Constants interface

Пакет: com.hypixel.hytale.server.worldgen.loader.cave

Файл: com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeCoverEntryJsonLoader.java

Поля (11)

МодификаторыТипИмя
String ERROR_NO_ENTRIES
String ERROR_NO_TYPE
String ERROR_WEIGHTS_ARRAY_SIZE
String KEY_ANCHOR_TYPE
String KEY_DENSITY
String KEY_HEIGHT_THRESHOLD
String KEY_NOISE_MASK
String KEY_OFFSET
String KEY_PARENT
String KEY_TYPE
String KEY_WEIGHT

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.cave;

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.common.map.IWeightedMap;
class="kw">import com.hypixel.hytale.common.map.WeightedMap;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantBlockFluidCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.DefaultCoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.DefaultCoordinateRndCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.HeightCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IBlockFluidCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateRndCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.HeightThresholdInterpreterJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.NoiseMaskConditionJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveNodeType;
class="kw">import com.hypixel.hytale.server.worldgen.loader.util.ResolvedBlockArrayJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry;
class="kw">import com.hypixel.hytale.server.worldgen.util.ResolvedBlockArray;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.FilteredBlockFluidCondition;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.HashSetBlockFluidCondition;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.RandomCoordinateCondition;
class="kw">import it.unimi.dsi.fastutil.longs.LongSet;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;

class="kw">public class CaveNodeCoverEntryJsonLoader class="kw">extends JsonLoader<SeedStringResource, CaveNodeType.CaveNodeCoverEntry> {
   class="kw">private class="kw">static class="kw">final IBlockFluidCondition DEFAULT_PARENT_MASK = new FilteredBlockFluidCondition(0, ConstantBlockFluidCondition.DEFAULT_TRUE);

   class="kw">public CaveNodeCoverEntryJsonLoader(@Nonnull SeedString<SeedStringResource> var1, Path var2, JsonElement var3) {
      super(var1.append(".CaveNodeCoverEntry"), var2, var3);
   }

   @Nonnull
   class="kw">public CaveNodeType.CaveNodeCoverEntry load() {
      class="kw">return new CaveNodeType.CaveNodeCoverEntry(
         this.loadEntries(),
         this.loadHeightCondition(),
         this.loadMapCondition(),
         this.loadDensityCondition(),
         this.loadParentCondition(),
         this.loadAnchorType()
      );
   }

   @Nonnull
   class="kw">protected IWeightedMap<CaveNodeType.CaveNodeCoverEntry.Entry> loadEntries() {
      if (!this.has("Type")) {
         throw new IllegalArgumentException("Could not find type array for cave cover container! Keyword: Type");
      }

      ResolvedBlockArray var1 = new ResolvedBlockArrayJsonLoader(this.seed, this.dataFolder, this.get("Type")).load();
      JsonArray var2 = this.has("Weight") ? this.get("Weight").getAsJsonArray() : null;
      if (var2 != null && var2.size() != var1.size()) {
         throw new IllegalArgumentException("Weight array size does not equal size of types array");
      }

      WeightedMap.Builder var3 = WeightedMap.builder(CaveNodeType.CaveNodeCoverEntry.Entry.EMPTY_ARRAY);

      for (int var4 = 0; var4 < var1.size(); var4++) {
         BlockFluidEntry var5 = var1.getEntries()[var4];
         int var6 = this.loadOffset();
         double var7 = var2 == null ? 1.0 : var2.get(var4).getAsDouble();
         CaveNodeType.CaveNodeCoverEntry.Entry var9 = new CaveNodeType.CaveNodeCoverEntry.Entry(var5, var6);
         var3.put(var9, var7);
      }

      if (var3.size() <= 0) {
         throw new IllegalArgumentException("There are no blocks in this cover container!");
      } else {
         class="kw">return var3.build();
      }
   }

   @Nonnull
   class="kw">protected ICoordinateRndCondition loadHeightCondition() {
      ICoordinateRndCondition var1 = DefaultCoordinateRndCondition.DEFAULT_TRUE;
      if (this.has("HeightThreshold")) {
         var1 = new HeightCondition(new HeightThresholdInterpreterJsonLoader<>(this.seed, this.dataFolder, this.get("HeightThreshold"), 320).load());
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected ICoordinateCondition loadMapCondition() {
      class="kw">return new NoiseMaskConditionJsonLoader<>(this.seed, this.dataFolder, this.get("NoiseMask")).load();
   }

   @Nonnull
   class="kw">protected ICoordinateCondition loadDensityCondition() {
      ICoordinateCondition var1 = DefaultCoordinateCondition.DEFAULT_TRUE;
      if (this.has("Density")) {
         var1 = new RandomCoordinateCondition(this.get("Density").getAsDouble());
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected IBlockFluidCondition loadParentCondition() {
      IBlockFluidCondition var1 = DEFAULT_PARENT_MASK;
      if (this.has("Parent")) {
         ResolvedBlockArray var2 = new ResolvedBlockArrayJsonLoader(this.seed, this.dataFolder, this.get("Parent")).load();
         LongSet var3 = var2.getEntrySet();
         var1 = new HashSetBlockFluidCondition(var3);
      }

      class="kw">return var1;
   }

   class="kw">protected int loadOffset() {
      int var1 = 0;
      if (this.has("Offset")) {
         var1 = this.get("Offset").getAsInt();
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected CaveNodeType.CaveNodeCoverType loadAnchorType() {
      CaveNodeType.CaveNodeCoverType var1 = CaveNodeType.CaveNodeCoverType.FLOOR;
      if (this.has("AnchorType")) {
         var1 = CaveNodeType.CaveNodeCoverType.valueOf(this.get("AnchorType").getAsString());
      }

      class="kw">return var1;
   }

   class="kw">public class="kw">interface Constants {
      String KEY_TYPE = "Type";
      String KEY_WEIGHT = "Weight";
      String KEY_HEIGHT_THRESHOLD = "HeightThreshold";
      String KEY_NOISE_MASK = "NoiseMask";
      String KEY_DENSITY = "Density";
      String KEY_OFFSET = "Offset";
      String KEY_PARENT = "Parent";
      String KEY_ANCHOR_TYPE = "AnchorType";
      String ERROR_NO_TYPE = "Could not find type array for cave cover container! Keyword: Type";
      String ERROR_NO_ENTRIES = "There are no blocks in this cover container!";
      String ERROR_WEIGHTS_ARRAY_SIZE = "Weight array size does not equal size of types array";
   }
}