Skip to content

Riding ​

com.jsmacrosce.jsmacros.client.api.event.impl.player.EventRiding

Since1.5.0Not cancellable

Fires from a startRiding return path when the local player attempts to mount, or when the player begins removing an existing vehicle. The mount event does not establish that riding succeeded. state is true for mounting and false for dismounting;
entity is the targeted entity or former vehicle, respectively. The dismount event also fires for externally caused dismounts.

js
JsMacros.on("Riding", JavaWrapper.methodToJava(function (event) {
 if (event.state) {
   Chat.log(`Mounting ${event.entity.getType()}`);  
 } else {
   Chat.log(`Dismounted from ${event.entity.getType()}`);  
 }
}))

Constructors ​

new EventRiding ​

new EventRiding(boolean state, Entity entity)#
Initializes the event with the supplied state and a wrapped entity; this does not perform a mount or dismount.

Parameters:

  • state: true for mounting or false for dismounting; this flag does not establish that riding succeeded
  • entity: raw Minecraft entity to wrap: target when mounting or former vehicle when dismounting; null fails with NullPointerException during wrapping

Fields ​

entity ​

entity: EntityHelper<?>read-only#
The mounted entity when state is true, or the former vehicle when it is false. It is wrapped in the corresponding EntityHelper subclass.

state ​

state: booleanread-only#
true when the player started riding, false when the player dismounted.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and the state and entity values.
Returns: the event name followed by {"state": boolean, "entity": entity}, with the boolean unquoted and the entity represented by its toString() result