ZoneBiomesJsonLoader class
Пакет: com.hypixel.hytale.server.worldgen.loader.zone
Файл: com/hypixel/hytale/server/worldgen/loader/zone/ZoneBiomesJsonLoader.java
extends: JsonLoader<SeedStringResource, IWeightedMap<TileBiome>>
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
|
String |
ERROR_BIOME_FAILED |
|
String |
ERROR_BIOME_FILES_NULL |
|
String |
ERROR_NO_TILE_BIOMES |
|
String |
FILE_TILE_PREFIX |
|
String |
FILE_TILE_SUFFIX |
|
WeightedMap.Builder |
var1 |
|
JsonElement |
var2 |
|
TileBiome |
var4 |
final |
ZoneFileContext |
zoneContext |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Could not find any tile biomes for this zone!") |
public |
IWeightedMap<TileBiome> |
loadIWeightedMap<TileBiome> load() |
abstract |
|
super super(var1, var2, var3) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.zone;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.common.map.IWeightedMap;
class="kw">import com.hypixel.hytale.common.map.WeightedMap;
class="kw">import com.hypixel.hytale.procedurallib.file.FileIO;
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.TileBiome;
class="kw">import com.hypixel.hytale.server.worldgen.loader.biome.TileBiomeJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.BiomeFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.ZoneFileContext;
class="kw">import java.nio.file.Path;
class="kw">import java.util.Map.Entry;
class="kw">import javax.annotation.Nonnull;
class="kw">public class ZoneBiomesJsonLoader class="kw">extends JsonLoader<SeedStringResource, IWeightedMap<TileBiome>> {
class="kw">protected class="kw">final ZoneFileContext zoneContext;
class="kw">public ZoneBiomesJsonLoader(SeedString<SeedStringResource> var1, Path var2, JsonElement var3, ZoneFileContext var4) {
super(var1, var2, var3);
this.zoneContext = var4;
}
class="kw">public IWeightedMap<TileBiome> load() {
WeightedMap.Builder var1 = WeightedMap.builder(TileBiome.EMPTY_ARRAY);
for (Entry var3 : this.zoneContext.getTileBiomes()) {
TileBiome var4 = this.loadBiome(var3.getValue());
var1.put(var4, var4.getWeight());
}
if (var1.size() <= 0) {
throw new IllegalArgumentException("Could not find any tile biomes for this zone!");
} else {
class="kw">return var1.build();
}
}
@Nonnull
class="kw">protected TileBiome loadBiome(@Nonnull BiomeFileContext var1) {
try {
JsonElement var2 = (JsonElement)FileIO.load(var1.getPath(), JsonLoader.JSON_OBJ_LOADER);
class="kw">return new TileBiomeJsonLoader(this.seed, this.dataFolder, var2, var1).load();
} catch (Throwable var3) {
throw new Error(String.format("Error while loading tile biome \"%s\" from \"%s\"", var1.getName(), var1.getPath().toString()), var3);
}
}
class="kw">public class="kw">interface Constants {
String ERROR_BIOME_FILES_NULL = "Biome files error occured.";
String ERROR_BIOME_FAILED = "Error while loading tile biome \"%s\" from \"%s\"";
String ERROR_NO_TILE_BIOMES = "Could not find any tile biomes for this zone!";
String FILE_TILE_PREFIX = "Tile.";
String FILE_TILE_SUFFIX = ".json";
}
}