Home Getting Started With Scripts Commands Examples
BracketDumpers BracketHandlers BracketValidators

Player

Importing the class

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 at the very top of the file.

script.zs
import crafttweaker.api.entity.type.player.Player;

Extending LivingEntity

Player extends LivingEntity. That means all methods available in LivingEntity are also available in Player

Methods

Return Type: boolean

script.zs
Player.addItem(stack as ItemStack) as boolean
ParameterTypeDescription
Parameter
stack
Type
ItemStack
Description
No Description Provided

Return Type: void

script.zs
Player.attack(entity as Entity) as void
ParameterTypeDescription
Parameter
entity
Type
Entity
Description
No Description Provided

Return Type: void

script.zs
Player.awardStat(stat as ResourceLocation) as void
ParameterTypeDescription
Parameter
stat
Type
ResourceLocation
Description
No Description Provided

Return Type: void

script.zs
Player.awardStat(stat as ResourceLocation, amount as int) as void
ParameterTypeDescription
Parameter
stat
Type
ResourceLocation
Description
No Description Provided
Parameter
amount
Type
int
Description
No Description Provided

Return Type: boolean

script.zs
Player.canEat(ignoreHunger as boolean) as boolean
ParameterTypeDescription
Parameter
ignoreHunger
Type
boolean
Description
No Description Provided

Return Type: boolean

script.zs
Player.canHarmPlayer(player as Player) as boolean
ParameterTypeDescription
Parameter
player
Type
Player
Description
No Description Provided

Return Type: boolean

script.zs
// Player.canUseGameMasterBlocks() as boolean
myPlayer.canUseGameMasterBlocks();

Return Type: void

script.zs
Player.causeFoodExhaustion(exhaustion as float) as void
ParameterTypeDescription
Parameter
exhaustion
Type
float
Description
No Description Provided

Return Type: void

script.zs
Player.crit(entity as Entity) as void
ParameterTypeDescription
Parameter
entity
Type
Entity
Description
No Description Provided

Return Type: void

script.zs
Player.disableShield(usingAxe as boolean) as void
ParameterTypeDescription
Parameter
usingAxe
Type
boolean
Description
No Description Provided

Return Type: void

script.zs
Player.displayClientMessage(component as Component, actionBar as boolean) as void
ParameterTypeDescription
Parameter
component
Type
Component
Description
No Description Provided
Parameter
actionBar
Type
boolean
Description
No Description Provided

Return Type: ItemEntity

script.zs
Player.drop(stack as ItemStack, traceItem as boolean) as ItemEntity
ParameterTypeDescription
Parameter
stack
Type
ItemStack
Description
No Description Provided
Parameter
traceItem
Type
boolean
Description
No Description Provided

Return Type: Abilities

script.zs
// Player.getAbilities() as Abilities
myPlayer.getAbilities();

Return Type: ItemCooldowns

script.zs
// Player.getCooldowns() as ItemCooldowns
myPlayer.getCooldowns();

Return Type: float

script.zs
// Player.getCurrentItemAttackStrengthDelay() as float
myPlayer.getCurrentItemAttackStrengthDelay();

Return Type: float

script.zs
Player.getDestroySpeed(state as BlockState) as float
ParameterTypeDescription
Parameter
state
Type
BlockState
Description
No Description Provided

Return Type: int

script.zs
// Player.getEnchantmentSeed() as int
myPlayer.getEnchantmentSeed();

Return Type: FoodData

script.zs
// Player.getFoodData() as FoodData
myPlayer.getFoodData();

Return Type: Inventory

script.zs
// Player.getInventory() as Inventory
myPlayer.getInventory();

Return Type: float

script.zs
// Player.getLuck() as float
myPlayer.getLuck();

Return Type: HumanoidArm

script.zs
// Player.getMainArm() as HumanoidArm
myPlayer.getMainArm();

Return Type: int

script.zs
// Player.getScore() as int
myPlayer.getScore();

Return Type: MapData

script.zs
// Player.getShoulderEntityLeft() as MapData
myPlayer.getShoulderEntityLeft();

Return Type: MapData

script.zs
// Player.getShoulderEntityRight() as MapData
myPlayer.getShoulderEntityRight();

Return Type: int

script.zs
// Player.getSleepTimer() as int
myPlayer.getSleepTimer();

Return Type: int

script.zs
// Player.getXpNeededForNextLevel() as int
myPlayer.getXpNeededForNextLevel();

Return Type: void

script.zs
Player.give(stack as IItemStack, slot as int) as void
ParameterTypeDescriptionOptionalDefaultValue
Parameter
stack
Type
IItemStack
Description
No Description Provided
Optional
false
DefaultValue
Parameter
slot
Type
int
Description
No Description Provided
Optional
true
DefaultValue
-1

Return Type: void

script.zs
Player.giveExperienceLevels(levels as int) as void
ParameterTypeDescription
Parameter
levels
Type
int
Description
No Description Provided

Return Type: void

script.zs
Player.giveExperiencePoints(amount as int) as void
ParameterTypeDescription
Parameter
amount
Type
int
Description
No Description Provided

Return Type: boolean

script.zs
Player.hasCorrectToolForDrops(state as BlockState) as boolean
ParameterTypeDescription
Parameter
state
Type
BlockState
Description
No Description Provided

Return Type: void

script.zs
Player.increaseScore(score as int) as void
ParameterTypeDescription
Parameter
score
Type
int
Description
No Description Provided

Return Type: boolean

script.zs
// Player.isCreative() as boolean
myPlayer.isCreative();

Return Type: boolean

script.zs
// Player.isHurt() as boolean
myPlayer.isHurt();

Return Type: boolean

script.zs
// Player.isLocalPlayer() as boolean
myPlayer.isLocalPlayer();

Return Type: boolean

script.zs
// Player.isReducedDebugInfo() as boolean
myPlayer.isReducedDebugInfo();

Return Type: boolean

script.zs
// Player.isScoping() as boolean
myPlayer.isScoping();

Return Type: boolean

script.zs
// Player.isSecondaryUseActive() as boolean
myPlayer.isSecondaryUseActive();

Return Type: boolean

script.zs
// Player.isSleepingLongEnough() as boolean
myPlayer.isSleepingLongEnough();

Return Type: void

script.zs
// Player.jumpFromGround() as void
myPlayer.jumpFromGround();

Return Type: void

script.zs
Player.magicCrit(entity as Entity) as void
ParameterTypeDescription
Parameter
entity
Type
Entity
Description
No Description Provided

Return Type: boolean

script.zs
// Player.mayBuild() as boolean
myPlayer.mayBuild();

Return Type: void

script.zs
Player.playNotifySound(event as SoundEvent, source as SoundSource, volume as float, pitch as float) as void
ParameterTypeDescription
Parameter
event
Type
SoundEvent
Description
No Description Provided
Parameter
source
Type
SoundSource
Description
No Description Provided
Parameter
volume
Type
float
Description
No Description Provided
Parameter
pitch
Type
float
Description
No Description Provided

Return Type: void

script.zs
// Player.respawn() as void
myPlayer.respawn();

Return Type: void

script.zs
Player.sendMessage(text as Component) as void
ParameterTypeDescription
Parameter
text
Type
Component
Description
No Description Provided

Return Type: boolean

script.zs
Player.setEntityOnShoulder(entityData as MapData) as boolean
ParameterTypeDescription
Parameter
entityData
Type
MapData
Description
No Description Provided

Return Type: void

script.zs
Player.setMainArm(arm as HumanoidArm) as void
ParameterTypeDescription
Parameter
arm
Type
HumanoidArm
Description
No Description Provided

Return Type: void

script.zs
Player.setReducedDebugInfo(reducedDebugInfo as boolean) as void
ParameterTypeDescription
Parameter
reducedDebugInfo
Type
boolean
Description
No Description Provided

Return Type: void

script.zs
Player.setScore(score as int) as void
ParameterTypeDescription
Parameter
score
Type
int
Description
No Description Provided

Return Type: void

script.zs
// Player.stopSleeping() as void
myPlayer.stopSleeping();

Return Type: void

script.zs
// Player.sweepAttack() as void
myPlayer.sweepAttack();

Properties

NameTypeHas GetterHas SetterDescription
Name
abilities
Type
Abilities
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
canUseGameMasterBlocks
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
cooldowns
Type
ItemCooldowns
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
currentItemAttackStrengthDelay
Type
float
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
enchantmentSeed
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
foodData
Type
FoodData
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
inventory
Type
Inventory
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isCreative
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isHurt
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isLocalPlayer
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isReducedDebugInfo
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isScoping
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isSecondaryUseActive
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
isSleepingLongEnough
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
luck
Type
float
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
mainArm
Type
HumanoidArm
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
mayBuild
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
score
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
shoulderEntityLeft
Type
MapData
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
shoulderEntityRight
Type
MapData
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
sleepTimer
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
xpNeededForNextLevel
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided