Class BlockCanBuildEvent


public class BlockCanBuildEvent extends BlockEvent
Called when we try to place a block, to see if we can build it here or not.

Note:

  • The Block returned by getBlock() is the block we are trying to place on, not the block we are trying to place.
  • If you want to figure out what is being placed, use getMaterial() instead.
  • Field Details

    • blockData

      protected BlockData blockData
    • buildable

      protected boolean buildable
  • Constructor Details

    • BlockCanBuildEvent

      @Deprecated(since="1.13.2", forRemoval=true) @Internal public BlockCanBuildEvent(@NotNull @NotNull Block block, @NotNull @NotNull BlockData type, boolean canBuild)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • BlockCanBuildEvent

      @Deprecated(forRemoval=true) @Internal public BlockCanBuildEvent(@NotNull @NotNull Block block, @Nullable @Nullable Player player, @NotNull @NotNull BlockData type, boolean canBuild)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • BlockCanBuildEvent

      @Internal public BlockCanBuildEvent(@NotNull @NotNull Block block, @Nullable @Nullable Player player, @NotNull @NotNull BlockData type, boolean canBuild, @NotNull EquipmentSlot hand)
  • Method Details

    • getPlayer

      @Nullable public @Nullable Player getPlayer()
      Gets the player who placed the block involved in this event.
      May be null for legacy calls of the event.
      Returns:
      The Player who placed the block involved in this event
    • getMaterial

      @NotNull public @NotNull Material getMaterial()
      Gets the Material that we are trying to place.
      Returns:
      The Material that we are trying to place
    • getBlockData

      @NotNull public @NotNull BlockData getBlockData()
      Gets the BlockData that we are trying to place.
      Returns:
      The BlockData that we are trying to place
    • getHand

      @NotNull public EquipmentSlot getHand()
      Gets the hand the player will use to place the block
      Returns:
      the EquipmentSlot representing the players hand.
    • isBuildable

      public boolean isBuildable()
      Gets whether the block can be built here.

      By default, returns Minecraft's answer on whether the block can be built here or not.

      Returns:
      boolean whether the block can be built
    • setBuildable

      public void setBuildable(boolean cancel)
      Sets whether the block can be built here or not.
      Parameters:
      cancel - true if you want to allow the block to be built here despite Minecraft's default behaviour
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()