PlayerMouseButtonEvent
Package:
com.hypixel.hytale.server.core.event.events.playerExtends:PlayerEvent<Void>Implements:IEvent<Void>,ICancellableCancellable: Yes
Standard event dispatched when a player presses or releases a mouse button. Provides full context about the interaction including what the player is holding, what they are targeting (block or entity), and screen coordinates.
Cancelling this event prevents the mouse button action from being processed by the server.
Fields / Accessors
Section titled “Fields / Accessors”| Field | Type | Accessor | Mutable | Nullable |
|---|---|---|---|---|
playerRef | Ref<EntityStore> | getPlayerRef() | No | No |
player | Player | getPlayer() | No | No |
playerRefComponent | PlayerRef | getPlayerRefComponent() | No | No |
clientUseTime | long | getClientUseTime() | No | No |
itemInHand | Item | getItemInHand() | No | No |
targetBlock | Vector3i | getTargetBlock() | No | No |
targetEntity | Entity | getTargetEntity() | No | No |
screenPoint | Vector2f | getScreenPoint() | No | No |
mouseButton | MouseButtonEvent | getMouseButton() | No | No |
- playerRef — ECS reference to the player entity. Inherited from
PlayerEvent. - player — The player who triggered the input. Inherited from
PlayerEvent. - playerRefComponent — The
PlayerRefcomponent for the player. - clientUseTime — Client-side timestamp of the use action.
- itemInHand — The item the player is holding.
- targetBlock — World-space coordinates of the targeted block, if any.
- targetEntity — The targeted entity, if any.
- screenPoint — Screen-space coordinates of the mouse cursor.
- mouseButton — The mouse button event data (which button, press/release).
Fired By
Section titled “Fired By”InteractionModule.doMouseInteraction()(line 407) viaeventBus dispatchFor— EventBus dispatch when a player presses or releases a mouse button.
Listening
Section titled “Listening”getEventRegistry().register(PlayerMouseButtonEvent.class, event -> { MouseButtonEvent mouseButton = event.getMouseButton(); Player player = event.getPlayer(); Entity target = event.getTargetEntity();
// Example: cancel right-click interactions on specific entities if (target != null && mouseButton.isRightClick()) { event.setCancelled(true); }});Related Events
Section titled “Related Events”PlayerMouseMotionEvent— The companion input event for mouse movement/drag.PlayerInteractEvent— Deprecated predecessor.BreakBlockEvent— ECS event that may fire downstream if the mouse button triggers block mining.UseBlockEvent— ECS event that may fire downstream if the mouse button triggers block use.