Class PlayerBlockPlaceEvent

java.lang.Object
net.minestom.server.event.Event
net.minestom.server.event.CancellableEvent
net.minestom.server.event.player.PlayerBlockPlaceEvent

public class PlayerBlockPlaceEvent
extends CancellableEvent
Called when a player tries placing a block.
  • Constructor Details

  • Method Details

    • setCustomBlock

      public void setCustomBlock​(@NotNull CustomBlock customBlock)
      Sets both the blockId and customBlockId.
      Parameters:
      customBlock - the custom block to place
    • setCustomBlock

      public void setCustomBlock​(short customBlockId)
      Sets both the blockStateId and customBlockId.
      Parameters:
      customBlockId - the custom block id to place
    • setCustomBlock

      public void setCustomBlock​(@NotNull java.lang.String customBlockId)
      Sets both the blockId and customBlockId.
      Parameters:
      customBlockId - the custom block id to place
    • getCustomBlockId

      public short getCustomBlockId()
      Gets the custom block id.
      Returns:
      the custom block id
    • setCustomBlockId

      public void setCustomBlockId​(short customBlockId)
      Sets the custom block id to place.

      WARNING: this does not change the visual block id, see setBlockStateId(short) or setCustomBlock(short).

      Parameters:
      customBlockId - the custom block id
    • getBlockStateId

      public short getBlockStateId()
      Gets the block state id.
      Returns:
      the block state id
    • setBlockStateId

      public void setBlockStateId​(short blockStateId)
      Changes the visual block id.
      Parameters:
      blockStateId - the new block state id
    • getPlayer

      @NotNull public Player getPlayer()
      Gets the player who is placing the block.
      Returns:
      the player
    • getBlockPosition

      @NotNull public BlockPosition getBlockPosition()
      Gets the block position.
      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