Class WeatherResource

java.lang.Object
com.hypixel.hytale.builtin.weather.resources.WeatherResource
All Implemented Interfaces:
Resource<EntityStore>, Cloneable

public class WeatherResource extends Object implements Resource<EntityStore>
A store resource that handles the weather logic on a per-world basis
Since:
2020/11/09
  • Field Details

    • WEATHER_UPDATE_RATE_S

      public static final float WEATHER_UPDATE_RATE_S
      The update rate, in seconds, of sending weather updates to all clients within the world
      See Also:
    • playerUpdateDelay

      public float playerUpdateDelay
      The current update delay, in seconds, before sending an update to all clients
  • Constructor Details

    • WeatherResource

      public WeatherResource()
      Default Constructor for a WeatherResource instance
  • Method Details

    • getResourceType

      public static ResourceType<EntityStore, WeatherResource> getResourceType()
      Returns:
      the resource type for the WeatherResource resource
    • getEnvironmentWeather

      @Nonnull public it.unimi.dsi.fastutil.ints.Int2IntMap getEnvironmentWeather()
      Returns:
      the environment weather, mapped by environment ID
    • getWeatherIndexForEnvironment

      public int getWeatherIndexForEnvironment(int environmentId)
      Fetches the weather index for a specific environment
      Parameters:
      environmentId - Given ID of the environment
      Returns:
      the weather index for the given environment
    • getForcedWeatherIndex

      public int getForcedWeatherIndex()
      Returns:
      the forced weather index, if configured
    • getEffectiveWeatherIndex

      public int getEffectiveWeatherIndex(int environmentId)
      Resolves the weather that applies at a position, ignoring any per-player override: the world's forced weather, otherwise the weather of the environment at that position.
      Parameters:
      environmentId - Given ID of the environment
      Returns:
      the weather index, or AssetMapWithIndexes.NOT_FOUND when the environment has no weather
    • setForcedWeather

      public void setForcedWeather(@Nullable String forcedWeather)
      Sets the forced weather index to the given forced weather value
      Parameters:
      forcedWeather - The asset ID of the weather to force
    • consumeForcedWeatherChange

      public boolean consumeForcedWeatherChange()
      Reports whether the forced weather has changed since the last call to this method and consumes the result so that subsequent calls return false until the forced weather is updated via setForcedWeather(String). When this method returns true it is an indication that the weather has either been set from default weather to a forced weather type, reset from a forced weather type to default, or set from one forced weather type to another.
      Returns:
      True if the forced weather state changed since last calling this method.
    • compareAndSwapHour

      public boolean compareAndSwapHour(int currentHour)
      Compares and swaps the previous hour to the given hour if not identical
      Parameters:
      currentHour - The hour value to set
      Returns:
      true if the swap was successful, false otherwise
    • clone

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