Constants interface
Пакет: com.hypixel.hytale.procedurallib.json
Файл: com/hypixel/hytale/procedurallib/json/NoiseHeightThresholdInterpreterJsonLoader.java
Поля (6)
| Модификаторы | Тип | Имя |
|---|---|---|
|
String |
ERROR_NO_KEYS |
|
String |
ERROR_NO_NOISE |
|
String |
ERROR_NO_THRESHOLDS |
|
String |
KEY_KEYS |
|
String |
KEY_NOISE |
|
String |
KEY_THRESHOLDS |
Исходный код
Показать/скрыть
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.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.procedurallib.condition.IHeightThresholdInterpreter;
class="kw">import com.hypixel.hytale.procedurallib.condition.NoiseHeightThresholdInterpreter;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class NoiseHeightThresholdInterpreterJsonLoader<K class="kw">extends SeedResource> class="kw">extends JsonLoader<K, NoiseHeightThresholdInterpreter> {
class="kw">protected class="kw">final int length;
class="kw">public NoiseHeightThresholdInterpreterJsonLoader(@Nonnull SeedString<K> var1, Path var2, JsonElement var3, int var4) {
super(var1.append(".NoiseHeightThresholdInterpreter"), var2, var3);
this.length = var4;
}
@Nonnull
class="kw">public NoiseHeightThresholdInterpreter load() {
IHeightThresholdInterpreter[] var1 = this.loadInterpreters();
float[] var2 = this.loadKeys();
if (var2.length != var1.length) {
throw new IllegalArgumentException("Keys and Thresholds array do not have the same length!");
} else {
class="kw">return new NoiseHeightThresholdInterpreter(this.loadNoise(), var2, var1);
}
}
@Nullable
class="kw">protected NoiseProperty loadNoise() {
if (!this.has("Noise")) {
throw new IllegalStateException("Could not find noise map data in NoiseHeightThresholdInterpreter. Keyword: Noise");
} else {
class="kw">return new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("Noise")).load();
}
}
@Nonnull
class="kw">protected IHeightThresholdInterpreter[] loadInterpreters() {
if (!this.has("Thresholds")) {
throw new IllegalStateException("Could not find threshold data in NoiseHeightThresholdInterpreter. Keyword: Thresholds");
}
JsonArray var1 = this.get("Thresholds").getAsJsonArray();
IHeightThresholdInterpreter[] var2 = new IHeightThresholdInterpreter[var1.size()];
for (int var3 = 0; var3 < var2.length; var3++) {
var2[var3] = new HeightThresholdInterpreterJsonLoader<>(this.seed.append("-" + var3), this.dataFolder, var1.get(var3), this.length).load();
}
class="kw">return var2;
}
class="kw">protected float[] loadKeys() {
if (!this.has("Keys")) {
throw new IllegalStateException("Could not find key data in NoiseHeightThresholdInterpreter. Keyword: Keys");
}
JsonArray var1 = this.get("Keys").getAsJsonArray();
float[] var2 = new float[var1.size()];
for (int var3 = 0; var3 < var2.length; var3++) {
var2[var3] = var1.get(var3).getAsFloat();
}
class="kw">return var2;
}
class="kw">public class="kw">static boolean shouldHandle(@Nonnull JsonObject var0) {
class="kw">return var0.has("Thresholds");
}
class="kw">public class="kw">interface Constants {
String KEY_NOISE = "Noise";
String KEY_THRESHOLDS = "Thresholds";
String KEY_KEYS = "Keys";
String ERROR_NO_NOISE = "Could not find noise map data in NoiseHeightThresholdInterpreter. Keyword: Noise";
String ERROR_NO_THRESHOLDS = "Could not find threshold data in NoiseHeightThresholdInterpreter. Keyword: Thresholds";
String ERROR_NO_KEYS = "Could not find key data in NoiseHeightThresholdInterpreter. Keyword: Keys";
}
}