Class PlayerBlockPlaceEvent

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

public class PlayerBlockPlaceEvent extends Object implements PlayerInstanceEvent, BlockEvent, CancellableEvent
Called when a player tries placing a block.
  • Constructor Details

    • PlayerBlockPlaceEvent

      public PlayerBlockPlaceEvent(@NotNull @NotNull Player player, @NotNull @NotNull Block block, @NotNull @NotNull BlockFace blockFace, @NotNull @NotNull BlockVec blockPosition, @NotNull Player.Hand hand)
  • Method Details

    • getBlock

      @NotNull public @NotNull Block getBlock()
      Gets the block which will be placed.
      Specified by:
      getBlock in interface BlockEvent
      Returns:
      the block to place
    • setBlock

      public void setBlock(@NotNull @NotNull Block block)
      Changes the block to be placed.
      Parameters:
      block - the new block
    • getBlockFace

      @NotNull public @NotNull BlockFace getBlockFace()
    • getBlockPosition

      @NotNull public @NotNull BlockVec getBlockPosition()
      Gets the block position.
      Specified by:
      getBlockPosition in interface BlockEvent
      Returns:
      the block position
    • getHand

      @NotNull public Player.Hand getHand()
      Gets the hand with which the player is trying to place.
      Returns:
      the hand used
    • consumeBlock

      public void consumeBlock(boolean consumeBlock)
      Should the block be consumed if not cancelled.
      Parameters:
      consumeBlock - true if the block should be consumer (-1 amount), false otherwise
    • doesConsumeBlock

      public boolean doesConsumeBlock()
      Should the block be consumed if not cancelled.
      Returns:
      true if the block will be consumed, false otherwise
    • setDoBlockUpdates

      public void setDoBlockUpdates(boolean doBlockUpdates)
      Should the place trigger updates (on self and neighbors)
      Parameters:
      doBlockUpdates - true if this placement should do block updates
    • shouldDoBlockUpdates

      public boolean shouldDoBlockUpdates()
      Should the place trigger updates (on self and neighbors)
      Returns:
      true if this placement should do block updates
    • 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