TilledSoilBlock class

Пакет: com.hypixel.hytale.builtin.adventure.farming.states

Файл: com/hypixel/hytale/builtin/adventure/farming/states/TilledSoilBlock.java

implements: Component<ChunkStore>

Поля (2)

МодификаторыТипИмя
static int VERSION
boolean var3

Методы (12)

МодификаторыВозвратСигнатура
static ComponentType<ChunkStore, TilledSoilBlock> getComponentTypeComponentType<ChunkStore, TilledSoilBlock> getComponentType()
public boolean hasExternalWaterboolean hasExternalWater()
if if(var1 != null)
if if(var1 != null)
if if(this.fertilized && var3)
public boolean isFertilizedboolean isFertilized()
public boolean isPlantedboolean isPlanted()
public void setDecayTimevoid setDecayTime(@Nullable Instant var1)
public void setExternalWatervoid setExternalWater(boolean var1)
public void setFertilizedvoid setFertilized(boolean var1)
public void setPlantedvoid setPlanted(boolean var1)
public void setWateredUntilvoid setWateredUntil(@Nullable Instant var1)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.adventure.farming.FarmingPlugin;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.MapCodec;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
class="kw">import java.time.Instant;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class TilledSoilBlock class="kw">implements Component<ChunkStore> {
   class="kw">public class="kw">static int VERSION = 1;
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<TilledSoilBlock> CODEC = BuilderCodec.<TilledSoilBlock>builder(TilledSoilBlock.class, TilledSoilBlock::new)
      .versioned()
      .codecVersion(VERSION)
      .append(new KeyedCodec<>("Planted", Codec.BOOLEAN), (var0, var1) -> var0.planted = var1, var0 -> var0.planted ? Boolean.TRUE : null)
      .add()
      .<Map>append(new KeyedCodec<>("ModifierTimes", new MapCodec<>(Codec.INSTANT, Object2ObjectOpenHashMap::new, false)), (var0, var1) -> {
         if (var1 != null) {
            var0.wateredUntil = (Instant)var1.get("WateredUntil");
         }
      }, var0 -> null)
      .setVersionRange(0, 0)
      .add()
      .<String[]>append(new KeyedCodec<>("Flags", Codec.STRING_ARRAY), (var0, var1) -> {
         if (var1 != null) {
            var0.fertilized = ArrayUtil.contains(var1, "Fertilized");
            var0.externalWater = ArrayUtil.contains(var1, "ExternalWater");
         }
      }, var0 -> null)
      .setVersionRange(0, 0)
      .add()
      .<Boolean>append(new KeyedCodec<>("Fertilized", Codec.BOOLEAN), (var0, var1) -> var0.fertilized = var1, var0 -> var0.fertilized ? Boolean.TRUE : null)
      .setVersionRange(1, VERSION)
      .add()
      .<Boolean>append(
         new KeyedCodec<>("ExternalWater", Codec.BOOLEAN), (var0, var1) -> var0.externalWater = var1, var0 -> var0.externalWater ? Boolean.TRUE : null
      )
      .setVersionRange(1, VERSION)
      .add()
      .<Instant>append(new KeyedCodec<>("WateredUntil", Codec.INSTANT), (var0, var1) -> var0.wateredUntil = var1, var0 -> var0.wateredUntil)
      .setVersionRange(1, VERSION)
      .add()
      .append(new KeyedCodec<>("DecayTime", Codec.INSTANT), (var0, var1) -> var0.decayTime = var1, var0 -> var0.decayTime)
      .add()
      .build();
   class="kw">protected boolean planted;
   class="kw">protected boolean fertilized;
   class="kw">protected boolean externalWater;
   @Nullable
   class="kw">protected Instant wateredUntil;
   @Nullable
   class="kw">protected Instant decayTime;

   class="kw">public class="kw">static ComponentType<ChunkStore, TilledSoilBlock> getComponentType() {
      class="kw">return FarmingPlugin.get().getTiledSoilBlockComponentType();
   }

   class="kw">public TilledSoilBlock() {
   }

   class="kw">public TilledSoilBlock(boolean var1, boolean var2, boolean var3, Instant var4, Instant var5) {
      this.planted = var1;
      this.fertilized = var2;
      this.externalWater = var3;
      this.wateredUntil = var4;
      this.decayTime = var5;
   }

   class="kw">public boolean isPlanted() {
      class="kw">return this.planted;
   }

   class="kw">public void setPlanted(boolean var1) {
      this.planted = var1;
   }

   class="kw">public void setWateredUntil(@Nullable Instant var1) {
      this.wateredUntil = var1;
   }

   @Nullable
   class="kw">public Instant getWateredUntil() {
      class="kw">return this.wateredUntil;
   }

   class="kw">public boolean isFertilized() {
      class="kw">return this.fertilized;
   }

   class="kw">public void setFertilized(boolean var1) {
      this.fertilized = var1;
   }

   class="kw">public boolean hasExternalWater() {
      class="kw">return this.externalWater;
   }

   class="kw">public void setExternalWater(boolean var1) {
      this.externalWater = var1;
   }

   @Nullable
   class="kw">public Instant getDecayTime() {
      class="kw">return this.decayTime;
   }

   class="kw">public void setDecayTime(@Nullable Instant var1) {
      this.decayTime = var1;
   }

   @Nullable
   class="kw">public String computeBlockType(@Nonnull Instant var1, @Nonnull BlockType var2) {
      boolean var3 = this.hasExternalWater() || this.wateredUntil != null && this.wateredUntil.isAfter(var1);
      if (this.fertilized && var3) {
         class="kw">return var2.getBlockKeyForState("Fertilized_Watered");
      } else if (this.fertilized) {
         class="kw">return var2.getBlockKeyForState("Fertilized");
      } else {
         class="kw">return var3 ? var2.getBlockKeyForState("Watered") : var2.getBlockKeyForState("class="kw">default");
      }
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "TilledSoilBlock{planted="
         + this.planted
         + ", fertilized="
         + this.fertilized
         + ", externalWater="
         + this.externalWater
         + ", wateredUntil="
         + this.wateredUntil
         + ", decayTime="
         + this.decayTime
         + "}";
   }

   @Nullable
   @Override
   class="kw">public Component<ChunkStore> clone() {
      class="kw">return new TilledSoilBlock(this.planted, this.fertilized, this.externalWater, this.wateredUntil, this.decayTime);
   }
}