Constants interface

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

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

Поля (6)

МодификаторыТипИмя
String ERROR_NO_BLOCK
String ERROR_UNKOWN_BLOCK
String ERROR_UNKOWN_FLUID
String KEY_BLOCK
String KEY_FLUID
String KEY_HEIGHT

Исходный код

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

class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
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.cave.CaveType;
class="kw">import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;

class="kw">public class FluidLevelJsonLoader class="kw">extends JsonLoader<SeedStringResource, CaveType.FluidLevel> {
   class="kw">public FluidLevelJsonLoader(SeedString<SeedStringResource> var1, Path var2, JsonElement var3) {
      super(var1, var2, var3);
   }

   @Nonnull
   class="kw">public CaveType.FluidLevel load() {
      int var1 = 0;
      int var2 = 0;
      int var3 = 0;
      if (this.has("Block")) {
         String var4 = this.get("Block").getAsString();
         BlockPattern.BlockEntry var5 = BlockPattern.BlockEntry.decode(var4);
         var1 = BlockType.getAssetMap().getIndex(var5.blockTypeKey());
         if (var1 == Integer.MIN_VALUE) {
            throw new Error(String.format("Could not resolve block \"%s\" from BlockTypes.", var4));
         }

         var2 = var5.rotation();
      }

      if (this.has("Fluid")) {
         String var6 = this.get("Fluid").getAsString();
         var3 = Fluid.getAssetMap().getIndex(var6);
         if (var3 == Integer.MIN_VALUE) {
            throw new Error(String.format("Could not resolve fluid \"%s\" from Fluids.", var6));
         }
      }

      if (!this.has("Block") && !this.has("Fluid")) {
         throw new IllegalArgumentException("Could not find block to use in FluidLevel container. Keyword: Block");
      } else {
         class="kw">return new CaveType.FluidLevel(new BlockFluidEntry(var1, var2, var3), this.loadHeight());
      }
   }

   class="kw">protected int loadHeight() {
      class="kw">return this.get("Height").getAsInt();
   }

   class="kw">public class="kw">interface Constants {
      String KEY_HEIGHT = "Height";
      String KEY_BLOCK = "Block";
      String KEY_FLUID = "Fluid";
      String ERROR_NO_BLOCK = "Could not find block to use in FluidLevel container. Keyword: Block";
      String ERROR_UNKOWN_BLOCK = "Could not resolve block \"%s\" from BlockTypes.";
      String ERROR_UNKOWN_FLUID = "Could not resolve fluid \"%s\" from Fluids.";
   }
}