WaterContainerEntryJsonLoader class

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

Файл: com/hypixel/hytale/server/worldgen/loader/container/WaterContainerJsonLoader.java

extends: JsonLoader<SeedStringResource, WaterContainer.Entry>

Поля (13)

МодификаторыТипИмя
String var1
IDoubleRange var1
IDoubleRange var1
ICoordinateCondition var1
var1
String var2
NoiseProperty var2
NoiseProperty var2
NoiseProperty var2
var2
int var3
String var5
int var6

Методы (11)

МодификаторыВозвратСигнатура
abstract return new DoubleRangeNoiseSupplierreturn new DoubleRangeNoiseSupplier(var1, var2)
abstract throw new Errorthrow new Error("Failed to load water container.", var4)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Could not find fluid information. Keyword: Fluid")
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Could not find maximum of water container entry.")
if if(var6 == Integer.MIN_VALUE)
if if(var3 == Integer.MIN_VALUE)
public WaterContainer.Entry loadpublic WaterContainer.Entry load()
private IDoubleCoordinateSupplier loadMaxprivate IDoubleCoordinateSupplier loadMax()
private IDoubleCoordinateSupplier loadMinprivate IDoubleCoordinateSupplier loadMin()
private NoiseProperty loadNoiseprivate NoiseProperty loadNoise(String var1)
private ICoordinateCondition loadNoiseMaskprivate ICoordinateCondition loadNoiseMask()

Исходный код

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

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvent;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvents;
class="kw">import com.hypixel.hytale.procedurallib.condition.DefaultCoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.DoubleRangeJsonLoader;
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.NoisePropertyJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.supplier.DoubleRange;
class="kw">import com.hypixel.hytale.procedurallib.supplier.DoubleRangeNoiseSupplier;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleCoordinateSupplier;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleRange;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.container.WaterContainer;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.BiomeFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.util.ConstantNoiseProperty;
class="kw">import com.hypixel.hytale.server.worldgen.util.ListPool;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class WaterContainerJsonLoader class="kw">extends JsonLoader<SeedStringResource, WaterContainer> {
   @Nonnull
   class="kw">private class="kw">final BiomeFileContext biomeContext;

   class="kw">public WaterContainerJsonLoader(@Nonnull SeedString<SeedStringResource> var1, Path var2, JsonElement var3, @Nonnull BiomeFileContext var4) {
      super(var1.append(".WaterContainer"), var2, var3);
      this.biomeContext = var4;
   }

   @Nonnull
   class="kw">public WaterContainer load() {
      try (ListPool.Resource var1 = WaterContainer.ENTRY_POOL.acquire()) {
         if (this.has("Block")) {
            String var12 = this.get("Block").getAsString();
            String var15 = var12;
            int var17 = BlockType.getAssetMap().getIndex(var15);
            if (var17 == Integer.MIN_VALUE) {
               throw new Error(String.format("Could not find Fluid for fluid: %s", var15.toString()));
            }

            IDoubleRange var18 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Height"), 0.0).load();
            NoiseProperty var19 = ConstantNoiseProperty.DEFAULT_ZERO;
            if (this.has("Heightmap")) {
               var19 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Heightmap")).load();
            }

            DoubleRangeNoiseSupplier var7 = new DoubleRangeNoiseSupplier(var18, var19);
            var1.add(
               new WaterContainer.Entry(
                  var17, 0, new DoubleRangeNoiseSupplier(DoubleRange.ZERO, ConstantNoiseProperty.DEFAULT_ZERO), var7, DefaultCoordinateCondition.DEFAULT_TRUE
               )
            );
         } else if (this.has("Fluid")) {
            String var11 = this.get("Fluid").getAsString();
            int var14 = Fluid.getAssetMap().getIndex(var11);
            if (var14 == Integer.MIN_VALUE) {
               throw new Error(String.format("Could not find Fluid for fluid: %s", var11));
            }

            IDoubleRange var4 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Height"), 0.0).load();
            NoiseProperty var5 = ConstantNoiseProperty.DEFAULT_ZERO;
            if (this.has("Heightmap")) {
               var5 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Heightmap")).load();
            }

            DoubleRangeNoiseSupplier var6 = new DoubleRangeNoiseSupplier(var4, var5);
            var1.add(
               new WaterContainer.Entry(
                  0, var14, new DoubleRangeNoiseSupplier(DoubleRange.ZERO, ConstantNoiseProperty.DEFAULT_ZERO), var6, DefaultCoordinateCondition.DEFAULT_TRUE
               )
            );
         } else {
            JsonArray var2 = this.mustGetArray("Entries", EMPTY_ARRAY);

            for (int var3 = 0; var3 < var2.size(); var3++) {
               try {
                  var1.add(
                     new WaterContainerJsonLoader.WaterContainerEntryJsonLoader(this.seed.append(String.format("-%s", var3)), this.dataFolder, var2.get(var3))
                        .load()
                  );
               } catch (Throwable var9) {
                  throw new Error(String.format("Failed to load TintContainerEntry #%s", var3), var9);
               }
            }
         }

         ModifyEvent.SeedGenerator var13 = new ModifyEvent.SeedGenerator<>(this.seed);
         ModifyEvent.dispatch(
            ModifyEvents.BiomeFluids.class,
            new ModifyEvents.BiomeFluids(
               this.seed,
               this.biomeContext,
               var1,
               var2x -> new WaterContainerJsonLoader.WaterContainerEntryJsonLoader(var13.next(), this.dataFolder, this.loadFile(var2x)).load()
            )
         );
         class="kw">return new WaterContainer(var1.toArray());
      }
   }

   class="kw">public class="kw">interface Constants {
      String KEY_ENTRIES = "Entries";
      String KEY_ENTRY_BLOCK = "Block";
      String ERROR_ENTRY_NO_BLOCK = "Could not find block information. Keyword: Block";
      String ERROR_ENTRY_FLUID_BLOCK = "Could not find BlockType for block: %s";
      String KEY_ENTRY_FLUID = "Fluid";
      String ERROR_ENTRY_NO_FLUID = "Could not find fluid information. Keyword: Fluid";
      String ERROR_ENTRY_FLUID_TYPE = "Could not find Fluid for fluid: %s";
      String KEY_ENTRY_MIN = "Min";
      String KEY_ENTRY_MIN_NOISE = "MinNoise";
      String KEY_ENTRY_MAX = "Max";
      String KEY_ENTRY_MAX_NOISE = "MaxNoise";
      String KEY_ENTRY_NOISE_MASK = "NoiseMask";
      String ERROR_ENTRY_NO_MAX = "Could not find maximum of water container entry.";
   }

   class="kw">private class="kw">static class WaterContainerEntryJsonLoader class="kw">extends JsonLoader<SeedStringResource, WaterContainer.Entry> {
      class="kw">public WaterContainerEntryJsonLoader(@Nonnull SeedString<SeedStringResource> var1, Path var2, JsonElement var3) {
         super(var1.append(".Entry"), var2, var3);
      }

      @Nonnull
      class="kw">public WaterContainer.Entry load() {
         try {
            if (this.has("Fluid")) {
               String var5 = this.get("Fluid").getAsString();
               int var6 = Fluid.getAssetMap().getIndex(var5);
               if (var6 == Integer.MIN_VALUE) {
                  throw new Error(String.format("Could not find Fluid for fluid: %s", var5));
               } else {
                  class="kw">return new WaterContainer.Entry(0, var6, this.loadMin(), this.loadMax(), this.loadNoiseMask());
               }
            } else if (this.has("Block")) {
               String var1 = this.get("Block").getAsString();
               String var2 = var1;
               int var3 = BlockType.getAssetMap().getIndex(var2);
               if (var3 == Integer.MIN_VALUE) {
                  throw new Error(String.format("Could not find Fluid for fluid: %s", var2.toString()));
               } else {
                  class="kw">return new WaterContainer.Entry(var3, 0, this.loadMin(), this.loadMax(), this.loadNoiseMask());
               }
            } else {
               throw new IllegalArgumentException("Could not find fluid information. Keyword: Fluid");
            }
         } catch (Error var4) {
            throw new Error("Failed to load water container.", var4);
         }
      }

      @Nonnull
      class="kw">private IDoubleCoordinateSupplier loadMin() {
         IDoubleRange var1 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Min"), 0.0).load();
         NoiseProperty var2 = this.loadNoise("MinNoise");
         class="kw">return new DoubleRangeNoiseSupplier(var1, var2);
      }

      @Nonnull
      class="kw">private IDoubleCoordinateSupplier loadMax() {
         if (!this.has("Max")) {
            throw new IllegalArgumentException("Could not find maximum of water container entry.");
         }

         IDoubleRange var1 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Max"), 0.0).load();
         NoiseProperty var2 = this.loadNoise("MaxNoise");
         class="kw">return new DoubleRangeNoiseSupplier(var1, var2);
      }

      @Nullable
      class="kw">private NoiseProperty loadNoise(String var1) {
         NoiseProperty var2 = ConstantNoiseProperty.DEFAULT_ZERO;
         if (this.has(var1)) {
            var2 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get(var1)).load();
         }

         class="kw">return var2;
      }

      @Nonnull
      class="kw">private ICoordinateCondition loadNoiseMask() {
         ICoordinateCondition var1 = DefaultCoordinateCondition.DEFAULT_TRUE;
         if (this.has("NoiseMask")) {
            var1 = new NoiseMaskConditionJsonLoader<>(this.seed, this.dataFolder, this.get("NoiseMask")).load();
         }

         class="kw">return var1;
      }
   }
}