CustomBiomeGeneratorJsonLoader class
Пакет: com.hypixel.hytale.server.worldgen.loader.biome
Файл: com/hypixel/hytale/server/worldgen/loader/biome/CustomBiomeGeneratorJsonLoader.java
extends: JsonLoader<SeedStringResource, CustomBiomeGenerator>
Поля (13)
| Модификаторы | Тип | Имя |
|---|---|---|
|
String |
ERROR_BIOME_ERROR_MASK |
|
String |
KEY_BIOME_MASK |
|
String |
KEY_NOISE_MASK |
|
String |
KEY_PRIORITY |
final |
BiomeFileContext |
biomeContext |
|
IIntCondition |
var1 |
|
|
var1 |
|
Map |
var1 |
|
Map |
var2 |
|
JsonArray |
var3 |
|
IntSet |
var4 |
|
String |
var6 |
|
Biome |
var7 |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(Biome var5 : this.tileBiomes) |
abstract |
|
for for(int var5 = 0; var5 < var3.size() |
protected |
int |
loadPriorityint loadPriority() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.biome;
class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IDoubleThreshold;
class="kw">import com.hypixel.hytale.procedurallib.condition.IIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.DoubleThresholdJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.NoisePropertyJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.biome.Biome;
class="kw">import com.hypixel.hytale.server.worldgen.biome.CustomBiomeGenerator;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.BiomeFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.HashSetIntCondition;
class="kw">import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.nio.file.Path;
class="kw">import java.util.HashMap;
class="kw">import java.util.Map;
class="kw">import java.util.Objects;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class CustomBiomeGeneratorJsonLoader class="kw">extends JsonLoader<SeedStringResource, CustomBiomeGenerator> {
class="kw">protected class="kw">final BiomeFileContext biomeContext;
class="kw">protected class="kw">final Biome[] tileBiomes;
class="kw">public CustomBiomeGeneratorJsonLoader(@Nonnull SeedString<SeedStringResource> var1, Path var2, JsonElement var3, BiomeFileContext var4, Biome[] var5) {
super(var1.append(".CustomBiomeGenerator"), var2, var3);
this.biomeContext = var4;
this.tileBiomes = var5;
}
@Nonnull
class="kw">public CustomBiomeGenerator load() {
class="kw">return new CustomBiomeGenerator(this.loadNoiseProperty(), this.loadNoiseThreshold(), this.loadBiomeMask(), this.loadPriority());
}
@Nullable
class="kw">protected NoiseProperty loadNoiseProperty() {
class="kw">return new NoisePropertyJsonLoader<>(this.seed, this.dataFolder, this.get("NoiseMask")).load();
}
@Nonnull
class="kw">protected IDoubleThreshold loadNoiseThreshold() {
class="kw">return new DoubleThresholdJsonLoader<>(this.seed, this.dataFolder, this.get("NoiseMask").getAsJsonObject().get("Threshold")).load();
}
@Nonnull
class="kw">protected IIntCondition loadBiomeMask() {
IIntCondition var1 = ConstantIntCondition.DEFAULT_TRUE;
if (this.has("BiomeMask")) {
Map var2 = this.generateNameBiomeMapping();
JsonArray var3 = this.get("BiomeMask").getAsJsonArray();
IntSet var4 = new IntOpenHashSet(var3.size());
for (int var5 = 0; var5 < var3.size(); var5++) {
String var6 = var3.get(var5).getAsString();
Biome var7 = var2.get(var6);
Objects.requireNonNull(var7, var6);
var4.add(var7.getId());
}
var1 = new HashSetIntCondition(var4);
}
class="kw">return var1;
}
@Nonnull
class="kw">protected Map<String, Biome> generateNameBiomeMapping() {
Map var1 = new HashMap<>();
for (Biome var5 : this.tileBiomes) {
var1.put(var5.getName(), var5);
}
class="kw">return var1;
}
class="kw">protected int loadPriority() {
class="kw">return this.has("Priority") ? this.get("Priority").getAsInt() : 0;
}
class="kw">public class="kw">interface Constants {
String KEY_NOISE_MASK = "NoiseMask";
String KEY_BIOME_MASK = "BiomeMask";
String KEY_PRIORITY = "Priority";
String ERROR_BIOME_ERROR_MASK = "Could not find tile biome \"%s\" for biome mask. Typo or disabled tile biome?";
}
}