InteractEntity
com.jsmacrosce.jsmacros.client.api.event.impl.player.EventInteractEntity
Fires after the local player's entity-interact action returns, except when it returns InteractionResult.FAIL. result is true when the result consumes the action and false when it does not; false is not an event rejection. This event reports the interact action, not attacks, which use EventAttackEntity.
js
JsMacros.on("InteractEntity", JavaWrapper.methodToJava(function (event) {
Chat.log(`${event.result ? "Consumed" : "Passed"}: ${event.entity.getType()}`);
}))js
JsMacros.on("InteractEntity", JavaWrapper.methodToJava(function (event) {
if (event.result) {
Chat.log(`${event.offhand ? "Off hand" : "Main hand"} used on ${event.entity.getType()}`);
}
}))Constructors
new EventInteractEntity
Stores the interaction hand, consumption flag, and wrapped entity; this constructor does not perform or dispatch an interaction.
Parameters:
offhand: whether the supplied hand flag indicates the off hand;falseindicates the main handaccepted: the supplied action-consumption flag, stored asresultentity: the Minecraft entity to wrap; wrapping fails with NullPointerException if it isnull
Fields
entity
The clicked entity, wrapped in the most specific EntityHelper subclass for its type, so it can be narrowed with
instanceof EntityHelpers.Player and the other namespace types; asLiving(), asPlayer() and the other as...() helpers are casts. Its type is available from getType() and its name from getName().offhand
true if the click was made with the off hand, false if it was made with the main hand.result
true if the interaction result consumes the action, false if it does not. The event is not fired when the result is FAIL.