WeatherResource class

Пакет: com.hypixel.hytale.builtin.weather.resources

Файл: com/hypixel/hytale/builtin/weather/resources/WeatherResource.java

implements: Resource<EntityStore>

Поля (1)

МодификаторыТипИмя
final float WEATHER_UPDATE_RATE_S

Методы (8)

МодификаторыВозвратСигнатура
public boolean compareAndSwapHourboolean compareAndSwapHour(int var1)
public boolean consumeForcedWeatherChangeboolean consumeForcedWeatherChange()
public int getForcedWeatherIndexint getForcedWeatherIndex()
static ResourceType<EntityStore, WeatherResource> getResourceTypeResourceType<EntityStore, WeatherResource> getResourceType()
public int getWeatherIndexForEnvironmentint getWeatherIndexForEnvironment(int var1)
if if(this.previousForcedWeatherIndex == this.forcedWeatherIndex)
if if(var1 == this.previousHour)
public void setForcedWeathervoid setForcedWeather(@Nullable String var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.weather.resources;

class="kw">import com.hypixel.hytale.builtin.weather.WeatherPlugin;
class="kw">import com.hypixel.hytale.component.Resource;
class="kw">import com.hypixel.hytale.component.ResourceType;
class="kw">import com.hypixel.hytale.server.core.asset.type.weather.config.Weather;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.ints.Int2IntMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class WeatherResource class="kw">implements Resource<EntityStore> {
   class="kw">public class="kw">static class="kw">final float WEATHER_UPDATE_RATE_S = 1.0F;
   class="kw">private int forcedWeatherIndex;
   class="kw">private int previousForcedWeatherIndex;
   @Nonnull
   class="kw">private class="kw">final Int2IntMap environmentWeather = new Int2IntOpenHashMap();
   class="kw">private int previousHour = -1;
   class="kw">public float playerUpdateDelay;

   class="kw">public class="kw">static ResourceType<EntityStore, WeatherResource> getResourceType() {
      class="kw">return WeatherPlugin.get().getWeatherResourceType();
   }

   class="kw">public WeatherResource() {
      this.environmentWeather.defaultReturnValue(Integer.MIN_VALUE);
   }

   @Nonnull
   class="kw">public Int2IntMap getEnvironmentWeather() {
      class="kw">return this.environmentWeather;
   }

   class="kw">public int getWeatherIndexForEnvironment(int var1) {
      class="kw">return this.environmentWeather.get(var1);
   }

   class="kw">public int getForcedWeatherIndex() {
      class="kw">return this.forcedWeatherIndex;
   }

   class="kw">public void setForcedWeather(@Nullable String var1) {
      this.previousForcedWeatherIndex = this.forcedWeatherIndex;
      this.forcedWeatherIndex = var1 == null ? 0 : Weather.getAssetMap().getIndex(var1);
   }

   class="kw">public boolean consumeForcedWeatherChange() {
      if (this.previousForcedWeatherIndex == this.forcedWeatherIndex) {
         class="kw">return false;
      }

      this.previousForcedWeatherIndex = this.forcedWeatherIndex;
      class="kw">return true;
   }

   class="kw">public boolean compareAndSwapHour(int var1) {
      if (var1 == this.previousHour) {
         class="kw">return false;
      }

      this.previousHour = var1;
      class="kw">return true;
   }

   @Nonnull
   @Override
   class="kw">public Resource<EntityStore> clone() {
      class="kw">return new WeatherResource();
   }
}