EntryJsonLoader class

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

Файл: com/hypixel/hytale/server/worldgen/loader/util/NoiseBlockArrayJsonLoader.java

extends: JsonLoader<SeedStringResource, NoiseBlockArray.Entry>

Поля (16)

МодификаторыТипИмя
String var1
NoiseProperty var1
var1
BlockFluidEntry var2
BlockPattern.BlockEntry var2
IDoubleRange var3
int var3
NoiseProperty var4
String var5
var5
String var5
int var6
var6
int var6
String[] var7
BlockFluidEntry var8

Методы (11)

МодификаторыВозвратСигнатура
abstract return new BlockFluidEntryreturn new BlockFluidEntry(0, 0, var6)
abstract throw new Errorthrow new Error("BlockLayer does not exist in BlockTypes", var4)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Unsupported Json Entry: " + this.json)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var5)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var2)
if if(var6 == Integer.MIN_VALUE)
if if(var3 == Integer.MIN_VALUE)
public NoiseBlockArray.Entry loadpublic NoiseBlockArray.Entry load()
protected NoiseProperty loadNoiseprotected NoiseProperty loadNoise()
protected IDoubleRange loadRepetitionsprotected IDoubleRange loadRepetitions()
protected BlockFluidEntry resolveBlockIdprotected BlockFluidEntry resolveBlockId(@Nonnull String var1)

Исходный код

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

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
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.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.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.core.prefab.selection.mask.BlockPattern;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry;
class="kw">import com.hypixel.hytale.server.worldgen.util.ConstantNoiseProperty;
class="kw">import com.hypixel.hytale.server.worldgen.util.NoiseBlockArray;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

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

   @Nonnull
   class="kw">public NoiseBlockArray load() {
      if (this.json.isJsonPrimitive()) {
         class="kw">return new NoiseBlockArray(new NoiseBlockArray.Entry[]{new NoiseBlockArrayJsonLoader.EntryJsonLoader(this.seed, this.dataFolder, this.json).load()});
      }

      if (this.json.isJsonObject() && !this.has("Entries")) {
         class="kw">return new NoiseBlockArray(new NoiseBlockArray.Entry[]{this.loadEntry(this.json, 0)});
      }

      JsonElement var1;
      if (this.json.isJsonArray()) {
         var1 = this.json;
      } else {
         var1 = this.get("Entries");
      }

      if (var1 != null && !var1.isJsonNull()) {
         JsonArray var2 = var1.getAsJsonArray();
         NoiseBlockArray.Entry[] var3 = new NoiseBlockArray.Entry[var2.size()];

         for (int var4 = 0; var4 < var2.size(); var4++) {
            try {
               var3[var4] = this.loadEntry(var2.get(var4), var4);
            } catch (Throwable var6) {
               throw new Error(String.format("Failed to load block array entry #%s", var4), var6);
            }
         }

         class="kw">return new NoiseBlockArray(var3);
      } else {
         throw new IllegalArgumentException("Could not find entries in block array. Keyword: Entries");
      }
   }

   @Nonnull
   class="kw">protected NoiseBlockArray.Entry loadEntry(JsonElement var1, int var2) {
      class="kw">return new NoiseBlockArrayJsonLoader.EntryJsonLoader(this.seed.append("-" + var2), this.dataFolder, var1).load();
   }

   class="kw">public class="kw">interface Constants {
      String KEY_ENTRIES = "Entries";
      String KEY_ENTRY_TYPE = "Type";
      String KEY_ENTRY_REPEAT = "Repeat";
      String KEY_ENTRY_REPEAT_NOISE = "RepeatNoise";
      String ERROR_NO_ENTRIES = "Could not find entries in block array. Keyword: Entries";
      String ERROR_ENTRY_FAIL = "Failed to load block array entry #%s";
   }

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

      @Nonnull
      class="kw">public NoiseBlockArray.Entry load() {
         if (this.json.isJsonPrimitive()) {
            String var5 = this.json.getAsString();
            int var6 = 1;
            if (var5.contains(":")) {
               String[] var7 = var5.split(":", -1);
               var5 = var7[0];
               var6 = Integer.parseInt(var7[1]);
            }

            BlockFluidEntry var8 = this.resolveBlockId(var5);
            class="kw">return new NoiseBlockArray.Entry(var5, var8, new DoubleRange.Constant(var6), ConstantNoiseProperty.DEFAULT_ZERO);
         } else if (this.json.isJsonObject()) {
            String var1 = this.get("Type").getAsString();
            BlockFluidEntry var2 = this.resolveBlockId(var1);
            IDoubleRange var3 = this.loadRepetitions();
            NoiseProperty var4 = this.loadNoise();
            class="kw">return new NoiseBlockArray.Entry(var1, var2, var3, var4);
         } else {
            throw new IllegalArgumentException("Unsupported Json Entry: " + this.json);
         }
      }

      @Nullable
      class="kw">protected IDoubleRange loadRepetitions() {
         class="kw">return new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Repeat"), 1.0).load();
      }

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

         class="kw">return var1;
      }

      @Nonnull
      class="kw">protected BlockFluidEntry resolveBlockId(@Nonnull String var1) {
         try {
            if (var1.startsWith("fluid#")) {
               String var5 = var1.substring("fluid#".length());
               int var6 = Fluid.getAssetMap().getIndex(var5);
               if (var6 == Integer.MIN_VALUE) {
                  throw new IllegalArgumentException("Unknown key! " + var5);
               } else {
                  class="kw">return new BlockFluidEntry(0, 0, var6);
               }
            } else {
               BlockPattern.BlockEntry var2 = BlockPattern.BlockEntry.decode(var1);
               int var3 = BlockType.getAssetMap().getIndex(var2.blockTypeKey());
               if (var3 == Integer.MIN_VALUE) {
                  throw new IllegalArgumentException("Unknown key! " + var2);
               } else {
                  class="kw">return new BlockFluidEntry(var3, var2.rotation(), 0);
               }
            }
         } catch (IllegalArgumentException var4) {
            throw new Error("BlockLayer does not exist in BlockTypes", var4);
         }
      }
   }
}