Contents
Class WeatherResource
java.lang.Object
com.hypixel.hytale.builtin.weather.resources.WeatherResource
- All Implemented Interfaces:
Resource<EntityStore>, Cloneable
A store resource that handles the weather logic on a per-world basis
- Since:
- 2020/11/09
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloatThe current update delay, in seconds, before sending an update to all clientsstatic final floatThe update rate, in seconds, of sending weather updates to all clients within the worldFields inherited from interface Resource
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()booleancompareAndSwapHour(int currentHour) Compares and swaps the previous hour to the given hour if not identicalbooleanReports 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 viasetForcedWeather(String).intgetEffectiveWeatherIndex(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.it.unimi.dsi.fastutil.ints.Int2IntMapintstatic ResourceType<EntityStore, WeatherResource> intgetWeatherIndexForEnvironment(int environmentId) Fetches the weather index for a specific environmentvoidsetForcedWeather(String forcedWeather) Sets the forced weather index to the given forced weather value
-
Field Details
-
WEATHER_UPDATE_RATE_S
public static final float WEATHER_UPDATE_RATE_SThe update rate, in seconds, of sending weather updates to all clients within the world- See Also:
-
playerUpdateDelay
public float playerUpdateDelayThe current update delay, in seconds, before sending an update to all clients
-
-
Constructor Details
-
WeatherResource
public WeatherResource()Default Constructor for aWeatherResourceinstance
-
-
Method Details
-
getResourceType
- Returns:
- the resource type for the
WeatherResourceresource
-
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_FOUNDwhen the environment has no weather
-
setForcedWeather
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 viasetForcedWeather(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:
trueif the swap was successful,falseotherwise
-
clone
- Specified by:
clonein interfaceResource<EntityStore>- Returns:
- a clone instance of the original resource instance.
-