Class BlockPlaceEvent

java.lang.Object
fr.fidorial.event.block.BlockPlaceEvent
All Implemented Interfaces:
Cancellable, Event, PlayerEvent

public final class BlockPlaceEvent extends Object implements PlayerEvent, Cancellable
Fired when a player places a block, before the block is written to the world.

Cancelling the event leaves the world untouched and resyncs the position to the client.

Since:
0.1.0
  • Constructor Details

    • BlockPlaceEvent

      public BlockPlaceEvent(Player player, BlockPos position, int stateId)
      Creates an event.
      Parameters:
      player - the player placing the block
      position - the position of the block, in the player's world
      stateId - the network identifier of the block state about to be placed
      Since:
      0.1.0
  • Method Details

    • player

      public Player player()
      Description copied from interface: PlayerEvent
      Returns the player involved in this event.
      Specified by:
      player in interface PlayerEvent
      Returns:
      the player involved in this event
    • world

      public World world()
      Returns the world the block belongs to, that is the world of the player.
      Returns:
      the world the block belongs to, that is the world of the player
      Since:
      0.1.0
    • position

      public BlockPos position()
      Returns the position of the block.
      Returns:
      the position of the block
      Since:
      0.1.0
    • stateId

      public int stateId()
      Returns the network identifier of the block state about to be placed.
      Returns:
      the network identifier of the block state about to be placed
      Since:
      0.1.0
      See Also:
    • blockData

      public @Nullable BlockData blockData()
      Resolves the block state about to be placed.
      Returns:
      the block state, or null if stateId() is unknown to the block registry
      Since:
      0.1.0
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Returns true if the action this event describes will not happen.
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the action this event describes will not happen
    • setCancelled

      public void setCancelled(boolean cancelled)
      Description copied from interface: Cancellable
      Prevents or re-allows the action this event describes.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancelled - true to prevent it