Class PlayerBlockInteractEvent

java.lang.Object
net.minestom.server.event.player.PlayerBlockInteractEvent
All Implemented Interfaces:
Event, BlockEvent, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent

public class PlayerBlockInteractEvent extends Object implements PlayerInstanceEvent, BlockEvent, CancellableEvent
Called when a player interacts with a block (right-click). This is also called when a block is placed.
  • Constructor Details

    • PlayerBlockInteractEvent

      public PlayerBlockInteractEvent(@NotNull @NotNull Player player, @NotNull Player.Hand hand, @NotNull @NotNull Block block, @NotNull @NotNull Point blockPosition, @NotNull @NotNull Point cursorPosition, @NotNull @NotNull BlockFace blockFace)
  • Method Details

    • isBlockingItemUse

      public boolean isBlockingItemUse()
      Gets if the event should block the item use.
      Returns:
      true if the item use is blocked, false otherwise
    • setBlockingItemUse

      public void setBlockingItemUse(boolean blocks)
      Sets the blocking item use state of this event Note: If this is true, then no PlayerUseItemOnBlockEvent will be fired.
      Parameters:
      blocks - - true to block item interactions, false to not block
    • getBlock

      @NotNull public @NotNull Block getBlock()
      Specified by:
      getBlock in interface BlockEvent
    • getBlockPosition

      @NotNull public @NotNull Point getBlockPosition()
      Gets the position of the interacted block.
      Returns:
      the block position
    • getCursorPosition

      @NotNull public @NotNull Point getCursorPosition()
      Gets the cursor position of the interacted block
      Returns:
      the cursor position of the interaction
    • getHand

      @NotNull public Player.Hand getHand()
      Gets the hand used for the interaction.
      Returns:
      the hand used
    • getBlockFace

      @NotNull public @NotNull BlockFace getBlockFace()
      Gets the block face.
      Returns:
      the block face
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: CancellableEvent
      Gets if the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: CancellableEvent
      Marks the Event as cancelled or not.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise
    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player