Skip to content

InteractBlock ​

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

Since1.8.0Not cancellable

Fires after a local block-use attempt returns, unless the result is FAIL. result is true when the interaction consumes an action; false means it was passed along without consuming one, not that it failed.

js
JsMacros.on("InteractBlock", JavaWrapper.methodToJava(function (event) {
 if (event.result) {
   Chat.log(`${event.offhand ? "Off hand" : "Main hand"} used on ${event.block.getId()}`);  
 }
}))

Constructors ​

new EventInteractBlock ​

new EventInteractBlock(boolean offhand, boolean accepted, BlockDataHelper block, int side)#
Stores the supplied block-interaction data and initializes the event with the client core.

Parameters:

  • offhand: whether the supplied hand flag identifies the off hand; false identifies the main hand
  • accepted: supplied action-consumption flag, stored as result
  • block: the supplied block helper reference
  • side: the supplied hit-face code

Fields ​

block ​

block: BlockDataHelperread-only#
The clicked block as seen by the client, including its block entity when present.

offhand ​

offhand: booleanread-only#
true if the click was made with the off hand, false if it was made with the main hand.

result ​

result: booleanread-only#
true when the interaction consumes an action; false when it passes without consuming one. This event is not fired for a FAIL result.

side ​

side: intread-only#
The clicked face's numeric direction id: 0 down, 1 up, 2 north, 3 south, 4 west and 5 east.

Methods ​

toString ​

toString(): String#
Returns this event's formatted string representation. The payload has the form eventName:{"block": helper, "result": "boolean"}; the boolean value is quoted, and the offhand and side values are omitted. This is not JSON.
Returns: the event-name-prefixed representation containing the block helper and stored result