Class DamageBlockEvent

All Implemented Interfaces:
ICancellableEcsEvent

public class DamageBlockEvent extends CancellableEcsEvent
An event that is called when a block is being damaged in the world.

If cancelled, damage will not be applied to the block.

  • Constructor Details

    • DamageBlockEvent

      public DamageBlockEvent(@Nullable ItemStack itemInHand, @Nonnull org.joml.Vector3i targetBlock, @Nonnull BlockType blockType, float currentDamage, float damage)
      Default Constructor for a DamageBlockEvent instance.
      Parameters:
      itemInHand - The item in the instigating entities hand, if any.
      targetBlock - The position of the block being damaged.
      blockType - The type of block being damaged.
      currentDamage - The current damage on the block.
      damage - The amount of damage to apply to the 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 of the block being damaged.
    • setTargetBlock

      public void setTargetBlock(@Nonnull org.joml.Vector3i targetBlock)
      Called to set the position of the block being damaged.
      Parameters:
      targetBlock - The new target block position.
    • getBlockType

      @Nonnull public BlockType getBlockType()
      Returns:
      the type of block being damaged.
    • getCurrentDamage

      public float getCurrentDamage()
      Returns:
      the current damage on the block.
    • getDamage

      public float getDamage()
      Returns:
      the amount of damage to apply to the block.
    • setDamage

      public void setDamage(float damage)
      Called to set the amount of damage to apply to the block.
      Parameters:
      damage - The new damage amount.