Skip to content

PlayerAbilitiesHelper ​

com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper

Since1.0.3

Reads and changes the local player's abilities, including flight, invulnerability,
movement speed, and permission to build. Changes write directly to the wrapped abilities object; server updates may subsequently replace them.

Obtain the helper from PlayerEntityHelper.getAbilities().

js
const player = Player.getPlayer();  
if (player !== null) {
 const abilities = player.getAbilities();  
 if (abilities.getCreativeMode()) {
   // the game reads the walk speed as a fraction of its normal value
   abilities.setWalkSpeed(0.4);  
   Chat.log(`walk speed is now ${abilities.getWalkSpeed()}`);  
 }
}

Constructors ​

new PlayerAbilitiesHelper ​

new PlayerAbilitiesHelper(Abilities a)#
Wraps the supplied abilities object without copying it or selecting a player.

Parameters:

  • a: the raw player abilities object to wrap

Methods ​

canModifyWorld ​

canModifyWorld(): booleanSince1.8.4#
Returns the abilities block's may-build flag. Other game or mod restrictions may still prevent a particular world interaction.
Returns: true if the player is allowed to modify the world, false otherwise.

getAllowFlying ​

getAllowFlying(): booleanSince1.0.3#
Returns the abilities block's permission-to-fly flag, distinct from getFlying().
Returns: if the player is allowed to fly.

getCreativeMode ​

getCreativeMode(): booleanSince1.0.3#
Returns the abilities block's instant-build flag; this is not itself a query of the player's current game mode.
Returns: if the player is in creative.

getFlying ​

getFlying(): booleanSince1.0.3#
Returns the abilities block's flying-state flag; this does not indicate merely whether the player is airborne.
Returns: if the player is currently flying.

getFlySpeed ​

getFlySpeed(): floatSince1.0.3#
Returns the wrapped abilities object's flight-speed value. Its default is 0.05.
Returns: the player fly speed multiplier.

getInvulnerable ​

getInvulnerable(): booleanSince1.0.3#
Returns the abilities block's invulnerability flag.
Returns: true when the invulnerability flag is set; damage sources that bypass invulnerability may still cause damage.

getWalkSpeed ​

getWalkSpeed(): floatSince1.8.4#
Returns the wrapped abilities object's walking-speed value. Its default is 0.1.
Returns: the player's walk speed.

setAllowFlying ​

setAllowFlying(boolean b): PlayerAbilitiesHelperSince1.0.3#
Sets the permission-to-fly flag in the wrapped abilities object.

Parameters:

  • b: whether flying should be allowed
Returns: self for chaining.

setFlying ​

setFlying(boolean b): PlayerAbilitiesHelperSince1.0.3#
Sets the flying-state flag in the abilities block. This changes the flag, not the player's position; server updates may replace the local value.

Parameters:

  • b: whether the flying state should be set
Returns: self for chaining.

setFlySpeed ​

setFlySpeed(double flySpeed): PlayerAbilitiesHelperSince1.0.3#
Sets the wrapped abilities object's flight-speed value, converting the input to a float.

Parameters:

  • flySpeed: the new flight speed multiplier
Returns: self for chaining.

setWalkSpeed ​

setWalkSpeed(double speed): PlayerAbilitiesHelperSince1.8.4#
Sets the wrapped abilities object's walking-speed value, converting the input to a float.

Parameters:

  • speed: the new walk speed
Returns: self for chaining.

toString ​

toString(): String#
Returns a diagnostic representation of the wrapped abilities' flags and movement speeds.
Returns: a diagnostic representation of the wrapped abilities