-
Notifications
You must be signed in to change notification settings - Fork 10
ZenUtilsPlayer
ZenUtilsPlayer is an expansion of IPlayer (crafttweaker.player.IPlayer
).
As this is a ZenExpansion, you can simply call the methods on any IPlayer object, or any of it's subtypes.
// Replace item at the given index within player's inventory
// will return a bool that states if the replacement is successful
// playerObj.replaceItemInInventory(int inventorySlot, IItemStack itemStack);
playerObj.replaceItemInInventory(20, <item:minecraft:iron_ingot> * 4);
@since 1.12.3
// gets a statistic field of the player
// returns an int
// playerObj.readStat(PlayerStat stat);
playerObj.readStat(PlayerStat.getBasicStat("stat.jump"));
// adds a value to a statistic field
// the amount parameter can be omitted, default is 1
// playerObj.addStat(PlayerStat stat, int amount)
playerObj.addStat(PlayerStat.getBasicStat("stat.jump"), 4);
// sets a statistic field to zero
// playerObj.takeStat(PlayerStat stat)
playerObj.takeStat(PlayerStat.getBasicStat("stat.jump"));
@since 1.14.3
ZenUtils allows to simulate a player interaction (right or left click). These methods are supposed to called only on server side.
Simulates a player right clicking an item but isn't targeting at a block or entity.
Returns a string represents the result of this interaction.
Probably return value: SUCCESS
PASS
FAIL
player.simulateRightClickItem(item, hand);
Parameter | Type | Description | Default value |
---|---|---|---|
item | IItemStack | The item that the player used | |
hand | IEntityEquipmentSlot | The hand that the player used. Only mainHand and offHand is allowed | mainHand |
Simulates a player right clicking a block with an item in hand.
Returns a string represents the result of this interaction.
Probably return value: SUCCESS
PASS
FAIL
player.simulateRightClickBlock(item, hand, pos, side, hitX, hitY, hitZ);
Parameter | Type | Description | Default value |
---|---|---|---|
item | IItemStack | The item that the player used | |
hand | IEntityEquipmentSlot | The hand that the player used. Only mainHand and offHand is allowed | mainHand |
pos | IBlockPos | The position of the block to be interacted | Determined by the player's eye direction |
side | IFacing | The side of the block to be interacted | Determined by the player's eye direction |
hitX | float | The relative X coordinate of the player click point, ranging from 0 to 1 | Determined by the player's eye direction |
hitY | float | The relative Y coordinate of the point the player clicked, ranging from 0 to 1 | Determined by the player's eye direction |
hitZ | float | The relative Z coordinate of the player click point, ranging from 0 to 1 | Determined by the player's eye direction |
Simulates a player right clicking an entity with a item in hand.
Returns a string represents the result of this interaction.
Probably return value: SUCCESS
PASS
FAIL
player.simulateRightClickEntity(entity, item, hand)
Parameter | Type | Description | Default value |
---|---|---|---|
entity | IEntity | The entity to be interacted | |
item | IItemStack | The item that the player used | the item the player held in the given hand |
hand | IEntityEquipmentSlot | The hand that the player used. Only mainHand and offHand is allowed | mainHand |
Simulates a player left clicking a block by main hand. Returns nothing.
player.simulateRightClickEntity(item, pos, side)
Parameter | Type | Description | Default value |
---|---|---|---|
item | IItemStack | The item that the player used | The item the player held in main hand |
pos | IBlockPos | The position of the block to be interacted | Determined by the player's eye direction |
side | IFacing | The side of the block to be interacted | Determined by the player's eye direction |
Simulates a player finishing using an item. (e.g. finishes eating)
Returns the result item, such as milk bucket to empty bucket.
player.simulateUseItemFinish(item, hand)
Parameter | Type | Description | Default value |
---|---|---|---|
item | IItemStack | The item that the player used | |
hand | IEntityEquipmentSlot | The hand that the player used. Only mainHand and offHand is allowed | player active hand |
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils