# PlayerAbilitiesHelper

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

**Since:** 1.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()](PlayerEntityHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.entity.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 {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_constructor-Abilities-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_canModifyWorld-}

```js
canModifyWorld(): boolean
```

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.

**Since:** 1.8.4

### getAllowFlying {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getAllowFlying-}

```js
getAllowFlying(): boolean
```

Returns the abilities block's permission-to-fly flag, distinct from
 [getFlying()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getFlying-).

**Returns:** if the player is allowed to fly.

**Since:** 1.0.3

### getCreativeMode {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getCreativeMode-}

```js
getCreativeMode(): boolean
```

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.

**Since:** 1.0.3

### getFlying {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getFlying-}

```js
getFlying(): boolean
```

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.

**Since:** 1.0.3

### getFlySpeed {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getFlySpeed-}

```js
getFlySpeed(): float
```

Returns the wrapped abilities object's flight-speed value. Its default is `0.05`.

**Returns:** the player fly speed multiplier.

**Since:** 1.0.3

### getInvulnerable {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getInvulnerable-}

```js
getInvulnerable(): boolean
```

Returns the abilities block's invulnerability flag.

**Returns:** `true` when the invulnerability flag is set; damage sources that
 bypass invulnerability may still cause damage.

**Since:** 1.0.3

### getWalkSpeed {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_getWalkSpeed-}

```js
getWalkSpeed(): float
```

Returns the wrapped abilities object's walking-speed value. Its default is `0.1`.

**Returns:** the player's walk speed.

**Since:** 1.8.4

### setAllowFlying {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_setAllowFlying-boolean-}

```js
setAllowFlying(boolean b): PlayerAbilitiesHelper
```

Sets the permission-to-fly flag in the wrapped abilities object.

**Parameters:**
- `b`: whether flying should be allowed

**Returns:** self for chaining.

**Since:** 1.0.3

### setFlying {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_setFlying-boolean-}

```js
setFlying(boolean b): PlayerAbilitiesHelper
```

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.

**Since:** 1.0.3

### setFlySpeed {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_setFlySpeed-double-}

```js
setFlySpeed(double flySpeed): PlayerAbilitiesHelper
```

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.

**Since:** 1.0.3

### setWalkSpeed {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_setWalkSpeed-double-}

```js
setWalkSpeed(double speed): PlayerAbilitiesHelper
```

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.

**Since:** 1.8.4

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerAbilitiesHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation of the wrapped abilities' flags and movement speeds.

**Returns:** a diagnostic representation of the wrapped abilities
