player

This page will go over the Player API namespace.

This is based on EntityLiving class, therefore this support every method from Entity, as well as EntityLiving class.

Methods from the superclasses

isAnimal(): Boolean

Returns if the entity is an animal.

isMob(): Boolean

Returns if the entity is a mob.

isPlayer(): Boolean

Returns if the entity is a player.

getHealth(): Number

Returns the entity health.

getMaxHealth(): Number

Returns the maximum entity health.

getHurtTime(): Number

Returns the entity hurt time.

getMaxHurtTime(): Number

Returns the maximum entity hurt time.

getLastHurtTime(): Number

Returns the last entity hurt time.

getHeldItemStack(): ItemStack

Returns the held item stack of the entity.

isDead(): Boolean

Returns if the entity is dead.

isLiving(): Boolean

Returns if the entity is instance of LivingEntity.

getPosition(): Vector3

Returns the entity position.

getLastPosition(): Vector3

Returns the previous tick entity position.

getMotion(): Vector3

Returns the entity motion.

getRotation(): Vector2

Returns the entity rotation.

getLastRotation(): Vector2

Returns the previous tick entity rotation.

getTicksExisted(): Number

Returns the amount of ticks the entity has existed for.

getEntityId(): Number

Returns the entity ID.

getDisplayName(): String

Returns the entity display name.

getInventory(): Inventory

Returns the inventory of the entity.

getDistanceToEntity(entity): Number

Argument
Type
Description

entity

Entity

Another entity

Returns distance between this and another entity.

getDistance(x, y, z): Number

Argument
Type
Description

x

Number

X position.

y

Number

Y position.

z

Number

Z position.

Returns the distance between this entity and the specified position.

Exclusive to player API, not found in superclasses.

message(text): Undefined

Argument
Type
Description

text

String

Text to send in the chat.

Sends a chat message.

getName(): String

Returns the player name.

getPlayerID(): String

Returns the player ID.

isOnGround(): Boolean

Returns the mc.thePlayer.onGround variable

isMoving(): Boolean

Returns if the player is moving or not.

jump(): Undefined

Makes the player jump.

setSlot(Number slot): Undefined

Sets your slot.

strafe(speed): Undefined

Argument
Type
Description

speed

(Optional argument) Number

The speed to strafe at.

Makes the player strafe. speed argument is optional.

stop(): Undefined

Stops the player instantly.

setPosition(posX, posY, posZ): Undefined

Argument
Type
Description

posX

Number

Position X.

posY

Number

Position Y.

posZ

Number

Position Z.

Sets the player position with 3 Number arguments.

setPosition(vector): Undefined

Argument
Type
Description

vector

Vector3d

Vector3d with the player position.

Sets the player motion with a single Vector3d argument.

setMotion(motionX, motionY, motionZ): Undefined

Argument
Type
Description

motionX

Number

Motion X.

motionY

Number

Motion Y.

motionZ

Number

Motion Z.

Sets the player motion with 3 Number arguments.

setMotionX(motionX): Undefined

Argument
Type
Description

motionX

Number

The Motion X to apply to the player.

Sets the player motion on the X axis.

setMotionY(motionY): Undefined

Argument
Type
Description

motionY

Number

The Motion Y to apply to the player.

Sets the player motion on the Y axis.

setMotionZ(motionZ): Undefined

Argument
Type
Description

motionZ

Number

The Motion Z to apply to the player.

Sets the player motion on the Z axis.

setMotion(vector): Undefined

Argument
Type
Description

vector

Vector3d

Vector3d with the player motion.

Sets the player motion with a single Vector3d argument.

leftClick(): Undefined

Clicks left mouse button.

rightClick(): Undefined

Clicks right mouse button.

attackEntity(target): Undefined

Argument
Type
Description

target

EntityLiving

The entity to attack.

Attacks the target entity.

swingItem(): Undefined

Swings the currently held item.

message(message): Undefined

Argument
Type
Description

message

String

Message to send

Sends a chat message. You can not execute rise commands with this.

setRotation(rotations, rotationSpeed, movementFix): Undefined

Argument
Type
Description

rotations

Vector2

Angles to rotate to.

rotationSpeed

Number

Speed to rotate at. 10 is the maximum speed. 1 section is 18 degrees per tick.

movementFix

Boolean

Whether to fix movement to sync with the rotations or not.

Silently rotates your player to a specific set of angles.

setHeldItem(slot, render): Undefined

Run this on preUpdate for every tick you want the slot to be changed, if you want to permanently setslot use the "setSlot" method.

Argument
Type
Description

slot

Number

Hotbar slot to use.

render

Boolean

Whether to render the actually held item. This argument is optional.

Silently sets a held item.

getHeldItemStack(): ItemStack

Returns the serverside held item stack.

getClientHeldItemStack(): ItemStack

Returns the clientside held item stack.

getClientHeldItemSlot(): Number

Returns the clientside held item slot.

itemDamage(): Undefined

Damages the player using a snowball/fishing rod/bow.

damage(packet, timer): Undefined

Argument
Type
Description

packet

Boolean

Whether to do instant damage or slow damage.

timer

Number

Timer for the slow damage. This argument is optional and defaults to 1.

Damages the player without an item.

fakeDamage(): Undefined

Fake damages the player.

calculateRotations(to): Vector2

Argument
Type
Description

to

Vector3 or Entity

Entity or position to calculate rotations to.

Calculates rotations towards an entity / a position in the world.

getHurtTime(): Number

Returns the players hurt time.

isUsingItem(): Boolean

Returns whether the player is using an item.

isHoldingSword(): Boolean

Returns whether the player is holding a sword.

isHoldingTool(): Boolean

Returns whether the player is holding a tool.

isHoldingBlock(): Boolean

Returns whether the player is holding blocks.

getFoward(): Number

Returns a value depending on if forward or backwards are being pressed.

getStrafe(): Number

Returns a value depending on if left or right is being pressed.

getSpeed(): Number

Returns players speed.

getUseItemProgress(): Number

Returns use item progress.

setSprinting(sprinting): Undefined

Sets sprinting.

setClientRotations(yaw, pitch): Undefined

Sets client rotations.

getUseItemProgress(): Number

Returns use item progress.

getFallDistance(): Number

Returns fall distance.

getHunger(): Number

Returns hunger.

getAbsorption(): Number

Returns absorption.

isInWater(): Boolean

Returns true if in water.

isInLava(): Boolean

Returns true if in water.

setSneaking(sneaking): Undefined

Sets sneaking.

isInWeb(): Boolean

Returns true if in a web.

isOnLadder(): Boolean

Returns true if on a ladder.

isCollided(): Boolean

Returns true if collided.

isCollidedHorizontally(): Boolean

Returns true if collided horizontally.

isCollidedVertically(): Boolean

Returns true if collided vertically.

isPotionActive(Number potionID): Boolean

Returns true if the potion is active, refer to https://pastebin.com/U9SyiD9Y for potion ids.

placeBlock(ItemStack heldStack, Vector3d blockPos, Number side, Vector3d hitVec): Undefined

Allows you to place a block.

Use the corresponding number for the "side" argument in the placeBlock method
DOWN(0)
UP(1)
NORTH(2)
SOUTH(3)
WEST(4)
EAST(5)

getGUI(): String

Returns the name of the GUI you're in.

mouseOverEntity(entity, range): Boolean

Argument
Type
Description

entity

Entity

The Entity object of a Entity you want to check.

range

Number

The maximum distance of the entity (from the player)

Returns whether a player is aiming over an entity. Also includes rotations that are set by other modules.

Last updated