Skip to content

PlayerMouseButtonEvent

Package: com.hypixel.hytale.server.core.event.events.player Extends: PlayerEvent<Void> Implements: IEvent<Void>, ICancellable Cancellable: 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.

FieldTypeAccessorMutableNullable
playerRefRef<EntityStore>getPlayerRef()NoNo
playerPlayergetPlayer()NoNo
playerRefComponentPlayerRefgetPlayerRefComponent()NoNo
clientUseTimelonggetClientUseTime()NoNo
itemInHandItemgetItemInHand()NoNo
targetBlockVector3igetTargetBlock()NoNo
targetEntityEntitygetTargetEntity()NoNo
screenPointVector2fgetScreenPoint()NoNo
mouseButtonMouseButtonEventgetMouseButton()NoNo
  • playerRef — ECS reference to the player entity. Inherited from PlayerEvent.
  • player — The player who triggered the input. Inherited from PlayerEvent.
  • playerRefComponent — The PlayerRef component 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).
  • InteractionModule.doMouseInteraction() (line 407) via eventBus dispatchFor — EventBus dispatch when a player presses or releases a mouse button.
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);
}
});