Contents
Class Damage
java.lang.Object
com.hypixel.hytale.component.system.EcsEvent
com.hypixel.hytale.component.system.CancellableEcsEvent
com.hypixel.hytale.server.core.modules.entity.damage.Damage
- All Implemented Interfaces:
ICancellableEcsEvent, IMetaStore<Damage>
A wrapper around a damage event.
Contains the amount of damage, the source of the damage and any extra information about the damage needed.
If cancelled, no damage will be applied.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordCamera Effectstatic classA damage source that represents a command senderstatic classstatic classA damage source that contains an affiliated entitystatic classA damage source that is caused by the environment, such as block explosions.static classParticlesstatic classAn entity damage source that also includes the affiliated projectile entity.static classSound Effectstatic interfaceInformation about the source of a damage event.Nested classes/interfaces inherited from interface IMetaStore
IMetaStore.MetaEntryConsumer -
Field Summary
FieldsModifier and TypeFieldDescriptionA meta key that indicates whether the damage was blocked (e.g. shield/block)static final MetaKey<Damage.CameraEffect> A meta key that holds the camera effects to be applied after processing the affiliated damage entryThis has been added to display particles for all players (including damage source) in case damage can be predicted (ie projectiles at the moment)A meta key that holds the death icon string to be used upon death from this damage entryA meta key that holds the hit angle of the damage eventstatic final MetaKey<org.joml.Vector4d> A meta key that holds the hit location of the damage eventstatic final MetaKey<Damage.Particles> A meta key that holds the particles to be applied after processing the affiliated damage entrystatic final MetaKey<Damage.SoundEffect> A meta key that holds the impact sound effect to be played upon processing the affiliated damage entrystatic final MetaKey<InteractionType> The interaction type of the chain that dealt this damage (e.g.static final MetaKey<KnockbackComponent> A meta key that holds the knockback component for the target of this damage entrystatic final MetaRegistry<Damage> The meta registry for registering damage-specific metaobjectsstatic final Damage.SourceA reusable null source for damage entriesstatic final MetaKey<Damage.SoundEffect> A meta key that holds the player impact sound effect to be played upon player impactA meta key that holds the stamina drain multiplier for this damage entry -
Constructor Summary
ConstructorsConstructorDescriptionDamage(Damage.Source source, int damageCauseIndex, float amount) Default Constructor for aDamageinstanceDamage(Damage.Source source, DamageCause damageCause, float amount) Default Constructor for aDamageinstance -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the current amount of damage to be dealtgetCause()Deprecated.intgetDeathMessage(Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) Builds aMessagecontaining a death message relevant to this damage event.floatReturns the initial amount of damage this event was created with.Returns the meta store object.Returns the source of this damage.voidsetAmount(float amount) Changes the amount of damage that will be dealt.voidsetDamageCauseIndex(int damageCauseIndex) Called to set the index of the cause of the damage.voidsetSource(Damage.Source source) Changes the source of this damage event.Methods inherited from class CancellableEcsEvent
isCancelled, setCancelledMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IMetaStore
consumeMetaStoreDirty, forEachMetaObject, getIfPresentMetaObject, getMetaObject, hasMetaObject, markMetaStoreDirty, putMetaObject, removeMetaObject, removeSerializedMetaObject
-
Field Details
-
META_REGISTRY
The meta registry for registering damage-specific metaobjects -
HIT_LOCATION
A meta key that holds the hit location of the damage event -
HIT_ANGLE
-
IMPACT_PARTICLES
A meta key that holds the particles to be applied after processing the affiliated damage entry -
IMPACT_SOUND_EFFECT
A meta key that holds the impact sound effect to be played upon processing the affiliated damage entry -
PLAYER_IMPACT_SOUND_EFFECT
A meta key that holds the player impact sound effect to be played upon player impact -
CAMERA_EFFECT
A meta key that holds the camera effects to be applied after processing the affiliated damage entry -
DEATH_ICON
-
BLOCKED
-
STAMINA_DRAIN_MULTIPLIER
-
CAN_BE_PREDICTED
-
INTERACTION_TYPE
The interaction type of the chain that dealt this damage (e.g. Primary for a basic weapon swing). Absent for damage that did not come from an interaction chain. -
KNOCKBACK_COMPONENT
A meta key that holds the knockback component for the target of this damage entry -
NULL_SOURCE
A reusable null source for damage entries
-
-
Constructor Details
-
Damage
Default Constructor for aDamageinstance- Parameters:
source- The source of the damagedamageCause- The cause of the damageamount- The amount of damage applied
-
Damage
Default Constructor for aDamageinstance- Parameters:
source- The source of the damagedamageCauseIndex- The index for the damage cause asset that was the cause of the damageamount- The amount of damage applied
-
-
Method Details
-
getDamageCauseIndex
public int getDamageCauseIndex()- Returns:
- the index of the cause of the damage.
-
setDamageCauseIndex
public void setDamageCauseIndex(int damageCauseIndex) Called to set the index of the cause of the damage.- Parameters:
damageCauseIndex- The new damage cause index.
-
getCause
Deprecated.Returns the cause of the damage.- Returns:
- The cause of the damage event.
-
getSource
Returns the source of this damage.- Returns:
- The source of the damage event.
-
setSource
Changes the source of this damage event.- Parameters:
source- The new source of the event.
-
getAmount
public float getAmount()Returns the current amount of damage to be dealt- Returns:
- The damage to be dealt.
-
setAmount
public void setAmount(float amount) Changes the amount of damage that will be dealt.- Parameters:
amount- The new damage to be dealt.
-
getInitialAmount
public float getInitialAmount()Returns the initial amount of damage this event was created with.This value cannot be changed by any damage system.
- Returns:
- The initial amount of damage that was attempted to be dealt.
-
getDeathMessage
@Nonnull public Message getDeathMessage(@Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Builds aMessagecontaining a death message relevant to this damage event.The death message is decided by the
Damage.Sourceusing information from this class.- Parameters:
targetRef- The entity reference of the target entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- The built death message.
-
getMetaStore
Description copied from interface:IMetaStoreReturns the meta store object.- Specified by:
getMetaStorein interfaceIMetaStore<Damage>- Returns:
- MetaStore object
-