Class PlaceBlockEvent

All Implemented Interfaces:
ICancellableEcsEvent

public class PlaceBlockEvent extends CancellableEcsEvent
An event that is called when a block is placed in the world.

If cancelled, the block will not be placed.

  • Constructor Details

    • PlaceBlockEvent

      public PlaceBlockEvent(@Nullable ItemStack itemInHand, @Nonnull org.joml.Vector3i targetBlock, @Nonnull RotationTuple rotation)
      Default Constructor for a PlaceBlockEvent instance.
      Parameters:
      itemInHand - The item in the instigating entities hand, if any.
      targetBlock - The position in which the block is being placed.
      rotation - The rotation of the placed block.
  • Method Details

    • getItemInHand

      @Nullable public ItemStack getItemInHand()
      Returns:
      the item in the instigating entities hand, or null if none.
    • getTargetBlock

      @Nonnull public org.joml.Vector3i getTargetBlock()
      Returns:
      the position in which the block is being placed.
    • setTargetBlock

      public void setTargetBlock(@Nonnull org.joml.Vector3i targetBlock)
      Called to set the position in which the block is being placed.
      Parameters:
      targetBlock - The new target block position.
    • getRotation

      @Nonnull public RotationTuple getRotation()
      Returns:
      the rotation of the placed block.
    • setRotation

      public void setRotation(@Nonnull RotationTuple rotation)
      Called to set the rotation of the placed block.
      Parameters:
      rotation - The new rotation.
    • isConsumeItem

      public boolean isConsumeItem()
      Returns:
      whether placing the block should consume it from the placer's inventory.
    • setConsumeItem

      public void setConsumeItem(boolean consumeItem)
      Called to set whether placing the block should consume it from the placer's inventory.
      Parameters:
      consumeItem - false to place the block without consuming it.