Constants interface

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

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

Поля (21)

МодификаторыТипИмя
Boolean DEFAULT_SUBMERGE
String ERROR_LOADING_ENVIRONMENT
String ERROR_NO_ENTRY
String ERROR_NO_ENTRY_POINTS
String KEY_BIOME_MASK
String KEY_BLOCK_MASK
String KEY_DEPTH
String KEY_ENTRY
String KEY_ENTRY_POINTS
String KEY_ENVIRONMENT
String KEY_FIXED_ENTRY_HEIGHT
String KEY_FIXED_ENTRY_HEIGHT_NOISE
String KEY_FLUID_LEVEL
String KEY_HEIGHT_RADIUS_FACTOR
String KEY_HEIGHT_THRESHOLDS
String KEY_MAXIMUM_SIZE
String KEY_NOISE_MASK
String KEY_PITCH
String KEY_SUBMERGE
String KEY_SURFACE_LIMITTED
String KEY_YAW

Исходный код

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

class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.procedurallib.condition.DefaultCoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.HeightThresholdCoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IHeightThresholdInterpreter;
class="kw">import com.hypixel.hytale.procedurallib.file.FileIO;
class="kw">import com.hypixel.hytale.procedurallib.json.DoubleRangeJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.FloatRangeJsonLoader;
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.NoisePropertyJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.PointGeneratorJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.IPointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleRange;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IFloatRange;
class="kw">import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveBiomeMaskFlags;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveNodeType;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveType;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.ZoneFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.loader.prefab.BlockPlacementMaskJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.util.ConstantNoiseProperty;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.flag.Int2FlagsCondition;
class="kw">import java.io.File;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class CaveTypeJsonLoader class="kw">extends JsonLoader<SeedStringResource, CaveType> {
   class="kw">protected class="kw">final Path caveFolder;
   class="kw">protected class="kw">final String name;
   class="kw">protected class="kw">final ZoneFileContext zoneContext;

   class="kw">public CaveTypeJsonLoader(@Nonnull SeedString<SeedStringResource> var1, Path var2, JsonElement var3, Path var4, String var5, ZoneFileContext var6) {
      super(var1.append(".CaveType"), var2, var3);
      this.caveFolder = var4;
      this.name = var5;
      this.zoneContext = var6;
   }

   @Nonnull
   class="kw">public CaveType load() {
      IPointGenerator var1 = this.loadEntryPointGenerator();
      class="kw">return new CaveType(
         this.name,
         this.loadEntryNodeType(),
         this.loadYaw(),
         this.loadPitch(),
         this.loadDepth(),
         this.loadHeightFactors(),
         var1,
         this.loadBiomeMask(),
         this.loadBlockMask(),
         this.loadMapCondition(),
         this.loadHeightCondition(),
         this.loadFixedEntryHeight(),
         this.loadFixedEntryHeightNoise(),
         this.loadFluidLevel(),
         this.loadEnvironment(),
         this.loadSurfaceLimited(),
         this.loadSubmerge(),
         this.loadMaximumSize(var1)
      );
   }

   @Nonnull
   class="kw">protected IFloatRange loadYaw() {
      class="kw">return new FloatRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Yaw"), -180.0F, 180.0F, var0 -> var0 * (float) (Math.PI / 180.0)).load();
   }

   @Nonnull
   class="kw">protected IFloatRange loadPitch() {
      class="kw">return new FloatRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Pitch"), -15.0F, var0 -> var0 * (float) (Math.PI / 180.0)).load();
   }

   @Nonnull
   class="kw">protected IFloatRange loadDepth() {
      class="kw">return new FloatRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Depth"), 80.0F).load();
   }

   @Nullable
   class="kw">protected IHeightThresholdInterpreter loadHeightFactors() {
      class="kw">return new HeightThresholdInterpreterJsonLoader<>(this.seed, this.dataFolder, this.get("HeightRadiusFactor"), 320).load();
   }

   @Nonnull
   class="kw">protected CaveNodeType loadEntryNodeType() {
      JsonElement var1 = this.get("Entry");
      if (var1 == null) {
         throw new IllegalArgumentException("\"Entry\" is not defined. Define an entry node type");
      }

      if (var1.isJsonObject()) {
         String var8 = this.seed.get().getUniqueName("CaveType#");
         class="kw">return new CaveNodeTypeStorage(this.seed, this.dataFolder, this.caveFolder, this.zoneContext).loadCaveNodeType(var8, var1.getAsJsonObject());
      }

      if (var1.isJsonPrimitive() && var1.getAsJsonPrimitive().isString()) {
         Path var2 = this.caveFolder;
         ZoneFileContext var3 = this.zoneContext;
         String var4 = var1.getAsString();
         if (var4.startsWith("Zones.")) {
            Path var5 = this.dataFolder.resolve(var4.replace(".", File.separator));
            Path var6 = FileIO.relativize(var5, this.dataFolder);
            if (var6.getNameCount() > 1) {
               String var7 = var6.getName(1).toString();
               var3 = var3.getParentContext().getZones().get(var7);
               var2 = var3.getPath().resolve("Cave");
               var4 = FileIO.relativize(var5, var2).toString().replace(File.separator, ".");
            }
         }

         class="kw">return new CaveNodeTypeStorage(this.seed, this.dataFolder, var2, var3).loadCaveNodeType(var4);
      } else {
         throw error("Invalid entry node type definition! Expected String or JsonObject: %s", var1);
      }
   }

   @Nonnull
   class="kw">protected ICoordinateCondition loadHeightCondition() {
      ICoordinateCondition var1 = DefaultCoordinateCondition.DEFAULT_TRUE;
      if (this.has("HeightThreshold")) {
         IHeightThresholdInterpreter var2 = new HeightThresholdInterpreterJsonLoader<>(this.seed, this.dataFolder, this.get("HeightThreshold"), 320).load();
         var1 = new HeightThresholdCoordinateCondition(var2);
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">protected IPointGenerator loadEntryPointGenerator() {
      if (!this.has("EntryPoints")) {
         throw new IllegalArgumentException("\"EntryPoints\" is not defined, no spawn information for caves available");
      } else {
         class="kw">return new PointGeneratorJsonLoader<>(this.seed, this.dataFolder, this.get("EntryPoints")).load();
      }
   }

   @Nonnull
   class="kw">protected Int2FlagsCondition loadBiomeMask() {
      Int2FlagsCondition var1 = CaveBiomeMaskFlags.DEFAULT_ALLOW;
      if (this.has("BiomeMask")) {
         ZoneFileContext var2 = this.zoneContext.matchContext(this.json, "BiomeMask");
         var1 = new CaveBiomeMaskJsonLoader(this.seed, this.dataFolder, this.get("BiomeMask"), var2).load();
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">protected BlockMaskCondition loadBlockMask() {
      BlockMaskCondition var1 = BlockMaskCondition.DEFAULT_TRUE;
      if (this.has("BlockMask")) {
         var1 = new BlockPlacementMaskJsonLoader(this.seed, this.dataFolder, this.getRaw("BlockMask")).load();
      }

      class="kw">return var1;
   }

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

   @Nullable
   class="kw">protected IDoubleRange loadFixedEntryHeight() {
      IDoubleRange var1 = null;
      if (this.has("FixedEntryHeight")) {
         var1 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("FixedEntryHeight"), 0.0).load();
      }

      class="kw">return var1;
   }

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

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected CaveType.FluidLevel loadFluidLevel() {
      CaveType.FluidLevel var1 = CaveType.FluidLevel.EMPTY;
      if (this.has("FluidLevel")) {
         var1 = new FluidLevelJsonLoader(this.seed, this.dataFolder, this.get("FluidLevel")).load();
      }

      class="kw">return var1;
   }

   class="kw">protected int loadEnvironment() {
      int var1 = Integer.MIN_VALUE;
      if (this.has("Environment")) {
         String var2 = this.get("Environment").getAsString();
         var1 = Environment.getAssetMap().getIndex(var2);
         if (var1 == Integer.MIN_VALUE) {
            throw new Error(String.format("Error while looking up environment \"%s\"!", var2));
         }
      }

      class="kw">return var1;
   }

   class="kw">protected boolean loadSurfaceLimited() {
      class="kw">return !this.has("SurfaceLimited") || this.get("SurfaceLimited").getAsBoolean();
   }

   class="kw">protected boolean loadSubmerge() {
      class="kw">return this.mustGetBool("Submerge", CaveTypeJsonLoader.Constants.DEFAULT_SUBMERGE);
   }

   class="kw">protected double loadMaximumSize(@Nonnull IPointGenerator var1) {
      class="kw">return this.has("MaximumSize") ? this.get("MaximumSize").getAsLong() : MathUtil.fastFloor(var1.getInterval());
   }

   class="kw">public class="kw">interface Constants {
      String KEY_YAW = "Yaw";
      String KEY_PITCH = "Pitch";
      String KEY_DEPTH = "Depth";
      String KEY_HEIGHT_RADIUS_FACTOR = "HeightRadiusFactor";
      String KEY_ENTRY = "Entry";
      String KEY_ENTRY_POINTS = "EntryPoints";
      String KEY_HEIGHT_THRESHOLDS = "HeightThreshold";
      String KEY_BIOME_MASK = "BiomeMask";
      String KEY_BLOCK_MASK = "BlockMask";
      String KEY_NOISE_MASK = "NoiseMask";
      String KEY_FIXED_ENTRY_HEIGHT = "FixedEntryHeight";
      String KEY_FIXED_ENTRY_HEIGHT_NOISE = "FixedEntryHeightNoise";
      String KEY_FLUID_LEVEL = "FluidLevel";
      String KEY_SURFACE_LIMITTED = "SurfaceLimited";
      String KEY_SUBMERGE = "Submerge";
      String KEY_MAXIMUM_SIZE = "MaximumSize";
      String KEY_ENVIRONMENT = "Environment";
      Boolean DEFAULT_SUBMERGE = Boolean.FALSE;
      String ERROR_NO_ENTRY = "\"Entry\" is not defined. Define an entry node type";
      String ERROR_NO_ENTRY_POINTS = "\"EntryPoints\" is not defined, no spawn information for caves available";
      String ERROR_LOADING_ENVIRONMENT = "Error while looking up environment \"%s\"!";
   }
}