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.
Zengetters
Link to zengetters
Zengetters are for retrieving information. Usually either assigned to a variable or used in a method/function.
Zengetter | 功能 | 返回值类型 | Usage |
---|---|---|---|
Zengetter uuid | 功能 返回玩家UID | 返回值类型 string | Usage 播放器.uuid |
Zengetter name(名称) | 功能 returns the player's name | 返回值类型 string | Usage player.name |
Zengetter data | 功能 returns the player's data | 返回值类型 IData #数据 | Usage player.data |
Zengetter xp (经验值) | 功能 returns the player's experience level. Can also be used to set a player's experience level | 返回值类型 int | Usage player.xp |
Zengetter hotbarSize | 功能 returns the player's hotbar size | 返回值类型 int | Usage player.hotbarSize |
Zengetter inventorySize | 功能 returns the player's inventory size | 返回值类型 int | Usage player.inventorySize |
Zengetter currentItem | 功能 returns the item the player is currently holding | 返回值类型 IItemstack | Usage player.currentItem |
Zengetter creative | 功能 returns if the player is currently in creative mode (a.k.a gamemode 1) | 返回值类型 bool | Usage player.creative |
Zengetter adventure | 功能 returns if the player is currently in adventure mode (a.k.a gamemode 2) | 返回值类型 bool | Usage player.adventure |
Zengetter x | 功能 returns the player's current X position in the world | 返回值类型 double | Usage player.x |
Zengetter y | 功能 returns the player's current y position in the world | 返回值类型 double | Usage player.y |
Zengetter z | 功能 returns the player's current z position in the world | 返回值类型 double | Usage player.z |
Zengetter position | 功能 returns the player's current position. Can also be used to set a player's position | 返回值类型 Position3f | Usage player.position |
Zengetter foodStats | 功能 returns the player's foodstats. | 返回值类型 IFoodStats | Usage player.foodStats |
Zengetter bedLocation | 功能 returns the location of the player's bed. | 返回值类型 IBlockPos | Usage player.bedLocation |
Zengetter fishHook | 功能 returns the player's fishingrod entity. | 返回值类型 [IEntityFishHook ](/Vanilla/Entities/IEntityFishHook /) | Usage player.fishHook |
Zengetter foodStats | 功能 returns the player's foodstats. | 返回值类型 IFoodStats | Usage player.foodStats |
ZenMethods
Link to zenmethods
ZenMethods 是为了与其他东西做事,在这种情况下是与一名玩家做事。
ZenMethod | Parameter Type(s) | 功能 | 例子 |
---|---|---|---|
ZenMethod removeXP(XPtoRemove) | Parameter Type(s) int | 功能 Removes the given experience levels from the player. | 例子 player.removeXP(1) |
ZenMethod update(IData) | Parameter Type(s) IData #数据 | 功能 Updates the playerdata to the provided IData. | 例子 |
ZenMethod sendChat(Message) | Parameter Type(s) string OR IChatMessage | 功能 Sends the player a Chat Message. | 例子 player.sendChat("Hello my old friend") |
ZenMethod sendStatusMessage(message, hotbar) | Parameter Type(s) string OR IFormattedText | 功能 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 | 功能 same as sendStatusMessage , but the message is an ITextComponent | 例子 |
ZenMethod getHotbarStack(index) | Parameter Type(s) int | 功能 Returns the item at the given index within the player's hotbar. | 例子 player.getHotbarStack(3) |
ZenMethod getInventoryStack(index) | Parameter Type(s) int | 功能 Returns the item at the given index within the player's inventory. | 例子 player.getInventoryStack(3) |
ZenMethod give(item) | Parameter Type(s) IItemstack | 功能 Give the player the provided item. Item is an IItemStack. | 例子 player.give(<minecraft:gold_ingot>) |
ZenMethod teleport(position) | Parameter Type(s) Position3f | 功能 Teleports the player to the provided position in the same dimension | 例子 player.teleport(position) |
ZenMethod executeCommand(raw) | Parameter Type(s) string | 功能 Executes the command as the player | 例子 player.executeCommand("kill") |
ZenMethod dropItem(dropAll) | Parameter Type(s) bool | 功能 Drops the current item (or the entire stack) that the player is holding. | 例子 player.dropItem(false) |
ZenMethod dropItem(itemToDrop) | Parameter Type(s) IItemstack | 功能 Drops the provided item at the player's position. | 例子 player.dropItem(<minecraft:dirt>) |
ZenMethod getCooldown(item) | Parameter Type(s) IItemstack | 功能 Gets current cooldown of specific item for the player | 例子 player.getCooldown(<minecraft:ender_pearl>) |
ZenMethod setCooldown(item, time) | Parameter Type(s) IItemStack, int | 功能 Sets cooldown time of specific item for the player | 例子 player.setCooldown(<minecraft:ender_pearl>, 3) |