Skip to content

PlayerMouseButtonEvent

Package: com.hypixel.hytale.server.core.event.events.player Extends: PlayerEvent<Void> Implements: IEvent<Void>, ICancellable Cancellable: Yes Key type: Void

Dispatched when a player presses or releases a mouse button. This event 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.

Because the key type is Void, this event is dispatched globally — all registered listeners receive it regardless of key.

FieldTypeAccessorMutableNotes
playerRefRef<EntityStore>getPlayerRef()NoECS reference to the player entity. Inherited from PlayerEvent.
playerPlayergetPlayer()NoThe player who triggered the input. Inherited from PlayerEvent.
playerRefComponentPlayerRefgetPlayerRefComponent()NoThe PlayerRef component for the player.
clientUseTimelonggetClientUseTime()NoClient-side timestamp of the use action.
itemInHandItemgetItemInHand()NoThe item the player is holding.
targetBlockVector3igetTargetBlock()NoWorld-space coordinates of the targeted block, if any.
targetEntityEntitygetTargetEntity()NoThe targeted entity, if any.
screenPointVector2fgetScreenPoint()NoScreen-space coordinates of the mouse cursor.
mouseButtonMouseButtonEventgetMouseButton()NoThe mouse button event data (which button, press/release).
  • InteractionModule.doMouseInteraction() (line 407) via eventBus.dispatchFor() — dispatched when a player presses or releases a mouse button during gameplay interaction processing.
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);
}
});
  • PlayerMouseMotionEvent — the companion input event for mouse movement/drag. Together these two events cover all mouse input.
  • PlayerInteractEventdeprecated predecessor. PlayerMouseButtonEvent is one of its replacements.
  • 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.