BiomeInterpolationJsonLoader class
Пакет: com.hypixel.hytale.server.worldgen.loader.biome
Файл: com/hypixel/hytale/server/worldgen/loader/biome/BiomeInterpolationJsonLoader.java
extends: JsonLoader<SeedStringResource, BiomeInterpolation>
Поля (24)
| Модификаторы | Тип | Имя |
|---|---|---|
|
String |
ERROR_BIOME_RADIUS |
|
String |
ERROR_DEFAULT_RADIUS |
|
String |
ERROR_DUPLICATE_BIOME |
|
String |
ERROR_INVALID_BIOME_ENTRY |
|
String |
ERROR_INVALID_BIOME_LIST |
|
String |
ERROR_MISSING_PROPERTY |
|
String |
KEY_BIOMES |
|
String |
KEY_DEFAULT_RADIUS |
|
String |
KEY_MASK |
|
String |
KEY_RADIUS |
|
String |
SEED_OFFSET_MASK |
|
int |
var1 |
|
int |
var1 |
|
Int2IntMap |
var2 |
|
JsonElement |
var2 |
|
int |
var2 |
|
Int2IntOpenHashMap |
var3 |
|
int |
var3 |
|
int |
var4 |
|
IntSet |
var4 |
|
IIntCondition |
var5 |
|
IntIterator |
var5 |
|
int |
var6 |
final |
ZoneFileContext |
zoneFileContext |
Методы (14)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
Errorthrow new Error("Invalid json-type for Biomes property. Must be an array!") |
abstract |
throw new |
Errorthrow new Error("Invalid json-type for biome entry. Must be an object!") |
abstract |
throw new |
Errorthrow new Error("Duplicate biome detected in interpolation rules") |
static |
void |
addBiomesvoid addBiomes(IIntCondition var0, int var1, @Nonnull Int2IntMap var2) |
abstract |
|
addBiomes addBiomes(var5, var4, var3) |
|
|
if if(var1 >= 0 && var1 <= 5) |
|
|
if if(var4 != var2) |
|
|
if if(var2 >= 0 && var2 <= var1) |
|
|
if if(var0 instanceof HashSetIntCondition) |
public |
BiomeInterpolation |
loadBiomeInterpolation load() |
protected |
void |
loadBiomeEntryvoid loadBiomeEntry(@Nonnull JsonElement var1, int var2, @Nonnull Int2IntMap var3) |
static |
int |
loadBiomeRadiusint loadBiomeRadius(@Nonnull JsonObject var0, int var1) |
protected |
int |
loadDefaultRadiusint loadDefaultRadius() |
abstract |
|
super super(var1, var2, var3) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.biome;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.procedurallib.condition.IIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.biome.BiomeInterpolation;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.ZoneFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.HashSetIntCondition;
class="kw">import it.unimi.dsi.fastutil.ints.Int2IntMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.ints.IntIterator;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class BiomeInterpolationJsonLoader class="kw">extends JsonLoader<SeedStringResource, BiomeInterpolation> {
class="kw">protected class="kw">final ZoneFileContext zoneFileContext;
class="kw">public BiomeInterpolationJsonLoader(SeedString<SeedStringResource> var1, Path var2, JsonElement var3, ZoneFileContext var4) {
super(var1, var2, var3);
this.zoneFileContext = var4;
}
class="kw">public BiomeInterpolation load() {
int var1 = this.loadDefaultRadius();
Int2IntMap var2 = this.loadBiomeRadii(var1);
class="kw">return BiomeInterpolation.create(var1, var2);
}
class="kw">protected int loadDefaultRadius() {
if (!this.has("DefaultRadius")) {
class="kw">return 5;
} else {
int var1 = this.get("DefaultRadius").getAsInt();
if (var1 >= 0 && var1 <= 5) {
class="kw">return var1;
} else {
throw new Error(String.format("Default biome interpolation radius %s lies outside the range 0-5", var1));
}
}
}
@Nonnull
class="kw">protected Int2IntMap loadBiomeRadii(int var1) {
if (!this.has("Biomes")) {
class="kw">return BiomeInterpolation.EMPTY_MAP;
}
JsonElement var2 = this.get("Biomes");
if (!var2.isJsonArray()) {
throw new Error("Invalid json-type for Biomes property. Must be an array!");
}
Int2IntOpenHashMap var3 = new Int2IntOpenHashMap();
for (JsonElement var5 : var2.getAsJsonArray()) {
this.loadBiomeEntry(var5, var1, var3);
}
class="kw">return var3;
}
class="kw">protected void loadBiomeEntry(@Nonnull JsonElement var1, int var2, @Nonnull Int2IntMap var3) {
if (!var1.isJsonObject()) {
throw new Error("Invalid json-type for biome entry. Must be an object!");
}
int var4 = loadBiomeRadius(var1.getAsJsonObject(), var2);
if (var4 != var2) {
IIntCondition var5 = this.loadBiomeMask(var1.getAsJsonObject());
addBiomes(var5, var4, var3);
}
}
@Nullable
class="kw">protected IIntCondition loadBiomeMask(@Nonnull JsonObject var1) {
if (!var1.has("Mask")) {
throw new Error(String.format("Missing property %s", "Mask"));
} else {
class="kw">return new BiomeMaskJsonLoader(this.seed, this.dataFolder, var1.get("Mask"), "InterpolationMask", this.zoneFileContext).load();
}
}
class="kw">protected class="kw">static int loadBiomeRadius(@Nonnull JsonObject var0, int var1) {
if (!var0.has("Radius")) {
throw new Error(String.format("Missing property %s", "Radius"));
} else {
int var2 = var0.get("Radius").getAsInt();
if (var2 >= 0 && var2 <= var1) {
class="kw">return var2;
} else {
throw new Error(String.format("Biome interpolation radius %s is outside the range 0-%s", var2, var1));
}
}
}
class="kw">protected class="kw">static void addBiomes(IIntCondition var0, int var1, @Nonnull Int2IntMap var2) {
if (var0 class="kw">instanceof HashSetIntCondition) {
int var3 = var1 * var1;
IntSet var4 = ((HashSetIntCondition)var0).getSet();
IntIterator var5 = var4.iterator();
while (var5.hasNext()) {
int var6 = (Integer)var5.next();
if (var2.containsKey(var6)) {
throw new Error("Duplicate biome detected in interpolation rules");
}
var2.put(var6, var3);
}
}
}
class="kw">public class="kw">interface Constants {
String KEY_DEFAULT_RADIUS = "DefaultRadius";
String KEY_RADIUS = "Radius";
String KEY_BIOMES = "Biomes";
String KEY_MASK = "Mask";
String SEED_OFFSET_MASK = "InterpolationMask";
String ERROR_MISSING_PROPERTY = "Missing property %s";
String ERROR_INVALID_BIOME_LIST = "Invalid json-type for Biomes property. Must be an array!";
String ERROR_INVALID_BIOME_ENTRY = "Invalid json-type for biome entry. Must be an object!";
String ERROR_DUPLICATE_BIOME = "Duplicate biome detected in interpolation rules";
String ERROR_BIOME_RADIUS = "Biome interpolation radius %s is outside the range 0-%s";
String ERROR_DEFAULT_RADIUS = "Default biome interpolation radius %s lies outside the range 0-5";
}
}