- Description
- Field Summary
- Method Summary
- Field Details
- Method Details
- getComponentType()
- getDeathCause()
- getDeathMessage()
- setDeathMessage(Message)
- isShowDeathMenu()
- setShowDeathMenu(boolean)
- getItemsLostOnDeath()
- setItemsLostOnDeath(List)
- getItemsAmountLossPercentage()
- setItemsAmountLossPercentage(double)
- getItemsDurabilityLossPercentage()
- setItemsDurabilityLossPercentage(double)
- displayDataOnDeathScreen()
- setDisplayDataOnDeathScreen(boolean)
- getDeathInfo()
- getItemsLossMode()
- setItemsLossMode(DeathConfig.ItemsLossMode)
- getDeathItemLoss()
- getInteractionChain()
- setInteractionChain(InteractionChain)
- clone()
- tryAddComponent(CommandBuffer, Ref, Damage)
- tryAddComponent(Store, Ref, Damage)
- respawn(ComponentAccessor, Ref)
Class DeathComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
A dead entity may not be removed instantly and may continue
ticking for a while after their dead (e.g. delay before the
corpse is removed if a DeferredCorpseRemoval component
is present, or if a death interaction is running).
Generally if you wish to handle an entity dying you should
use a RefChangeSystem
watching for this component to be added.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<DeathComponent> static final HytaleLoggerFields inherited from interface Component
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanstatic ComponentType<EntityStore, DeathComponent> Returns the cause of the damage that killed this entity.Returns the damage info of the damage event that killed this entity.Return a view of the consequences of this death at this stage.The currently running interaction chain for handling this entity's death.doubledoubleWhether this entity should drop items on death based on the loss mode.booleanstatic CompletableFuture<Void> respawn(ComponentAccessor<EntityStore> componentAccessor, Ref<EntityStore> ref) Respawns a dead entity, firing aRespawnEventthat a listener can cancel.voidsetDeathMessage(Message deathMessage) voidsetDisplayDataOnDeathScreen(boolean displayDataOnDeathScreen) voidsetInteractionChain(InteractionChain interactionChain) Changes the currently running interaction chain that is handling this entity's death.voidsetItemsAmountLossPercentage(double itemsAmountLossPercentage) voidsetItemsDurabilityLossPercentage(double itemsDurabilityLossPercentage) voidsetItemsLossMode(DeathConfig.ItemsLossMode itemsLossMode) Changes whether this entity should drop items on death based on the loss mode.voidsetItemsLostOnDeath(List<ItemStack> itemsLostOnDeath) voidsetShowDeathMenu(boolean showDeathMenu) static voidtryAddComponent(CommandBuffer<EntityStore> commandBuffer, Ref<EntityStore> ref, Damage damage) Attempts to add the death component to the entity.static voidtryAddComponent(Store<EntityStore> store, Ref<EntityStore> ref, Damage damage) Attempts to add the death component to the entity.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
LOGGER
-
CODEC
-
-
Method Details
-
getComponentType
-
getDeathCause
Returns the cause of the damage that killed this entity.This should be the same result as doing
getDeathInfo().getCause()however the death info is not serialized whilst this field is meaning it should always have value.- Returns:
- The cause of death.
-
getDeathMessage
-
setDeathMessage
-
isShowDeathMenu
public boolean isShowDeathMenu() -
setShowDeathMenu
public void setShowDeathMenu(boolean showDeathMenu) -
getItemsLostOnDeath
-
setItemsLostOnDeath
-
getItemsAmountLossPercentage
public double getItemsAmountLossPercentage() -
setItemsAmountLossPercentage
public void setItemsAmountLossPercentage(double itemsAmountLossPercentage) -
getItemsDurabilityLossPercentage
public double getItemsDurabilityLossPercentage() -
setItemsDurabilityLossPercentage
public void setItemsDurabilityLossPercentage(double itemsDurabilityLossPercentage) -
displayDataOnDeathScreen
public boolean displayDataOnDeathScreen() -
setDisplayDataOnDeathScreen
public void setDisplayDataOnDeathScreen(boolean displayDataOnDeathScreen) -
getDeathInfo
Returns the damage info of the damage event that killed this entity.Can be null when a dead entity is loaded from disk losing the damage info.
Should never be added to an entity whilst null, only loaded as systems using
RefChangeSystemexpect this to have a value. -
getItemsLossMode
Whether this entity should drop items on death based on the loss mode.- Returns:
- Whether this entity should drop items on death based on the loss mode.
-
setItemsLossMode
Changes whether this entity should drop items on death based on the loss mode.Should be set before systems that process this value are called.
Currently these are
andinvalid reference
DeathSystems.DropDeathItemsDeathSystems.DropPlayerDeathItems.- Parameters:
itemsLossMode- Whether the entity should drop items on death based on the loss mode.
-
getDeathItemLoss
Return a view of the consequences of this death at this stage. Useful for post-mortem review, such as the death panel UI.- Returns:
- The state of the items lost on death
-
getInteractionChain
The currently running interaction chain for handling this entity's death.Optional, the chain doesn't have be used.
- Returns:
- The running interaction chain for death or null.
-
setInteractionChain
Changes the currently running interaction chain that is handling this entity's death.Should only be used by
DeathSystems.RunDeathInteractions- Parameters:
interactionChain- The running interaction chain.
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-
tryAddComponent
public static void tryAddComponent(@Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull Ref<EntityStore> ref, @Nonnull Damage damage) Attempts to add the death component to the entity.If the entity already has the component by the time the command buffer is consumed then this will do nothing and leave the first death component.
-
tryAddComponent
public static void tryAddComponent(@Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> ref, @Nonnull Damage damage) Attempts to add the death component to the entity.If the entity already has the component then this will do nothing and leave the first death component.
-
respawn
@Nullable public static CompletableFuture<Void> respawn(@Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull Ref<EntityStore> ref) Respawns a dead entity, firing aRespawnEventthat a listener can cancel.- Returns:
- the respawn in flight, already complete when the entity is alive, or
nullwhen a listener cancelled the event and the entity stays dead.
-