Skip to content

Damage

Package: com.hypixel.hytale.server.core.modules.entity.damage

public class Damage extends CancellableEcsEvent implements IMetaStore<Damage>

Represents a damage event dispatched through the ECS event system. Damage carries the amount, cause, and source of damage dealt to an entity, and supports cancellation. It implements IMetaStore to allow attaching arbitrary metadata (hit location, particles, sound effects, camera effects, knockback, etc.) via MetaKey entries on its META_REGISTRY.

KeyTypeDescription
HIT_LOCATIONVector4dWorld-space coordinates of the hit point.
HIT_ANGLEFloatAngle of the hit for directional indicators.
IMPACT_PARTICLESDamage.ParticlesParticle configuration spawned on impact.
IMPACT_SOUND_EFFECTDamage.SoundEffectSound effect played on impact for all nearby players.
PLAYER_IMPACT_SOUND_EFFECTDamage.SoundEffectSound effect played only for the damaged player.
CAMERA_EFFECTDamage.CameraEffectCamera shake or effect triggered on hit.
DEATH_ICONStringIcon identifier displayed in the kill feed on death.
BLOCKEDBooleanWhether the damage was blocked (defaults to false).
STAMINA_DRAIN_MULTIPLIERFloatMultiplier applied to stamina drain when blocking.
CAN_BE_PREDICTEDBooleanWhether the client can predict this damage (defaults to false).
KNOCKBACK_COMPONENTKnockbackComponentKnockback data attached to this damage event.
FieldTypeDescription
META_REGISTRYMetaRegistry<Damage>Registry for all damage metadata keys.
NULL_SOURCEDamage.SourceA no-op source used for environment or sourceless damage.
public Damage(@Nonnull Damage.Source source, @Nonnull DamageCause damageCause, float amount)

Creates a damage event from a source, a DamageCause asset, and an amount. The damage cause is resolved to an index via DamageCause.getAssetMap().

public Damage(@Nonnull Damage.Source source, int damageCauseIndex, float amount)

Creates a damage event from a source, a raw damage cause index, and an amount.

public int getDamageCauseIndex()

Returns the integer index of the damage cause in the asset map.

public void setDamageCauseIndex(int damageCauseIndex)

Overrides the damage cause index.

@Deprecated
@Nullable
public DamageCause getCause()

Returns the DamageCause asset for this damage event, or null if the index is invalid. Deprecated in favor of index-based lookups.

@Nonnull
public Damage.Source getSource()

Returns the Damage.Source that caused this damage.

public void setSource(@Nonnull Damage.Source source)

Replaces the damage source.

public float getAmount()

Returns the current damage amount. This value may be modified by filter systems before application.

public void setAmount(float amount)

Sets the damage amount. Used by damage reduction systems to modify the final value.

public float getInitialAmount()

Returns the original damage amount as set at construction time, before any modifications.

@Nonnull
public Message getDeathMessage(@Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor)

Delegates to the source’s getDeathMessage() to produce a localized death message for the kill feed.

@Nonnull
@Override
public IMetaStoreImpl<Damage> getMetaStore()

Returns the DynamicMetaStore backing this damage event’s metadata.

Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.