Class BlockDamageData

java.lang.Object
me.deecaad.weaponmechanics.weapon.damage.BlockDamageData

public final class BlockDamageData extends Object
Utility class that stores all block damage on the server.
  • Field Details

    • MAX_BLOCK_CRACK

      public static final int MAX_BLOCK_CRACK
      See Also:
    • MASK

      public static final org.bukkit.Material MASK
    • EPSILON

      public static final double EPSILON
      See Also:
  • Method Details

    • damage

      public static BlockDamageData.DamageData damage(@NotNull org.bukkit.block.Block block, double damage, boolean isBreak, boolean isRegenerate)
    • damage

      public static BlockDamageData.DamageData damage(@NotNull org.bukkit.block.Block block, double damage, boolean isBreak, boolean isRegenerate, org.bukkit.Material mask)
      Damages the given block for the given percentage of damage. Note that the returned value should be checked to schedule a block regeneration task.
      Parameters:
      block - The non-null block to damage.
      damage - The percentage of damage [0.0, 1.0].
      isBreak - Whether the block will break or not.
      isRegenerate - false is will cause inventories to drop and block updates.
      mask - The block to replace... Usually MASK.
      Returns:
      true if the block was broken.
    • getBlockDamage

      @Nullable public static BlockDamageData.DamageData getBlockDamage(@NotNull org.bukkit.block.Block block)
    • isBroken

      public static boolean isBroken(@NotNull org.bukkit.block.Block block)
      Returns true if the given block is broken by WeaponMechanics. Note that is only returns true if the block is scheduled to regenerate. When regeneration is turned off, this method will return false for any block.
      Parameters:
      block - The non-null block position to test.
      Returns:
      true if the block is broken and going to regenerate.
    • regenerate

      public static void regenerate(@NotNull org.bukkit.block.Block block)
      Regenerates the given block by resetting it to the BlockState it had before being destroyed. This also resets the block's durability, and removes it from the damage map.
      Parameters:
      block - The non-null block to regenerate
    • regenerate

      public static void regenerate(@NotNull org.bukkit.Chunk chunk)
      Regenerates all blocks in the given chunk. Note that the given chunk must have a world associated with it (such that Chunk.getWorld()) will not return null.

      After regeneration, the chunk will be removed from the cache.

      Parameters:
      chunk - The non-null chunk to regenerate all blocks.
      See Also:
    • regenerate

      public static void regenerate(@NotNull org.bukkit.World world)
      Regenerates all blocks in the given world.

      After regeneration, all chunks from the world will be removed from the cache.

      Parameters:
      world - The non-null world to regenerate all blocks.
      See Also:
    • regenerateAll

      public static void regenerateAll()