PlayerAbilitiesHelper
com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper
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
Methods
canModifyWorld
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
Returns the abilities block's permission-to-fly flag, distinct from getFlying().
Returns: if the player is allowed to fly.
getCreativeMode
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
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
Returns the wrapped abilities object's flight-speed value. Its default is
0.05.Returns: the player fly speed multiplier.
getInvulnerable
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
Returns the wrapped abilities object's walking-speed value. Its default is
0.1.Returns: the player's walk speed.
setAllowFlying
Sets the permission-to-fly flag in the wrapped abilities object.
Parameters:
b: whether flying should be allowed
Returns: self for chaining.
setFlying
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
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
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.