Class DamageBlockEvent
java.lang.Object
fr.hytale.loader.event.types.ecs.DamageBlockEvent
- All Implemented Interfaces:
com.hypixel.hytale.event.IBaseEvent<Void>, com.hypixel.hytale.event.IEvent<Void>
Called when a block takes damage.
This event is fired when a block is being damaged but not yet broken. This allows mods to track block damage progression or modify damage values. The event can be cancelled to prevent damage.
- Since:
- 1.0.1
- Version:
- 1.0.4
- Author:
- HytaleLoader
-
Constructor Summary
ConstructorsConstructorDescriptionDamageBlockEvent(com.hypixel.hytale.server.core.event.events.ecs.DamageBlockEvent originalEvent, Player player) Constructs a new DamageBlockEvent. -
Method Summary
Modifier and TypeMethodDescriptioncom.hypixel.hytale.server.core.asset.type.blocktype.config.BlockTypeGets the type of block being damaged.floatGets the current accumulated damage on the block.floatGets the damage being applied in this event.com.hypixel.hytale.server.core.inventory.ItemStackGets the item being used to damage the block.Gets the player who damaged the block.com.hypixel.hytale.math.vector.Vector3iGets the position of the block being damaged.booleanChecks if this event has been cancelled.voidsetCancelled(boolean cancelled) Sets the cancelled state of this event.voidsetDamage(float damage) Sets the damage to be applied.voidsetTargetBlock(com.hypixel.hytale.math.vector.Vector3i targetBlock) Sets the target block position.
-
Constructor Details
-
DamageBlockEvent
public DamageBlockEvent(com.hypixel.hytale.server.core.event.events.ecs.DamageBlockEvent originalEvent, Player player) Constructs a new DamageBlockEvent.- Parameters:
originalEvent- the original Hytale ECS eventplayer- the player who damaged the block, or null if not a player
-
-
Method Details
-
getItemInHand
public com.hypixel.hytale.server.core.inventory.ItemStack getItemInHand()Gets the item being used to damage the block.- Returns:
- the item in hand, or null if no item
-
getTargetBlock
public com.hypixel.hytale.math.vector.Vector3i getTargetBlock()Gets the position of the block being damaged.- Returns:
- the block position
-
setTargetBlock
public void setTargetBlock(com.hypixel.hytale.math.vector.Vector3i targetBlock) Sets the target block position.- Parameters:
targetBlock- the new target position
-
getBlockType
public com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType getBlockType()Gets the type of block being damaged.- Returns:
- the block type
-
getCurrentDamage
public float getCurrentDamage()Gets the current accumulated damage on the block.- Returns:
- the current damage value
-
getDamage
public float getDamage()Gets the damage being applied in this event.- Returns:
- the damage amount
-
setDamage
public void setDamage(float damage) Sets the damage to be applied.- Parameters:
damage- the new damage amount
-
isCancelled
public boolean isCancelled()Checks if this event has been cancelled.- Returns:
- true if cancelled, false otherwise
-
setCancelled
public void setCancelled(boolean cancelled) Sets the cancelled state of this event.- Parameters:
cancelled- true to cancel, false to allow
-
getPlayer
Gets the player who damaged the block.- Returns:
- the player, or null if the block was not damaged by a player
-