PlayerControllerMP
Can be used for controlling the local player.
Methods
attackEntity()
attackEntity(
entity):void
Attack an entity with the current item.
Parameters
entity
The target entity.
Returns
void
clickBlock()
clickBlock(
pos,facing):boolean
Start breaking a block.
Parameters
pos
The block position
facing
The face being hit (e.g. NORTH, SOUTH, UP, DOWN, EAST, WEST)
Returns
boolean
damageBlock()
damageBlock(
pos,facing):boolean
Continue damaging a block (hold action).
Parameters
pos
The position of the block.
facing
The direction you are interacting with.
Returns
boolean
True if action handled and we actually continue breaking the block.
destroyBlock()
destroyBlock(
pos,facing):boolean
Immediately destroy a block if allowed.
Parameters
pos
The position of the block.
facing
The direction you are interacting with.
Returns
boolean
extendedReach()
extendedReach():
boolean
Returns
boolean
True if extended reach is enabled (Creative).
flipPlayer()
flipPlayer(
player):void
Flip the player's yaw 180°.
Parameters
player
The player to flip.
Returns
void
gameIsSurvivalOrAdventure()
gameIsSurvivalOrAdventure():
boolean
Returns
boolean
True if in Survival or Adventure.
getBlockReachDistance()
getBlockReachDistance():
number
Returns
number
Reach distance in blocks.
getCurrentGameType()
getCurrentGameType():
number
Returns
number
Current game type ID (0=Survival,1=Creative,2=Adventure,3=Spectator).
interactWithEntity()
interactWithEntity(
entity):boolean
Interact with an entity (right-click).
Parameters
entity
The target entity.
Returns
boolean
True if handled.
isHittingBlock()
isHittingBlock():
boolean
Returns
boolean
True if currently breaking a block.
isInCreativeMode()
isInCreativeMode():
boolean
Returns
boolean
True if in Creative.
isNotCreative()
isNotCreative():
boolean
Returns
boolean
True if not in Creative.
isRidingHorse()
isRidingHorse():
boolean
Returns
boolean
True if the local player is riding a horse.
isSpectator()
isSpectator():
boolean
Returns
boolean
If the player is a spectator.
isSpectatorMode()
isSpectatorMode():
boolean
Returns
boolean
True if in Spectator mode.
resetBlockRemoving()
resetBlockRemoving():
void
Abort current block breaking progress.
Returns
void
rightClickBlock()
rightClickBlock(
pos,facing):boolean
Right-click a block with the currently held item.
Parameters
pos
The position of the block.
facing
The direction you are interacting with.
Returns
boolean
True if action handled.
setGameType()
setGameType(
gameType):void
Set the game type: 0 -> survival 1 -> creative 2 -> adventure 3 -> spectator
Parameters
gameType
number
Returns
void
shouldDrawHUD()
shouldDrawHUD():
boolean
Returns
boolean
True if the HUD should be drawn for the current game mode.
stopUsingItem()
stopUsingItem():
void
Release right-click usage (bows, food, etc.).
Returns
void
syncHotbar()
syncHotbar():
void
Sync the selected hotbar slot to the server.
Returns
void
updateController()
updateController():
void
Process incoming packets and keep controller in sync.
Returns
void
useItemInHand()
useItemInHand():
boolean
Use the currently held item (right-click in air).
Returns
boolean
True if the stack changed.
windowClick()
windowClick(
windowId,slot,button,mode):object
Perform an inventory click (client-side send + local container logic).
Parameters:
windowId: The container window ID (0 = player inventory, other IDs for open GUIs).
slot: Slot index to click. Use -999 to click outside (cursor drop).
button: Mouse button / index depending on mode.
mode: Integer 0..6: 0=PICKUP, 1=QUICK_MOVE, 2=SWAP, 3=CLONE, 4=THROW, 5=QUICK_CRAFT, 6=PICKUP_ALL
Returns: The ItemStack on the cursor after the click (or null if empty).
Parameters
windowId
number
windowId
slot
number
slot
button
number
button
mode
number
mode
Returns
object
ItemStack | null
Last updated