Repository navigation
ClientInputLocks API
ClientInputLocks API provides direct control over client input dimensions on Bedrock via UpdateClientInputLocksPacket. Inputs are locked at the client C++ engine level without position rubberbanding or server-side movement event loops.
pocketmine\player\InputLockFlags defines controllable input channels:
| Flag | Value | Disables |
|---|---|---|
InputLockFlags::MOVEMENT |
1 << 0 |
W/A/S/D movement & joystick walking |
InputLockFlags::ROTATION |
1 << 1 |
Camera pitch & yaw mouse/touch rotation |
InputLockFlags::JUMP |
1 << 2 |
Jump key / auto-jump |
InputLockFlags::SNEAK |
1 << 3 |
Sneak key |
InputLockFlags::MOUNT |
1 << 4 |
Mounting entities or vehicles |
InputLockFlags::DISMOUNT |
1 << 5 |
Dismounting from entities or vehicles |
InputLockFlags::HOTBAR |
1 << 6 |
Changing held item slot |
InputLockFlags::ATTACK |
1 << 7 |
Attack, block break, and interaction |
InputLockFlags::all() returns a bitmask containing all flags.
use pocketmine\player\InputLockFlags;
// Lock movement and jump
$player->lockInputs(InputLockFlags::MOVEMENT, InputLockFlags::JUMP);
// Check if a specific input is locked
if ($player->hasInputLock(InputLockFlags::MOVEMENT)) {
// Player cannot walk
}
// Unlock movement while keeping jump locked
$player->unlockInputs(InputLockFlags::MOVEMENT);
// Clear all active locks
$player->clearInputLocks();All input lock methods are located on pocketmine\player\Player:
-
Player::lockInputs(InputLockFlags ...$flags): void
Applies the specified locks. Merges with existing active locks and dispatchesPlayerInputLockEvent. -
Player::unlockInputs(InputLockFlags ...$flags): void
Removes the specified locks while retaining all other active locks. DispatchesPlayerInputLockEvent. -
Player::clearInputLocks(): void
Resets active input locks to0and sends an unlock packet to the client. -
Player::hasInputLock(InputLockFlags $flag): bool
Returns whether the player currently has the specified lock active. -
Player::getInputLocks(): int
Returns the raw integer bitmask of currently active input locks.
Locking or unlocking inputs fires PlayerInputLockEvent:
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInputLockEvent;
use pocketmine\player\InputLockFlags;
class LockListener implements Listener {
public function onInputLock(PlayerInputLockEvent $event): void {
$flags = $event->getFlags();
// Prevent locking camera rotation
if (($flags & InputLockFlags::ROTATION->value) !== 0) {
$event->setFlags($flags & ~InputLockFlags::ROTATION->value);
}
}
}