Class InputEvent.InteractionKeyMappingTriggered
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.InputEvent
net.neoforged.neoforge.client.event.InputEvent.InteractionKeyMappingTriggered
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Enclosing class:
InputEvent
public static class InputEvent.InteractionKeyMappingTriggered
extends InputEvent
implements net.neoforged.bus.api.ICancellableEvent
Fired when a keymapping that by default involves clicking the mouse buttons is triggered.
The key bindings that trigger this event are:
- Use Item - defaults to left mouse click
- Pick Block - defaults to middle mouse click
- Attack - defaults to right mouse click
This event is cancellable, and does not
.
If this event is cancelled, then the keymapping's action is not processed further, and the hand will be swung
according to invalid reference
have a result
shouldSwingHand()
.
This event is fired on the main Forge event bus, only on the logical client.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.client.event.InputEvent
InputEvent.InteractionKeyMappingTriggered, InputEvent.Key, InputEvent.MouseButton, InputEvent.MouseScrollingEvent
-
Field Summary
Modifier and TypeFieldDescriptionprivate final int
private final InteractionHand
private boolean
private final KeyMapping
-
Constructor Summary
ConstructorDescriptionInteractionKeyMappingTriggered
(int button, KeyMapping keyMapping, InteractionHand hand) -
Method Summary
Modifier and TypeMethodDescriptiongetHand()
Returns the hand that caused the input.Returns the key mapping which triggered this event.boolean
isAttack()
Returnstrue
if the mouse button is the left mouse button.boolean
Returnstrue
if the mouse button is the middle mouse button.boolean
Returnstrue
if the mouse button is the right mouse button.void
setSwingHand
(boolean value) Sets whether to swing the hand.boolean
Returns whether to swing the hand; always takes effect, regardless of cancellation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
button
private final int button -
keyMapping
-
hand
-
handSwing
private boolean handSwing
-
-
Constructor Details
-
InteractionKeyMappingTriggered
@Internal public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand)
-
-
Method Details
-
setSwingHand
public void setSwingHand(boolean value) Sets whether to swing the hand. This takes effect whether or not the event is cancelled.- Parameters:
value
- whether to swing the hand
-
shouldSwingHand
public boolean shouldSwingHand()Returns whether to swing the hand; always takes effect, regardless of cancellation.- Returns:
- whether to swing the hand; always takes effect, regardless of cancellation
-
getHand
Returns the hand that caused the input.The event will be called for both hands if this is a use item input regardless of both event's cancellation. Will always be
InteractionHand.MAIN_HAND
if this is an attack or pick block input.- Returns:
- the hand that caused the input
-
isAttack
public boolean isAttack()Returnstrue
if the mouse button is the left mouse button.- Returns:
true
if the mouse button is the left mouse button
-
isUseItem
public boolean isUseItem()Returnstrue
if the mouse button is the right mouse button.- Returns:
true
if the mouse button is the right mouse button
-
isPickBlock
public boolean isPickBlock()Returnstrue
if the mouse button is the middle mouse button.- Returns:
true
if the mouse button is the middle mouse button
-
getKeyMapping
Returns the key mapping which triggered this event.- Returns:
- the key mapping which triggered this event
-