Class DeathComponent

java.lang.Object
com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class DeathComponent extends Object implements Component<EntityStore>
A component that is added to entities when they have died.

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 Details

  • Method Details

    • getComponentType

      public static ComponentType<EntityStore, DeathComponent> getComponentType()
    • getDeathCause

      @Nullable public DamageCause 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

      @Nullable public Message getDeathMessage()
    • setDeathMessage

      public void setDeathMessage(@Nullable Message deathMessage)
    • isShowDeathMenu

      public boolean isShowDeathMenu()
    • setShowDeathMenu

      public void setShowDeathMenu(boolean showDeathMenu)
    • getItemsLostOnDeath

      public ItemStack[] getItemsLostOnDeath()
    • setItemsLostOnDeath

      public void setItemsLostOnDeath(List<ItemStack> itemsLostOnDeath)
    • 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

      @Nullable public Damage 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 RefChangeSystem expect this to have a value.

    • getItemsLossMode

      public DeathConfig.ItemsLossMode 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

      public void setItemsLossMode(DeathConfig.ItemsLossMode itemsLossMode)
      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

      invalid reference
      DeathSystems.DropDeathItems
      and DeathSystems.DropPlayerDeathItems.
      Parameters:
      itemsLossMode - Whether the entity should drop items on death based on the loss mode.
    • getDeathItemLoss

      public DeathItemLoss 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

      @Nullable public InteractionChain 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

      public void setInteractionChain(@Nullable InteractionChain interactionChain)
      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

      @Nonnull public Component<EntityStore> clone()
      Specified by:
      clone in interface Component<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 a RespawnEvent that a listener can cancel.
      Returns:
      the respawn in flight, already complete when the entity is alive, or null when a listener cancelled the event and the entity stays dead.