InteractionManagerHelper
com.jsmacrosce.jsmacros.client.api.helper.InteractionManagerHelper
Controls client-side player interactions with the world through the current interaction manager.
Obtain it with Player.interactions(), which is null when no interaction manager is available. Block and entity target overrides affect operations that use the crosshair until cleared; range and block checks may also clear or turn an override into a miss.
An await option waits for the queued client-thread invocation when called from outside the client thread and its joined-thread stack; it does not wait for server confirmation.
Calls on that stack execute directly. breakBlock() rejects waiting on that stack after checking for an immediate result; timed holdInteract(int) calls reject it before enabling the hold. Waiting can be interrupted; interruption during a timed hold can leave the interact override enabled.
const interactions = Player.interactions();
if (interactions === null) { throw new Error("not in a world"); }
interactions.breakBlockAsync(JavaWrapper.methodToJava(function (result) {
Chat.log(`break finished as ${result.reason}`);
}));Constructors
new InteractionManagerHelper
new InteractionManagerHelper(MultiPlayerGameMode base)#Parameters:
base: initial interaction manager to wrap
Fields
autoUpdateBase
autoUpdateBase: boolean#true; when disabled, a mismatch throws RuntimeException. If no replacement manager exists, updating fails and retains the wrapped manager. See checkBase(boolean) for the exact result.Methods
attack
Parameters:
await: whether to wait for the queued client-thread attack call to finish when called outside the client thread and its joined-thread stack; calls on that stack execute directly. This does not wait for server confirmation
Parameters:
entity: entity to attack; targeting the local player throwsAssertionError
Parameters:
entity: entity to attack; targeting the local player throwsAssertionErrorawait: whether to wait for the queued attack and swing to finish when called outside the client thread and its joined-thread stack; calls on that stack execute directly. This does not wait for server confirmation
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: block face name:up,down,north,south,east, orwest
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face's 3D data value (0-5: down, up, north, south, west, east)
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: block face name:up,down,north,south,east, orwestawait: whether to wait for the queued block-breaking call and swing to finish when called outside the client thread and its joined-thread stack; calls on that stack execute directly. This does not wait for server confirmation
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face's 3D data value (0-5: down, up, north, south, west, east)await: whether to wait for the queued block-breaking call and swing to finish when called outside the client thread and its joined-thread stack; calls on that stack execute directly. This does not wait for server confirmation
breakBlock
NO_TARGET, not by returning null.UNAVAILABLE when the immediate check finds no interaction managerParameters:
x: block x coordinatey: block y coordinatez: block z coordinate
null if the position cannot be targetedpos, temporarily overriding the target when needed.Parameters:
pos: position to break
null if the position cannot be targetedbreakBlockAsync
breakBlockAsync(MethodWrapper<InteractionProxy.Break.BreakBlockResult, Object, ?, ?> callback): InteractionManagerHelperSince1.9.0#callback. A null callback starts the break without registering for its outcome. SUCCESS means the client completed the break; it does not guarantee server acceptance. Immediate-result callbacks are submitted to the client thread, and normal game-driven completion runs there. Cancellation, target clearing, reset, or a break-override query can instead invoke pending callbacks synchronously on the calling thread. const interactions = Player.interactions();
if (interactions === null) { throw new Error("not in a world"); }
// start it and carry on, with the outcome arriving later
interactions.breakBlockAsync(JavaWrapper.methodToJava(function (result) {
if (result !== null) {
Chat.log(`break finished as ${result.reason}`);
}
}));Parameters:
callback: receives the break outcome
cancelBreakBlock
CANCELLED to registered callbacks. Callbacks run synchronously on the caller's thread.checkBase
checkBase(boolean update): boolean#true, including when both are null. A mismatch with update == false throws RuntimeException.Parameters:
update: whether to replace a stale manager with a non-null current manager
true if the references match or replacement succeeds; false if replacement was requested but the current manager is null, leaving the wrapped manager unchangedclearTargetOverride
getGameMode
getTarget
null if none is availablegetTargetedBlock
null when the current hit result is not a block hitgetTargetedEntity
null when there is no crosshair entityhasBreakBlockOverride
true while a valid break override remains activehasInteractOverride
hasTargetOverride
holdInteract
Parameters:
holding: whether to enable or disable the override
Parameters:
holding: whether to enable or disable the overrideawaitFirstClick: whether to wait for queued enabling work, not server confirmation; ignored when disabling
Parameters:
ticks: number of ticks to hold
stopOnPause enabled or if the override stopped, and 0 when the full duration elapsedParameters:
ticks: number of unpaused ticks to holdstopOnPause: whether to stop when the game is paused; iffalse, paused ticks do not count and the hold resumes after unpausing
stopOnPause enabled or if the override stopped, and 0 when the full duration elapsedinteract
Parameters:
await: whether to wait for the queued client-thread invocation; calls on the client or joined-thread stack execute directly, and no server confirmation is awaited
interactBlock
interactBlock(int x, int y, int z, String direction, boolean offHand): InteractionManagerHelperSince1.8.4#direction.Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face name:up,down,north,south,east, orwestoffHand: whether to use the off hand instead of the main hand
interactBlock(int x, int y, int z, int direction, boolean offHand): InteractionManagerHelperSince1.5.0#Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face data value:0down,1up,2north,3south,4west,5eastoffHand: whether to use the off hand instead of the main hand
interactBlock(int x, int y, int z, String direction, boolean offHand, boolean await): InteractionManagerHelperSince1.8.4#direction.Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face name:up,down,north,south,east, orwestoffHand: whether to use the off hand instead of the main handawait: whether to wait for the queued client-thread task to run; it does not wait for server confirmation
interactBlock(int x, int y, int z, int direction, boolean offHand, boolean await): InteractionManagerHelperSince1.5.0#Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face data value:0down,1up,2north,3south,4west,5eastoffHand: whether to use the off hand instead of the main handawait: whether to wait for the queued client-thread task to run; it does not wait for server confirmation
interactEntity
entity using the selected hand.Parameters:
entity: entity to interact with; the local player's entity causesAssertionErroroffHand: whether to use the off hand instead of the main hand
interactEntity(EntityHelper<?> entity, boolean offHand, boolean await): InteractionManagerHelperSince1.6.0#Parameters:
entity: entity to interact with; the player's own entity causes an AssertionErroroffHand: whether to use the off hand instead of the main handawait: whether to wait for the queued client-thread task to run; it does not wait for server confirmation
interactItem
Parameters:
offHand: whether to use the off hand instead of the main hand
Parameters:
offHand: whether to use the off hand instead of the main handawait: whether to wait for the queued client-thread task to run; it does not wait for server confirmation
isBreakingBlock
resetTargetChecks
setGameMode
Parameters:
gameMode: game mode name; recognized names are case-insensitive, and unrecognized names retain the current mode
setTarget
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinate
const interactions = Player.interactions();
if (interactions === null) { throw new Error("not in a world"); }
// act on the top face of a specific block, then put the crosshair back
interactions.setTarget(10, 64, -10, "up");
interactions.interactBlock(10, 64, -10, "up", false);
interactions.clearTargetOverride();Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: block face name:up,down,north,south,east, orwest
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinatedirection: face's 3D data value (0-5: down, up, north, south, west, east)
pos and its down face.Parameters:
pos: block position
pos and the named face.Parameters:
pos: block positiondirection: block face name:up,down,north,south,east, orwest
pos and the face identified by its 3D data value.Parameters:
pos: block positiondirection: face's 3D data value (0-5: down, up, north, south, west, east)
AssertionError if the entity is not pickable or is the local player.Parameters:
entity: entity to target
setTargetAirCheck
Parameters:
enabled: whether to check if a block target is air; defaults tofalseautoClear: whether an air-block override is cleared; iffalse, it becomes a miss
setTargetMissed
setTargetRangeCheck
Parameters:
enabled: whether to check override range; defaults totrueautoClear: whether an out-of-range override is cleared; iffalse, it becomes a miss
setTargetShapeCheck
Parameters:
enabled: whether to check for an empty block shape; defaults totrueautoClear: whether an override with an empty shape is cleared; otherwise it becomes a miss. Defaults tofalse