NoisePropertyJsonLoader class

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

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

extends: JsonLoader<K, NoiseProperty>

Поля (111)

МодификаторыТипИмя
FractalNoiseProperty.FractalMode DEFAULT_FRACTAL_MODE
double DEFAULT_LACUNARITY
double DEFAULT_PERSISTENCE
String ERROR_DISTORTED_RANDOMIZER
String ERROR_NORMALIZE_NO_RANGE
String ERROR_NO_FORMULA
String ERROR_NO_NOISE
String ERROR_NO_SCALE
String ERROR_SUM_NO_FACTORS
String ERROR_UNKOWN_TYPE
String KEY_CURVE
String KEY_DISTORTED_RANDOMIZER
String KEY_FORMULA
String KEY_FRACTAL_MODE
String KEY_GRADIENT
String KEY_LACUNARITY
String KEY_NOISE
String KEY_NORMALIZE
String KEY_NORMALIZE_RANGE
String KEY_OCTAVES
String KEY_OFFSET
String KEY_OFFSET_X
String KEY_OFFSET_Y
String KEY_OFFSET_Z
String KEY_PERSISTENCE
String KEY_SCALE
String KEY_SEED
String KEY_SUM_FACTORS
String KEY_TYPE
break
break
break
break
break
break
break
break
break
break
break
break
break
break
NoiseProperty var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
var1
int var1
var1
double var10
NoiseProperty var12
NoiseProperty var13
NoiseProperty var14
NoiseProperty var15
NoiseProperty var16
NoiseProperty[] var17
NoiseProperty var18
NoiseProperty var19
NoisePropertyType var2
var2
SeedString var2
JsonArray var2
NoiseProperty[] var20
NoiseProperty[] var21
NoiseProperty[] var22
NoiseFunction var23
NoiseFormulaProperty.NoiseFormula var24
double var25
IDoubleRange var26
double var27
CoordinateRotator var28
double var29
NoiseProperty var3
NoiseProperty[] var3
double[] var3
IDoubleRange var30
NoiseFormulaProperty.NoiseFormula var31
double var32
double[] var33
FractalNoiseProperty.FractalMode var34
int var35
double var36
double var38
double var39
CoordinateRotator var4
JsonArray var4
SumNoiseProperty.Entry[] var5
double var6
double var7
double var8
double var9

Методы (12)

МодификаторыВозвратСигнатура
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find noise map data. Keyword: Noise")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find factors for sum composed noise map. Keyword: Factors")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find scale data for scaled noise map. Keyword: Scale")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find formula type for noise map. Keyword: Formula")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find randomizer for distorted noise map. Keyword: Randomizer")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find range data for normalized noise map. Keyword: Range")
for for(int var37 = 0; var37 < var5.length; var37++)
for for(int var4 = 0; var4 < var3.length; var4++)
for for(int var5 = 0; var5 < var2; var5++)
protected double[] loadDoubleArraydouble[] loadDoubleArray(@Nullable JsonElement var1, int var2)
protected int loadSeedint loadSeed()
switch switch(var2)

Исходный код

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

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.NoiseFunction;
class="kw">import com.hypixel.hytale.procedurallib.property.DistortedNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.FractalNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.InvertNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.MaxNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.MinNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.MultiplyNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseFormulaProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.NoisePropertyType;
class="kw">import com.hypixel.hytale.procedurallib.property.NormalizeNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.OffsetNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.RotateNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.ScaleNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.SingleNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.property.SumNoiseProperty;
class="kw">import com.hypixel.hytale.procedurallib.random.CoordinateRotator;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleRange;
class="kw">import java.nio.file.Path;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class NoisePropertyJsonLoader<K class="kw">extends SeedResource> class="kw">extends JsonLoader<K, NoiseProperty> {
   class="kw">public NoisePropertyJsonLoader(@Nonnull SeedString<K> var1, Path var2, JsonElement var3) {
      super(var1.append(".NoiseProperty"), var2, var3);
   }

   @Nonnull
   class="kw">public NoiseProperty load() {
      NoisePropertyType var2 = null;
      NoiseProperty var1;
      if (this.has("Type")) {
         var2 = NoisePropertyType.valueOf(this.get("Type").getAsString());
         class="kw">switch (var2) {
            case MAX:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty[] var22 = this.loadNoiseProperties(this.get("Noise"));
               var1 = new MaxNoiseProperty(var22);
               break;
            case MIN:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty[] var21 = this.loadNoiseProperties(this.get("Noise"));
               var1 = new MinNoiseProperty(var21);
               break;
            case SUM:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Factors")) {
                  throw new IllegalStateException("Could not find factors for sum composed noise map. Keyword: Factors");
               }

               NoiseProperty[] var20 = this.loadNoiseProperties(this.get("Noise"));
               double[] var33 = this.loadDoubleArray(this.get("Factors"), var20.length);
               SumNoiseProperty.Entry[] var5 = new SumNoiseProperty.Entry[var20.length];

               for (int var37 = 0; var37 < var5.length; var37++) {
                  var5[var37] = new SumNoiseProperty.Entry(var20[var37], var33[var37]);
               }

               var1 = new SumNoiseProperty(var5);
               break;
            case SCALE:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Scale")) {
                  throw new IllegalStateException("Could not find scale data for scaled noise map. Keyword: Scale");
               }

               NoiseProperty var19 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               double var32 = this.get("Scale").getAsDouble();
               var1 = new ScaleNoiseProperty(var19, var32);
               break;
            case FORMULA:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Formula")) {
                  throw new IllegalStateException("Could not find formula type for noise map. Keyword: Formula");
               }

               NoiseProperty var18 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               NoiseFormulaProperty.NoiseFormula var31 = NoiseFormulaProperty.NoiseFormula.valueOf(this.get("Formula").getAsString());
               var1 = new NoiseFormulaProperty(var18, var31.getFormula());
               break;
            case MULTIPLY:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty[] var17 = this.loadNoiseProperties(this.get("Noise"));
               var1 = new MultiplyNoiseProperty(var17);
               break;
            case DISTORTED:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Randomizer")) {
                  throw new IllegalStateException("Could not find randomizer for distorted noise map. Keyword: Randomizer");
               }

               NoiseProperty var16 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               var1 = new DistortedNoiseProperty(var16, new CoordinateRandomizerJsonLoader<>(this.seed, this.dataFolder, this.get("Randomizer")).load());
               break;
            case NORMALIZE:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Range")) {
                  throw new IllegalStateException("Could not find range data for normalized noise map. Keyword: Range");
               }

               NoiseProperty var15 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               IDoubleRange var30 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Range")).load();
               var1 = new NormalizeNoiseProperty(var15, var30.getValue(0.0), var30.getValue(1.0) - var30.getValue(0.0));
               break;
            case INVERT:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty var14 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               var1 = new InvertNoiseProperty(var14);
               break;
            case OFFSET:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty var13 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               double var29 = this.has("Offset") ? this.get("Offset").getAsDouble() : 0.0;
               double var6 = this.has("OffsetX") ? this.get("OffsetX").getAsDouble() : var29;
               double var8 = this.has("OffsetY") ? this.get("OffsetY").getAsDouble() : var29;
               double var10 = this.has("OffsetZ") ? this.get("OffsetZ").getAsDouble() : var29;
               var1 = new OffsetNoiseProperty(var13, var6, var8, var10);
               break;
            case ROTATE:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               if (!this.has("Rotate")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty var12 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               CoordinateRotator var4 = new CoordinateRotatorJsonLoader<>(this.seed, this.dataFolder, this.get("Rotate")).load();
               var1 = new RotateNoiseProperty(var12, var4);
               break;
            case GRADIENT:
               if (!this.has("Noise")) {
                  throw new IllegalStateException("Could not find noise map data. Keyword: Noise");
               }

               NoiseProperty var3 = new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
               var1 = new GradientNoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.json, var3).load();
               break;
            case CURVE:
               var1 = new CurveNoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.json, null).load();
               break;
            case BLEND:
               var1 = new BlendNoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.json).load();
               break;
            class="kw">default:
               throw new Error(String.format("Could not find instructions for noise property type: %s", var2));
         }
      } else {
         NoiseFunction var23 = this.newNoiseFunctionJsonLoader(this.seed, this.dataFolder, this.json).load();
         if (this.has("Octaves")) {
            FractalNoiseProperty.FractalMode var34 = this.has("FractalMode")
               ? FractalNoiseProperty.FractalMode.valueOf(this.get("FractalMode").getAsString())
               : NoisePropertyJsonLoader.Constants.DEFAULT_FRACTAL_MODE;
            int var35 = this.get("Octaves").getAsInt();
            double var38 = this.has("Lacunarity") ? this.get("Lacunarity").getAsDouble() : 2.0;
            double var39 = this.has("Persistence") ? this.get("Persistence").getAsDouble() : 0.5;
            var1 = new FractalNoiseProperty(this.loadSeed(), var23, var34.getFunction(), var35, var38, var39);
         } else {
            var1 = new SingleNoiseProperty(this.loadSeed(), var23);
         }
      }

      if (var2 != NoisePropertyType.FORMULA && this.has("Formula")) {
         NoiseFormulaProperty.NoiseFormula var24 = NoiseFormulaProperty.NoiseFormula.valueOf(this.get("Formula").getAsString());
         var1 = new NoiseFormulaProperty(var1, var24.getFormula());
      }

      if (var2 != NoisePropertyType.CURVE && this.has("Curve")) {
         var1 = new CurveNoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Curve"), var1).load();
      }

      if (var2 != NoisePropertyType.SCALE && this.has("Scale")) {
         double var25 = this.get("Scale").getAsDouble();
         var1 = new ScaleNoiseProperty(var1, var25);
      }

      if (var2 != NoisePropertyType.NORMALIZE && this.has("Normalize") && var2 != NoisePropertyType.GRADIENT) {
         IDoubleRange var26 = new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get("Normalize")).load();
         var1 = new NormalizeNoiseProperty(var1, var26.getValue(0.0), var26.getValue(1.0) - var26.getValue(0.0));
      }

      if (var2 != NoisePropertyType.OFFSET && (this.has("Offset") || this.has("OffsetX") || this.has("OffsetY") || this.has("OffsetZ"))) {
         double var27 = this.has("Offset") ? this.get("Offset").getAsDouble() : 0.0;
         double var36 = this.has("OffsetX") ? this.get("OffsetX").getAsDouble() : var27;
         double var7 = this.has("OffsetY") ? this.get("OffsetY").getAsDouble() : var27;
         double var9 = this.has("OffsetZ") ? this.get("OffsetZ").getAsDouble() : var27;
         var1 = new OffsetNoiseProperty(var1, var36, var7, var9);
      }

      if (var2 != NoisePropertyType.ROTATE && (this.has("Pitch") || this.has("Yaw"))) {
         CoordinateRotator var28 = new CoordinateRotatorJsonLoader<>(this.seed, this.dataFolder, this.json).load();
         var1 = new RotateNoiseProperty(var1, var28);
      }

      if (var2 != NoisePropertyType.GRADIENT && this.has("Gradient")) {
         var1 = new GradientNoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Gradient"), var1).load();
      }

      class="kw">return var1;
   }

   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 NoiseProperty[] loadNoiseProperties(@Nonnull JsonElement var1) {
      if (!var1.isJsonArray()) {
         class="kw">return new NoiseProperty[0];
      }

      JsonArray var2 = var1.getAsJsonArray();
      NoiseProperty[] var3 = new NoiseProperty[var2.size()];

      for (int var4 = 0; var4 < var3.length; var4++) {
         var3[var4] = new NoisePropertyJsonLoader<>(this.seed.append(String.format("-#%s", var4)), this.dataFolder, var2.get(var4)).load();
      }

      class="kw">return var3;
   }

   class="kw">protected double[] loadDoubleArray(@Nullable JsonElement var1, int var2) {
      double[] var3 = new double[var2];
      if (var1 == null || var1.isJsonNull()) {
         Arrays.fill(var3, 1.0 / var2);
      } else if (var1.isJsonArray()) {
         JsonArray var4 = var1.getAsJsonArray();

         for (int var5 = 0; var5 < var2; var5++) {
            var3[var5] = var4.get(var5).getAsDouble();
         }
      }

      class="kw">return var3;
   }

   @Nonnull
   class="kw">protected NoiseFunctionJsonLoader newNoiseFunctionJsonLoader(@Nonnull SeedString<K> var1, Path var2, JsonElement var3) {
      class="kw">return new NoiseFunctionJsonLoader<>(var1, var2, var3);
   }

   class="kw">public class="kw">interface Constants {
      String KEY_SEED = "Seed";
      String KEY_SUM_FACTORS = "Factors";
      String KEY_NORMALIZE_RANGE = "Range";
      String KEY_DISTORTED_RANDOMIZER = "Randomizer";
      String KEY_TYPE = "Type";
      String KEY_NOISE = "Noise";
      String KEY_FRACTAL_MODE = "FractalMode";
      String KEY_OCTAVES = "Octaves";
      String KEY_LACUNARITY = "Lacunarity";
      String KEY_PERSISTENCE = "Persistence";
      String KEY_FORMULA = "Formula";
      String KEY_CURVE = "Curve";
      String KEY_SCALE = "Scale";
      String KEY_NORMALIZE = "Normalize";
      String KEY_OFFSET = "Offset";
      String KEY_OFFSET_X = "OffsetX";
      String KEY_OFFSET_Y = "OffsetY";
      String KEY_OFFSET_Z = "OffsetZ";
      String KEY_GRADIENT = "Gradient";
      String ERROR_NO_NOISE = "Could not find noise map data. Keyword: Noise";
      String ERROR_SUM_NO_FACTORS = "Could not find factors for sum composed noise map. Keyword: Factors";
      String ERROR_NO_FORMULA = "Could not find formula type for noise map. Keyword: Formula";
      String ERROR_NO_SCALE = "Could not find scale data for scaled noise map. Keyword: Scale";
      String ERROR_DISTORTED_RANDOMIZER = "Could not find randomizer for distorted noise map. Keyword: Randomizer";
      String ERROR_NORMALIZE_NO_RANGE = "Could not find range data for normalized noise map. Keyword: Range";
      String ERROR_UNKOWN_TYPE = "Could not find instructions for noise property type: %s";
      FractalNoiseProperty.FractalMode DEFAULT_FRACTAL_MODE = FractalNoiseProperty.FractalMode.FBM;
      double DEFAULT_LACUNARITY = 2.0;
      double DEFAULT_PERSISTENCE = 0.5;
   }
}