Constants interface

Пакет: com.hypixel.hytale.procedurallib.json

Файл: com/hypixel/hytale/procedurallib/json/PointGeneratorJsonLoader.java

Поля (7)

МодификаторыТипИмя
String KEY_OFFSET
String KEY_OFFSET_X
String KEY_OFFSET_Y
String KEY_OFFSET_Z
String KEY_RANDOMIZER
String KEY_SCALE
String KEY_SEED

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.procedurallib.json;

class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.CellDistanceFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.DistanceCalculationMode;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.PointDistanceFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.evaluator.PointEvaluator;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.DistortedPointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.IPointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.OffsetPointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.PointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.logic.point.ScaledPointGenerator;
class="kw">import com.hypixel.hytale.procedurallib.random.CoordinateRotator;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class PointGeneratorJsonLoader<K class="kw">extends SeedResource> class="kw">extends JsonLoader<K, IPointGenerator> {
   class="kw">public PointGeneratorJsonLoader(SeedString<K> var1, Path var2, JsonElement var3) {
      super(var1, var2, var3);
   }

   class="kw">public IPointGenerator load() {
      PointGenerator var1 = this.newPointGenerator(this.loadSeed(), this.loadCellDistanceFunction());
      IPointGenerator var2 = var1;
      if (this.has("Scale")) {
         var2 = new ScaledPointGenerator(var1, this.get("Scale").getAsDouble());
      }

      if (this.has("Randomizer")) {
         var2 = new DistortedPointGenerator(var2, new CoordinateRandomizerJsonLoader<>(this.seed, this.dataFolder, this.get("Randomizer")).load());
      }

      double var3 = Double.NEGATIVE_INFINITY;
      double var5 = Double.NEGATIVE_INFINITY;
      double var7 = Double.NEGATIVE_INFINITY;
      if (this.has("Offset")) {
         var3 = var5 = var7 = this.get("Offset").getAsDouble();
      }

      if (this.has("OffsetX")) {
         var3 = this.get("OffsetX").getAsDouble();
      }

      if (this.has("OffsetY")) {
         var5 = this.get("OffsetY").getAsDouble();
      }

      if (this.has("OffsetZ")) {
         var7 = this.get("OffsetZ").getAsDouble();
      }

      if (var3 != Double.NEGATIVE_INFINITY || var5 != Double.NEGATIVE_INFINITY || var7 != Double.NEGATIVE_INFINITY) {
         if (var3 == Double.NEGATIVE_INFINITY) {
            var3 = 0.0;
         }

         if (var5 == Double.NEGATIVE_INFINITY) {
            var5 = 0.0;
         }

         if (var7 == Double.NEGATIVE_INFINITY) {
            var7 = 0.0;
         }

         var2 = new OffsetPointGenerator(var2, var3, var5, var7);
      }

      if (this.has("Rotate")) {
         CoordinateRotator var9 = new CoordinateRotatorJsonLoader<>(this.seed, this.dataFolder, this.get("Rotate")).load();
         if (var9 != CoordinateRotator.NONE) {
            var2 = new DistortedPointGenerator(var2, var9);
         }
      }

      class="kw">return var2;
   }

   class="kw">protected int loadSeed() {
      int var1 = this.seed.hashCode();
      if (this.has("Seed")) {
         SeedString var2 = this.seed.appendToOriginal(this.get("Seed").getAsString());
         var1 = var2.hashCode();
         this.seed.get().reportSeeds(var1, this.seed.original, this.seed.seed, var2.seed);
      } else {
         this.seed.get().reportSeeds(var1, this.seed.original, this.seed.seed, null);
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected PointGenerator newPointGenerator(int var1, CellDistanceFunction var2) {
      SeedResource var3 = this.seed.get();
      PointEvaluator var4 = this.loadPointEvaluator();
      class="kw">return new SeedResourcePointGenerator(var1, var2, var4, var3);
   }

   @Nullable
   class="kw">protected CellDistanceFunction loadCellDistanceFunction() {
      class="kw">return new CellDistanceFunctionJsonLoader<>(this.seed, this.dataFolder, this.json, this.loadPointDistanceFunction()).load();
   }

   @Nullable
   class="kw">protected PointEvaluator loadPointEvaluator() {
      class="kw">return new PointEvaluatorJsonLoader<>(this.seed, this.dataFolder, this.json).load();
   }

   class="kw">protected PointDistanceFunction loadPointDistanceFunction() {
      DistanceCalculationMode var1 = CellNoiseJsonLoader.Constants.DEFAULT_DISTANCE_MODE;
      if (this.has("DistanceMode")) {
         var1 = DistanceCalculationMode.valueOf(this.get("DistanceMode").getAsString());
      }

      class="kw">return var1.getFunction();
   }

   class="kw">public class="kw">interface Constants {
      String KEY_SEED = "Seed";
      String KEY_SCALE = "Scale";
      String KEY_RANDOMIZER = "Randomizer";
      String KEY_OFFSET = "Offset";
      String KEY_OFFSET_X = "OffsetX";
      String KEY_OFFSET_Y = "OffsetY";
      String KEY_OFFSET_Z = "OffsetZ";
   }
}