Class DespawnComponent

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

public class DespawnComponent extends Object implements Component<EntityStore>
A component that allows an entity to be marked for despawn at a certain time in the future
  • Field Details

  • Constructor Details

    • DespawnComponent

      public DespawnComponent()
    • DespawnComponent

      public DespawnComponent(@Nullable Instant timeToDespawnAt)
  • Method Details

    • getComponentType

      public static ComponentType<EntityStore, DespawnComponent> getComponentType()
    • setDespawn

      public void setDespawn(Instant timeToDespawnAt)
    • setDespawnTo

      public void setDespawnTo(@Nonnull Instant from, float additionalSeconds)
    • getDespawn

      @Nullable public Instant getDespawn()
    • despawnInSeconds

      @Nonnull public static DespawnComponent despawnInSeconds(@Nonnull TimeResource time, int seconds)
      Returns a DespawnComponent that will be marked for despawn in an amount of seconds from now.
      Parameters:
      seconds - the amount of seconds in the future we want to be marked for despawn
      Returns:
      a DespawnComponent that will be marked for despawn in an amount of seconds from now.
    • despawnInSeconds

      @Nonnull public static DespawnComponent despawnInSeconds(@Nonnull TimeResource time, float seconds)
      Returns a DespawnComponent that will be marked for despawn in an amount of seconds from now.
      Parameters:
      seconds - the amount of seconds in the future we want to be marked for despawn
      Returns:
      a DespawnComponent that will be marked for despawn in an amount of seconds from now.
    • despawnInMilliseconds

      @Nonnull public static DespawnComponent despawnInMilliseconds(@Nonnull TimeResource time, long milliseconds)
      Returns a DespawnComponent that will be marked for despawn in an amount of milliseconds from now.
      Parameters:
      milliseconds - the amount of milliseconds in the future we want to be marked for despawn
      Returns:
      a DespawnComponent that will be marked for despawn in an amount of milliseconds from now.
    • trySetDespawn

      public static void trySetDespawn(@Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull TimeResource timeResource, @Nonnull Ref<EntityStore> ref, @Nullable DespawnComponent despawnComponent, @Nullable Float newLifetime)
      Helper that sets the lifetime of an entity to the given value if it isn't null. If it is null then the lifetime will be removed.
      Parameters:
      commandBuffer - The command buffer to submit add/remove commands to
      timeResource - The resource to fetch the current game time from
      ref - The reference to the entity being modified
      despawnComponent - The current despawn component if it has one, allows reuse if set
      newLifetime - The new lifetime of the entity in seconds or null.
    • clone

      @Nonnull public Component<EntityStore> clone()
      Specified by:
      clone in interface Component<EntityStore>
      Returns:
      a clone instance of the original component instance.