MeshNoiseJsonLoader class

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

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

extends: AbstractCellJitterJsonLoader<K, NoiseFunction>

Поля (11)

МодификаторыТипИмя
boolean DEFAULT_LINES_X
boolean DEFAULT_LINES_Y
boolean DEFAULT_LINES_Z
String ERROR_NO_THICKNESS
String KEY_LINES_X
String KEY_LINES_Y
String KEY_LINES_Z
String KEY_THICKNESS
double var1
CellType var1
var1

Методы (7)

МодификаторыВозвратСигнатура
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Could not find thickness. Keyword: Thickness")
public NoiseFunction loadNoiseFunction load()
protected boolean loadLinesFlagboolean loadLinesFlag(String var1, boolean var2)
protected boolean loadLinesXboolean loadLinesX()
protected boolean loadLinesYboolean loadLinesY()
protected boolean loadLinesZboolean loadLinesZ()
protected double loadThicknessdouble loadThickness()

Исходный код

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

class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.NoiseFunction;
class="kw">import com.hypixel.hytale.procedurallib.condition.DoubleThresholdCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.logic.HexMeshNoise;
class="kw">import com.hypixel.hytale.procedurallib.logic.MeshNoise;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.CellType;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.evaluator.DensityPointEvaluator;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;

class="kw">public class MeshNoiseJsonLoader<K class="kw">extends SeedResource> class="kw">extends AbstractCellJitterJsonLoader<K, NoiseFunction> {
   class="kw">public MeshNoiseJsonLoader(@Nonnull SeedString<K> var1, Path var2, JsonElement var3) {
      super(var1.append(".MeshNoise"), var2, var3);
   }

   class="kw">public NoiseFunction load() {
      class="kw">return class="kw">switch (this.loadCellType()) {
         case SQUARE -> this.loadGridMeshNoise();
         case HEX -> this.loadHexMeshNoise();
      };
   }

   @Nonnull
   class="kw">protected MeshNoise loadGridMeshNoise() {
      double var1 = this.loadDefaultJitter();
      class="kw">return new MeshNoise(this.loadDensity(), this.loadThickness(), this.loadJitterX(var1), this.loadJitterY(var1));
   }

   @Nonnull
   class="kw">protected HexMeshNoise loadHexMeshNoise() {
      class="kw">return new HexMeshNoise(this.loadDensity(), this.loadThickness(), this.loadJitter(), this.loadLinesX(), this.loadLinesY(), this.loadLinesZ());
   }

   @Nonnull
   class="kw">protected CellType loadCellType() {
      CellType var1 = CellNoiseJsonLoader.Constants.DEFAULT_CELL_TYPE;
      if (this.has("CellType")) {
         var1 = CellType.valueOf(this.get("CellType").getAsString());
      }

      class="kw">return var1;
   }

   class="kw">protected double loadThickness() {
      if (!this.has("Thickness")) {
         throw new IllegalStateException("Could not find thickness. Keyword: Thickness");
      } else {
         class="kw">return this.get("Thickness").getAsDouble();
      }
   }

   @Nonnull
   class="kw">protected IIntCondition loadDensity() {
      class="kw">return DensityPointEvaluator.getDensityCondition(
         this.has("Density") ? new DoubleThresholdCondition(new DoubleThresholdJsonLoader<>(this.seed, this.dataFolder, this.get("Density")).load()) : null
      );
   }

   class="kw">protected boolean loadLinesX() {
      class="kw">return this.loadLinesFlag("LinesX", true);
   }

   class="kw">protected boolean loadLinesY() {
      class="kw">return this.loadLinesFlag("LinesY", true);
   }

   class="kw">protected boolean loadLinesZ() {
      class="kw">return this.loadLinesFlag("LinesZ", true);
   }

   class="kw">protected boolean loadLinesFlag(String var1, boolean var2) {
      class="kw">return !this.has(var1) ? var2 : this.get(var1).getAsBoolean();
   }

   class="kw">public class="kw">interface Constants {
      String KEY_THICKNESS = "Thickness";
      String KEY_LINES_X = "LinesX";
      String KEY_LINES_Y = "LinesY";
      String KEY_LINES_Z = "LinesZ";
      String ERROR_NO_THICKNESS = "Could not find thickness. Keyword: Thickness";
      boolean DEFAULT_LINES_X = true;
      boolean DEFAULT_LINES_Y = true;
      boolean DEFAULT_LINES_Z = true;
   }
}