Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

MCPlayerEntity

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.player.MCPlayerEntity;

Extending MCLivingEntity

MCPlayerEntity extends MCLivingEntity. That means all methods available in MCLivingEntity are also available in MCPlayerEntity

Methods

Return Type: void

script.zs
MCPlayerEntity.addExhaustion(exhaustion as float) as void
ParameterTypeDescription
Parameter
exhaustion
Type
float
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.addExperienceLevels(levels as int) as void
ParameterTypeDescription
Parameter
levels
Type
int
Description
No Description Provided

Return Type: boolean

script.zs
// MCPlayerEntity.canUseCommandBlock() as boolean
myMCPlayerEntity.canUseCommandBlock();

Return Type: boolean

script.zs
MCPlayerEntity.drop(p_225609_1_ as boolean) as boolean
ParameterTypeDescription
Parameter
p_225609_1_
Type
boolean
Description
No Description Provided

Return Type: IItemStack

script.zs
// MCPlayerEntity.getCurrentItem() as IItemStack
myMCPlayerEntity.getCurrentItem();

Return Type: float

script.zs
// MCPlayerEntity.getExperience() as float
myMCPlayerEntity.getExperience();

Return Type: int

script.zs
// MCPlayerEntity.getExperienceLevel() as int
myMCPlayerEntity.getExperienceLevel();

Return Type: int

script.zs
// MCPlayerEntity.getExperienceTotal() as int
myMCPlayerEntity.getExperienceTotal();

Return Type: int

script.zs
// MCPlayerEntity.getFoodLevel() as int
myMCPlayerEntity.getFoodLevel();

Return Type: IItemStack

script.zs
MCPlayerEntity.getHeldItem(hand as MCHand) as IItemStack
ParameterTypeDescription
Parameter
hand
Type
MCHand
Description
No Description Provided

Return Type: PlayerInventory

script.zs
// MCPlayerEntity.getInventory() as PlayerInventory
myMCPlayerEntity.getInventory();

Return Type: IItemStack

script.zs
MCPlayerEntity.getInventoryItemStack(slotIndex as int) as IItemStack
ParameterTypeDescription
Parameter
slotIndex
Type
int
Description
No Description Provided

Return Type: float

script.zs
// MCPlayerEntity.getLuck() as float
myMCPlayerEntity.getLuck();

Return Type: int

script.zs
// MCPlayerEntity.getMaxInPortalTime() as int
myMCPlayerEntity.getMaxInPortalTime();

Return Type: MCTextComponent

script.zs
// MCPlayerEntity.getName() as MCTextComponent
myMCPlayerEntity.getName();

Gets the persisted NBT tag that is saved between deaths. Many mods use this to keep track of if they have given the player an item or not.

Return Type: MapData

script.zs
// MCPlayerEntity.getPersistentData() as MapData
myMCPlayerEntity.getPersistentData();

Return Type: int

script.zs
// MCPlayerEntity.getPortalCooldown() as int
myMCPlayerEntity.getPortalCooldown();

Return Type: float

script.zs
// MCPlayerEntity.getSaturationLevel() as float
myMCPlayerEntity.getSaturationLevel();

Return Type: int

script.zs
// MCPlayerEntity.getSleepTimer() as int
myMCPlayerEntity.getSleepTimer();

Return Type: void

script.zs
MCPlayerEntity.give(stack as IItemStack) as void
ParameterTypeDescription
Parameter
stack
Type
IItemStack
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.giveExperiencePoints(experience as int) as void
ParameterTypeDescription
Parameter
experience
Type
int
Description
No Description Provided

Return Type: boolean

script.zs
// MCPlayerEntity.isCreative() as boolean
myMCPlayerEntity.isCreative();

Return Type: boolean

script.zs
// MCPlayerEntity.isFake() as boolean
myMCPlayerEntity.isFake();

Return Type: boolean

script.zs
// MCPlayerEntity.isPushedByWater() as boolean
myMCPlayerEntity.isPushedByWater();

Return Type: boolean

script.zs
// MCPlayerEntity.isSecondaryUseActive() as boolean
myMCPlayerEntity.isSecondaryUseActive();

Return Type: boolean

script.zs
// MCPlayerEntity.isSpectator() as boolean
myMCPlayerEntity.isSpectator();

Return Type: boolean

script.zs
// MCPlayerEntity.isSwimming() as boolean
myMCPlayerEntity.isSwimming();

Return Type: boolean

script.zs
// MCPlayerEntity.isUser() as boolean
myMCPlayerEntity.isUser();

Return Type: boolean

script.zs
// MCPlayerEntity.needFood() as boolean
myMCPlayerEntity.needFood();

Return Type: void

script.zs
MCPlayerEntity.sendMessage(text as MCTextComponent) as void
ParameterTypeDescription
Parameter
text
Type
MCTextComponent
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.sendStatusMessage(text as MCTextComponent, actionBar as boolean) as void
ParameterTypeDescription
Parameter
text
Type
MCTextComponent
Description
No Description Provided
Parameter
actionBar
Type
boolean
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.setFoodLevel(value as int) as void
ParameterTypeDescription
Parameter
value
Type
int
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.swing(hand as MCHand, updateSelf as boolean) as void
ParameterTypeDescription
Parameter
hand
Type
MCHand
Description
No Description Provided
Parameter
updateSelf
Type
boolean
Description
No Description Provided

Return Type: void

script.zs
MCPlayerEntity.unlockRecipes(p_193102_1_ as MCResourceLocation[]) as void
ParameterTypeDescription
Parameter
p_193102_1_
Type
MCResourceLocation[]
Description
No Description Provided

Updates the player’s persisted data that is saved between deaths.

Return Type: void

script.zs
MCPlayerEntity.updatePersistentData(data as MapData) as void
ParameterTypeDescription
Parameter
data
Type
MapData
Description
No Description Provided

Return Type: void

script.zs
// MCPlayerEntity.wakeUp() as void
myMCPlayerEntity.wakeUp();

Properties

NameTypeHas GetterHas SetterDescription
Name
experience
Type
float
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
experienceLevel
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
experienceTotal
Type
int
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
fake
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
foodLevel
Type
int
Has Getter
true
Has Setter
true
Description
No Description Provided
Name
inventory
Type
PlayerInventory
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
name
Type
MCTextComponent
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
saturationLevel
Type
float
Has Getter
true
Has Setter
false
Description
No Description Provided