Class BlockDamageData
java.lang.Object
me.deecaad.weaponmechanics.weapon.damage.BlockDamageData
Utility class that stores all block damage on the server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTheChunkclass does not provide a hashing method, so we are stuck wrapping the chunk in order to use aHashMapstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final org.bukkit.Materialstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockDamageData.DamageDatadamage(org.bukkit.block.Block block, double damage, boolean isBreak, boolean isRegenerate) Shorthand fordamage(Block, double, boolean, boolean, Material)static BlockDamageData.DamageDatadamage(org.bukkit.block.Block block, double damage, boolean isBreak, boolean isRegenerate, org.bukkit.Material mask) Damages the givenblockfor the given percentage ofdamage.static BlockDamageData.DamageDatagetBlockDamage(org.bukkit.block.Block block) static booleanisBroken(org.bukkit.block.Block block) Returns true if the given block is broken by WeaponMechanics.static voidregenerate(org.bukkit.block.Block block) Regenerates the given block by resetting it to theBlockStateit had before being destroyed.static voidregenerate(org.bukkit.Chunk chunk) Regenerates all blocks in the given chunk.static voidregenerate(org.bukkit.World world) Regenerates all blocks in the given world.static void
-
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) Shorthand fordamage(Block, double, boolean, boolean, Material) -
damage
public static BlockDamageData.DamageData damage(@NotNull org.bukkit.block.Block block, double damage, boolean isBreak, boolean isRegenerate, org.bukkit.Material mask) Damages the givenblockfor the given percentage ofdamage. 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... UsuallyMASK.- Returns:
trueif 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 theBlockStateit 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 thatChunk.getWorld()) will not returnnull.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()
-