Contents
Class DespawnComponent
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.DespawnComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
A component that allows an entity to be marked for despawn at a certain time in the future
-
Field Summary
FieldsFields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static DespawnComponentdespawnInMilliseconds(TimeResource time, long milliseconds) Returns aDespawnComponentthat will be marked for despawn in an amount of milliseconds from now.static DespawnComponentdespawnInSeconds(TimeResource time, float seconds) Returns aDespawnComponentthat will be marked for despawn in an amount of seconds from now.static DespawnComponentdespawnInSeconds(TimeResource time, int seconds) Returns aDespawnComponentthat will be marked for despawn in an amount of seconds from now.static ComponentType<EntityStore, DespawnComponent> voidsetDespawn(Instant timeToDespawnAt) voidsetDespawnTo(Instant from, float additionalSeconds) static voidtrySetDespawn(CommandBuffer<EntityStore> commandBuffer, TimeResource timeResource, Ref<EntityStore> ref, DespawnComponent despawnComponent, Float newLifetime) Helper that sets the lifetime of an entity to the given value if it isn't null.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
CODEC
-
-
Constructor Details
-
DespawnComponent
public DespawnComponent() -
DespawnComponent
-
-
Method Details
-
getComponentType
-
setDespawn
-
setDespawnTo
-
getDespawn
-
despawnInSeconds
Returns aDespawnComponentthat 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
DespawnComponentthat will be marked for despawn in an amount of seconds from now.
-
despawnInSeconds
Returns aDespawnComponentthat 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
DespawnComponentthat will be marked for despawn in an amount of seconds from now.
-
despawnInMilliseconds
@Nonnull public static DespawnComponent despawnInMilliseconds(@Nonnull TimeResource time, long milliseconds) Returns aDespawnComponentthat 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
DespawnComponentthat 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 totimeResource- The resource to fetch the current game time fromref- The reference to the entity being modifieddespawnComponent- The current despawn component if it has one, allows reuse if setnewLifetime- The new lifetime of the entity in seconds or null.
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-