IPlayer
Link to iplayer
The IPlayer interface allows you to view certain information on a specific player and interact with said one. Mostly used in Event Handlers and Recipe Functions.
Импорт пакета
Link to импорт-пакета
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.player.IPlayer;
Extending IEntityLivingBase and IUser
Link to extending-ientitylivingbase-and-iuser
IPlayer extends IEntityLivingBase. That means all functions available to IEntityLivingBase Objects also are available to IPlayer Objects.
IPlayer also extends IUser. That means all functions available to IUser Objects also are available to IPlayer Objects.
Геттеры
Link to геттеры
Zengetters are for retrieving information. Usually either assigned to a variable or used in a method/function.
Геттер | What does it do | Возвращаемый тип | Usage |
---|---|---|---|
Геттер uuid | What does it do возвращает UUID игрока | Возвращаемый тип string | Usage игрок.uuid |
Геттер name | What does it do returns the player's name | Возвращаемый тип string | Usage player.name |
Геттер data | What does it do returns the player's data | Возвращаемый тип IData | Usage player.data |
Геттер xp | What does it do returns the player's experience level. Can also be used to set a player's experience level | Возвращаемый тип int | Usage player.xp |
Геттер hotbarSize | What does it do returns the player's hotbar size | Возвращаемый тип int | Usage player.hotbarSize |
Геттер inventorySize | What does it do returns the player's inventory size | Возвращаемый тип int | Usage player.inventorySize |
Геттер currentItem | What does it do returns the item the player is currently holding | Возвращаемый тип IItemStack | Usage player.currentItem |
Геттер creative | What does it do returns if the player is currently in creative mode (a.k.a gamemode 1) | Возвращаемый тип bool | Usage player.creative |
Геттер adventure | What does it do returns if the player is currently in adventure mode (a.k.a gamemode 2) | Возвращаемый тип bool | Usage player.adventure |
Геттер x | What does it do returns the player's current X position in the world | Возвращаемый тип double | Usage player.x |
Геттер y | What does it do returns the player's current y position in the world | Возвращаемый тип double | Usage player.y |
Геттер z | What does it do returns the player's current z position in the world | Возвращаемый тип double | Usage player.z |
Геттер position | What does it do returns the player's current position. Can also be used to set a player's position | Возвращаемый тип Position3f | Usage player.position |
Геттер foodStats | What does it do returns the player's foodstats. | Возвращаемый тип IFoodStats | Usage player.foodStats |
Геттер bedLocation | What does it do returns the location of the player's bed. | Возвращаемый тип IBlockPos | Usage player.bedLocation |
Геттер fishHook | What does it do returns the player's fishingrod entity. | Возвращаемый тип [IEntityFishHook ](/Vanilla/Entities/IEntityFishHook /) | Usage player.fishHook |
Геттер foodStats | What does it do returns the player's foodstats. | Возвращаемый тип IFoodStats | Usage player.foodStats |
ZenMethods
Link to zenmethods
Методы ZenMethods для действий с другими вещами, в этом случае с игроком.
ZenMethod | Parameter Type(s) | What does it do | Пример |
---|---|---|---|
ZenMethod removeXP(XPtoRemove) | Parameter Type(s) int | What does it do Removes the given experience levels from the player. | Пример player.removeXP(1) |
ZenMethod update(IData) | Parameter Type(s) IData | What does it do Updates the playerdata to the provided IData. | Пример |
ZenMethod sendChat(Message) | Parameter Type(s) string OR IChatMessage | What does it do Sends the player a Chat Message. | Пример player.sendChat("Hello my old friend") |
ZenMethod sendStatusMessage(message, hotbar) | Parameter Type(s) string OR IFormattedText | What does it do Sends the player a status message, if the hotbar argument is true, the message will be displayed on player's hotbar, the default value is true | Пример player.sendStatusMessage("hello, world") |
ZenMethod sendRichTextStatusMessage(message, hotbar) | Parameter Type(s) ITextComponent | What does it do same as sendStatusMessage , but the message is an ITextComponent | Пример |
ZenMethod getHotbarStack(index) | Parameter Type(s) int | What does it do Returns the item at the given index within the player's hotbar. | Пример player.getHotbarStack(3) |
ZenMethod getInventoryStack(index) | Parameter Type(s) int | What does it do Returns the item at the given index within the player's inventory. | Пример player.getInventoryStack(3) |
ZenMethod give(item) | Parameter Type(s) IItemStack | What does it do Give the player the provided item. Предмет имеет тип IItemStack. | Пример player.give(<minecraft:gold_ingot>) |
ZenMethod teleport(position) | Parameter Type(s) Position3f | What does it do Teleports the player to the provided position in the same dimension | Пример player.teleport(position) |
ZenMethod executeCommand(raw) | Parameter Type(s) string | What does it do Executes the command as the player | Пример player.executeCommand("kill") |
ZenMethod dropItem(dropAll) | Parameter Type(s) bool | What does it do Drops the current item (or the entire stack) that the player is holding. | Пример player.dropItem(false) |
ZenMethod dropItem(itemToDrop) | Parameter Type(s) IItemStack | What does it do Drops the provided item at the player's position. | Пример player.dropItem(<minecraft:dirt>) |
ZenMethod getCooldown(item) | Parameter Type(s) IItemStack | What does it do Gets current cooldown of specific item for the player | Пример player.getCooldown(<minecraft:ender_pearl>) |
ZenMethod setCooldown(item, time) | Parameter Type(s) IItemStack, int | What does it do Sets cooldown time of specific item for the player | Пример player.setCooldown(<minecraft:ender_pearl>, 3) |