Class TimeResource

java.lang.Object
com.hypixel.hytale.server.core.modules.time.TimeResource
All Implemented Interfaces:
Resource<EntityStore>, Cloneable

public class TimeResource extends Object implements Resource<EntityStore>
An entity store resource that holds the current time, regardless of world time.

Useful for fetching the lifetime of a world regardless of the worlds day time cycle.

  • Field Details

  • Constructor Details

    • TimeResource

      public TimeResource()
      Empty Constructor for a TimeResource instance.

      Used by the codec to instantiate TimeResource instances.

    • TimeResource

      public TimeResource(@Nonnull Instant now)
      Default Constructor for a TimeResource instance.
      Parameters:
      now - The current time instant to set.
  • Method Details

    • getResourceType

      @Nonnull public static ResourceType<EntityStore, TimeResource> getResourceType()
      Returns:
      the TimeResource resource type.
    • getTimeDilationModifier

      public float getTimeDilationModifier()
      Returns:
      The time dilation modifier for this resource.
    • setTimeDilationModifier

      public void setTimeDilationModifier(float timeDilationModifier)
      Called to set the time dilation modifier for this resource.
      Parameters:
      timeDilationModifier - The time dilation modifier to set.
    • getNow

      @Nonnull public Instant getNow()
      Returns:
      the current time instant of this resource.
    • setNow

      public void setNow(@Nonnull Instant now)
      Called to set the current time instant of this resource.
      Parameters:
      now - The time instant to set.
    • add

      public void add(@Nonnull Duration duration)
      Called to add the given duration to the current time instant.
      Parameters:
      duration - The duration to increment the time instant by.
    • add

      public void add(long time, @Nonnull TemporalUnit unit)
      Called to add the given time of the given unit to the current time instant.
      Parameters:
      time - The amount of time to increment the time instant by.
      unit - The time unit of the time amount.
    • clone

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

    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object