mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-10 05:39:11 +01:00
Modernize biome types
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
ba77a9ea10
commit
9198252dc1
@ -1,18 +1,15 @@
|
||||
package net.minestom.server.world.biomes;
|
||||
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Biome {
|
||||
|
||||
public final class Biome {
|
||||
public static final AtomicInteger ID_COUNTER = new AtomicInteger(0);
|
||||
|
||||
private static final BiomeEffects DEFAULT_EFFECTS = BiomeEffects.builder()
|
||||
.fogColor(0xC0D8FF)
|
||||
.skyColor(0x78A7FF)
|
||||
@ -41,9 +38,9 @@ public class Biome {
|
||||
private final Category category;
|
||||
private final BiomeEffects effects;
|
||||
private final Precipitation precipitation;
|
||||
private final TemperatureModifier temperature_modifier;
|
||||
private final TemperatureModifier temperatureModifier;
|
||||
|
||||
Biome(NamespaceID name, float depth, float temperature, float scale, float downfall, Category category, BiomeEffects effects, Precipitation precipitation, TemperatureModifier temperature_modifier) {
|
||||
Biome(NamespaceID name, float depth, float temperature, float scale, float downfall, Category category, BiomeEffects effects, Precipitation precipitation, TemperatureModifier temperatureModifier) {
|
||||
this.name = name;
|
||||
this.depth = depth;
|
||||
this.temperature = temperature;
|
||||
@ -52,127 +49,90 @@ public class Biome {
|
||||
this.category = category;
|
||||
this.effects = effects;
|
||||
this.precipitation = precipitation;
|
||||
this.temperature_modifier = temperature_modifier;
|
||||
this.temperatureModifier = temperatureModifier;
|
||||
}
|
||||
|
||||
public static BiomeBuilder builder() {
|
||||
return new BiomeBuilder();
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NBTCompound toNbt() {
|
||||
public @NotNull NBTCompound toNbt() {
|
||||
Check.notNull(name, "The biome namespace cannot be null");
|
||||
Check.notNull(effects, "The biome effects cannot be null");
|
||||
|
||||
NBTCompound nbt = new NBTCompound();
|
||||
nbt.setString("name", name.toString());
|
||||
nbt.setInt("id", getId());
|
||||
nbt.setInt("id", id());
|
||||
|
||||
NBTCompound element = new NBTCompound();
|
||||
element.setFloat("depth", depth);
|
||||
element.setFloat("temperature", temperature);
|
||||
element.setFloat("scale", scale);
|
||||
element.setFloat("downfall", downfall);
|
||||
element.setString("category", category.getType());
|
||||
element.setString("precipitation", precipitation.getType());
|
||||
if (temperature_modifier != TemperatureModifier.NONE)
|
||||
element.setString("temperature_modifier", temperature_modifier.getType());
|
||||
element.setString("category", category.name().toLowerCase(Locale.ROOT));
|
||||
element.setString("precipitation", precipitation.name().toLowerCase(Locale.ROOT));
|
||||
if (temperatureModifier != TemperatureModifier.NONE)
|
||||
element.setString("temperature_modifier", temperatureModifier.name().toLowerCase(Locale.ROOT));
|
||||
element.set("effects", effects.toNbt());
|
||||
nbt.set("element", element);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public int id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public NamespaceID getName() {
|
||||
public NamespaceID name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public float getDepth() {
|
||||
public float depth() {
|
||||
return this.depth;
|
||||
}
|
||||
|
||||
public float getTemperature() {
|
||||
public float temperature() {
|
||||
return this.temperature;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
public float scale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public float getDownfall() {
|
||||
public float downfall() {
|
||||
return this.downfall;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
public Category category() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public BiomeEffects getEffects() {
|
||||
public BiomeEffects effects() {
|
||||
return this.effects;
|
||||
}
|
||||
|
||||
public Precipitation getPrecipitation() {
|
||||
public Precipitation precipitation() {
|
||||
return this.precipitation;
|
||||
}
|
||||
|
||||
public TemperatureModifier getTemperature_modifier() {
|
||||
return this.temperature_modifier;
|
||||
public TemperatureModifier temperatureModifier() {
|
||||
return this.temperatureModifier;
|
||||
}
|
||||
|
||||
public enum Precipitation {
|
||||
RAIN("rain"), NONE("none"), SNOW("snow");
|
||||
|
||||
String type;
|
||||
|
||||
Precipitation(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
RAIN, NONE, SNOW;
|
||||
}
|
||||
|
||||
public enum Category {
|
||||
NONE("none"), TAIGA("taiga"), EXTREME_HILLS("extreme_hills"), JUNGLE("jungle"), MESA("mesa"), PLAINS("plains"),
|
||||
SAVANNA("savanna"), ICY("icy"), THE_END("the_end"), BEACH("beach"), FOREST("forest"), OCEAN("ocean"),
|
||||
DESERT("desert"), RIVER("river"), SWAMP("swamp"), MUSHROOM("mushroom"), NETHER("nether");
|
||||
|
||||
String type;
|
||||
|
||||
Category(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
NONE, TAIGA, EXTREME_HILLS, JUNGLE, MESA, PLAINS,
|
||||
SAVANNA, ICY, THE_END, BEACH, FOREST, OCEAN,
|
||||
DESERT, RIVER, SWAMP, MUSHROOM, NETHER;
|
||||
}
|
||||
|
||||
public enum TemperatureModifier {
|
||||
NONE("none"), FROZEN("frozen");
|
||||
|
||||
String type;
|
||||
|
||||
TemperatureModifier(String type) {
|
||||
this.type = type;
|
||||
NONE, FROZEN;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBiomeCount(DimensionType dimensionType) {
|
||||
final int height = dimensionType.getLogicalHeight();
|
||||
return 4 * 4 * 4 * (height / Chunk.CHUNK_SECTION_SIZE);
|
||||
}
|
||||
|
||||
public static class BiomeBuilder {
|
||||
|
||||
public static final class Builder {
|
||||
private NamespaceID name;
|
||||
private float depth = 0.2f;
|
||||
private float temperature = 0.25f;
|
||||
@ -183,50 +143,50 @@ public class Biome {
|
||||
private Precipitation precipitation = Precipitation.RAIN;
|
||||
private TemperatureModifier temperatureModifier = TemperatureModifier.NONE;
|
||||
|
||||
BiomeBuilder() {
|
||||
Builder() {
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder name(NamespaceID name) {
|
||||
public Builder name(NamespaceID name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder depth(float depth) {
|
||||
public Builder depth(float depth) {
|
||||
this.depth = depth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder temperature(float temperature) {
|
||||
public Builder temperature(float temperature) {
|
||||
this.temperature = temperature;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder scale(float scale) {
|
||||
public Builder scale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder downfall(float downfall) {
|
||||
public Builder downfall(float downfall) {
|
||||
this.downfall = downfall;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder category(Category category) {
|
||||
public Builder category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder effects(BiomeEffects effects) {
|
||||
public Builder effects(BiomeEffects effects) {
|
||||
this.effects = effects;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder precipitation(Precipitation precipitation) {
|
||||
public Builder precipitation(Precipitation precipitation) {
|
||||
this.precipitation = precipitation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Biome.BiomeBuilder temperatureModifier(TemperatureModifier temperatureModifier) {
|
||||
public Builder temperatureModifier(TemperatureModifier temperatureModifier) {
|
||||
this.temperatureModifier = temperatureModifier;
|
||||
return this;
|
||||
}
|
||||
|
@ -1,154 +1,50 @@
|
||||
package net.minestom.server.world.biomes;
|
||||
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
public class BiomeEffects {
|
||||
import java.util.Locale;
|
||||
|
||||
private final int fog_color;
|
||||
private final int sky_color;
|
||||
private final int water_color;
|
||||
private final int water_fog_color;
|
||||
public record BiomeEffects(int fogColor, int skyColor, int waterColor, int waterFogColor, int foliageColor,
|
||||
int grassColor,
|
||||
GrassColorModifier grassColorModifier, BiomeParticles biomeParticles,
|
||||
NamespaceID ambientSound, MoodSound moodSound, AdditionsSound additionsSound,
|
||||
Music music) {
|
||||
|
||||
private final int foliage_color;
|
||||
private final int grass_color;
|
||||
private final GrassColorModifier grass_color_modifier;
|
||||
private final BiomeParticles biomeParticles;
|
||||
private final NamespaceID ambient_sound;
|
||||
private final MoodSound mood_sound;
|
||||
private final AdditionsSound additions_sound;
|
||||
private final Music music;
|
||||
|
||||
BiomeEffects(int fog_color, int sky_color, int water_color, int water_fog_color, int foliage_color, int grass_color, GrassColorModifier grass_color_modifier, BiomeParticles biomeParticles, NamespaceID ambient_sound, MoodSound mood_sound, AdditionsSound additions_sound, Music music) {
|
||||
this.fog_color = fog_color;
|
||||
this.sky_color = sky_color;
|
||||
this.water_color = water_color;
|
||||
this.water_fog_color = water_fog_color;
|
||||
this.foliage_color = foliage_color;
|
||||
this.grass_color = grass_color;
|
||||
this.grass_color_modifier = grass_color_modifier;
|
||||
this.biomeParticles = biomeParticles;
|
||||
this.ambient_sound = ambient_sound;
|
||||
this.mood_sound = mood_sound;
|
||||
this.additions_sound = additions_sound;
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
public static BiomeEffectsBuilder builder() {
|
||||
return new BiomeEffectsBuilder();
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public NBTCompound toNbt() {
|
||||
NBTCompound nbt = new NBTCompound();
|
||||
nbt.setInt("fog_color", fog_color);
|
||||
if (foliage_color != -1)
|
||||
nbt.setInt("foliage_color", foliage_color);
|
||||
if (grass_color != -1)
|
||||
nbt.setInt("grass_color", grass_color);
|
||||
nbt.setInt("sky_color", sky_color);
|
||||
nbt.setInt("water_color", water_color);
|
||||
nbt.setInt("water_fog_color", water_fog_color);
|
||||
if (grass_color_modifier != null)
|
||||
nbt.setString("grass_color_modifier", grass_color_modifier.getType());
|
||||
nbt.setInt("fog_color", fogColor);
|
||||
if (foliageColor != -1) nbt.setInt("foliage_color", foliageColor);
|
||||
if (grassColor != -1) nbt.setInt("grass_color", grassColor);
|
||||
nbt.setInt("sky_color", skyColor);
|
||||
nbt.setInt("water_color", waterColor);
|
||||
nbt.setInt("water_fog_color", waterFogColor);
|
||||
if (grassColorModifier != null)
|
||||
nbt.setString("grass_color_modifier", grassColorModifier.name().toLowerCase(Locale.ROOT));
|
||||
if (biomeParticles != null)
|
||||
nbt.set("particle", biomeParticles.toNbt());
|
||||
if (ambient_sound != null)
|
||||
nbt.setString("ambient_sound", ambient_sound.toString());
|
||||
if (mood_sound != null)
|
||||
nbt.set("mood_sound", mood_sound.toNbt());
|
||||
if (additions_sound != null)
|
||||
nbt.set("additions_sound", additions_sound.toNbt());
|
||||
if (ambientSound != null)
|
||||
nbt.setString("ambient_sound", ambientSound.toString());
|
||||
if (moodSound != null)
|
||||
nbt.set("mood_sound", moodSound.toNbt());
|
||||
if (additionsSound != null)
|
||||
nbt.set("additions_sound", additionsSound.toNbt());
|
||||
if (music != null)
|
||||
nbt.set("music", music.toNbt());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public int getFog_color() {
|
||||
return this.fog_color;
|
||||
}
|
||||
|
||||
public int getSky_color() {
|
||||
return this.sky_color;
|
||||
}
|
||||
|
||||
public int getWater_color() {
|
||||
return this.water_color;
|
||||
}
|
||||
|
||||
public int getWater_fog_color() {
|
||||
return this.water_fog_color;
|
||||
}
|
||||
|
||||
public int getFoliage_color() {
|
||||
return this.foliage_color;
|
||||
}
|
||||
|
||||
public int getGrass_color() {
|
||||
return this.grass_color;
|
||||
}
|
||||
|
||||
public GrassColorModifier getGrass_color_modifier() {
|
||||
return this.grass_color_modifier;
|
||||
}
|
||||
|
||||
public BiomeParticles getBiomeParticles() {
|
||||
return this.biomeParticles;
|
||||
}
|
||||
|
||||
public NamespaceID getAmbient_sound() {
|
||||
return this.ambient_sound;
|
||||
}
|
||||
|
||||
public MoodSound getMood_sound() {
|
||||
return this.mood_sound;
|
||||
}
|
||||
|
||||
public AdditionsSound getAdditions_sound() {
|
||||
return this.additions_sound;
|
||||
}
|
||||
|
||||
public Music getMusic() {
|
||||
return this.music;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "BiomeEffects(fog_color=" + this.getFog_color() + ", sky_color=" +
|
||||
this.getSky_color() + ", water_color=" + this.getWater_color() + ", water_fog_color=" +
|
||||
this.getWater_fog_color() + ", foliage_color=" + this.getFoliage_color() + ", grass_color=" +
|
||||
this.getGrass_color() + ", grass_color_modifier=" + this.getGrass_color_modifier() + ", biomeParticles=" +
|
||||
this.getBiomeParticles() + ", ambient_sound=" + this.getAmbient_sound() + ", mood_sound=" +
|
||||
this.getMood_sound() + ", additions_sound=" + this.getAdditions_sound() + ", music=" + this.getMusic() + ")";
|
||||
}
|
||||
|
||||
public enum GrassColorModifier {
|
||||
NONE("none"), DARK_FOREST("dark_forest"), SWAMP("swamp");
|
||||
|
||||
String type;
|
||||
|
||||
GrassColorModifier(String type) {
|
||||
this.type = type;
|
||||
NONE, DARK_FOREST, SWAMP;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MoodSound {
|
||||
|
||||
private final NamespaceID sound;
|
||||
private final int tickDelay;
|
||||
private final int blockSearchExtent;
|
||||
private final double offset;
|
||||
|
||||
public MoodSound(NamespaceID sound, int tickDelay, int blockSearchExtent, double offset) {
|
||||
this.sound = sound;
|
||||
this.tickDelay = tickDelay;
|
||||
this.blockSearchExtent = blockSearchExtent;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public NBTCompound toNbt() {
|
||||
public record MoodSound(NamespaceID sound, int tickDelay, int blockSearchExtent, double offset) {
|
||||
public @NotNull NBTCompound toNbt() {
|
||||
NBTCompound nbt = new NBTCompound();
|
||||
nbt.setString("sound", sound.toString());
|
||||
nbt.setInt("tick_delay", tickDelay);
|
||||
@ -156,43 +52,19 @@ public class BiomeEffects {
|
||||
nbt.setDouble("offset", offset);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class AdditionsSound {
|
||||
|
||||
private final NamespaceID sound;
|
||||
private final double tickChance;
|
||||
|
||||
public AdditionsSound(NamespaceID sound, double tickChance) {
|
||||
this.sound = sound;
|
||||
this.tickChance = tickChance;
|
||||
}
|
||||
|
||||
public NBTCompound toNbt() {
|
||||
public record AdditionsSound(NamespaceID sound, double tickChance) {
|
||||
public @NotNull NBTCompound toNbt() {
|
||||
NBTCompound nbt = new NBTCompound();
|
||||
nbt.setString("sound", sound.toString());
|
||||
nbt.setDouble("tick_chance", tickChance);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Music {
|
||||
|
||||
private final NamespaceID sound;
|
||||
private final int minDelay;
|
||||
private final int maxDelay;
|
||||
private final boolean replaceCurrentMusic;
|
||||
|
||||
public Music(NamespaceID sound, int minDelay, int maxDelay, boolean replaceCurrentMusic) {
|
||||
this.sound = sound;
|
||||
this.minDelay = minDelay;
|
||||
this.maxDelay = maxDelay;
|
||||
this.replaceCurrentMusic = replaceCurrentMusic;
|
||||
}
|
||||
|
||||
public NBTCompound toNbt() {
|
||||
public record Music(NamespaceID sound, int minDelay, int maxDelay, boolean replaceCurrentMusic) {
|
||||
public @NotNull NBTCompound toNbt() {
|
||||
NBTCompound nbt = new NBTCompound();
|
||||
nbt.setString("sound", sound.toString());
|
||||
nbt.setInt("min_delay", minDelay);
|
||||
@ -200,16 +72,13 @@ public class BiomeEffects {
|
||||
nbt.setByte("replace_current_music", replaceCurrentMusic ? (byte) 1 : (byte) 0);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class BiomeEffectsBuilder {
|
||||
|
||||
public static final class Builder {
|
||||
private int fogColor;
|
||||
private int skyColor;
|
||||
private int waterColor;
|
||||
private int waterFogColor;
|
||||
|
||||
private int foliageColor = -1;
|
||||
private int grassColor = -1;
|
||||
private GrassColorModifier grassColorModifier;
|
||||
@ -219,65 +88,65 @@ public class BiomeEffects {
|
||||
private AdditionsSound additionsSound;
|
||||
private Music music;
|
||||
|
||||
BiomeEffectsBuilder() {
|
||||
Builder() {
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder fogColor(int fogColor) {
|
||||
public Builder fogColor(int fogColor) {
|
||||
this.fogColor = fogColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder skyColor(int skyColor) {
|
||||
public Builder skyColor(int skyColor) {
|
||||
this.skyColor = skyColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder waterColor(int waterColor) {
|
||||
public Builder waterColor(int waterColor) {
|
||||
this.waterColor = waterColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder waterFogColor(int waterFogColor) {
|
||||
public Builder waterFogColor(int waterFogColor) {
|
||||
this.waterFogColor = waterFogColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder foliageColor(int foliageColor) {
|
||||
public Builder foliageColor(int foliageColor) {
|
||||
this.foliageColor = foliageColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder grassColor(int grassColor) {
|
||||
public Builder grassColor(int grassColor) {
|
||||
this.grassColor = grassColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder grassColorModifier(GrassColorModifier grassColorModifier) {
|
||||
public Builder grassColorModifier(GrassColorModifier grassColorModifier) {
|
||||
this.grassColorModifier = grassColorModifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder biomeParticles(BiomeParticles biomeParticles) {
|
||||
public Builder biomeParticles(BiomeParticles biomeParticles) {
|
||||
this.biomeParticles = biomeParticles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder ambientSound(NamespaceID ambientSound) {
|
||||
public Builder ambientSound(NamespaceID ambientSound) {
|
||||
this.ambientSound = ambientSound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder moodSound(MoodSound moodSound) {
|
||||
public Builder moodSound(MoodSound moodSound) {
|
||||
this.moodSound = moodSound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder additionsSound(AdditionsSound additionsSound) {
|
||||
public Builder additionsSound(AdditionsSound additionsSound) {
|
||||
this.additionsSound = additionsSound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeEffects.BiomeEffectsBuilder music(Music music) {
|
||||
public Builder music(Music music) {
|
||||
this.music = music;
|
||||
return this;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import java.util.Collections;
|
||||
* Contains {@link Biome#PLAINS} by default but can be removed.
|
||||
*/
|
||||
public final class BiomeManager {
|
||||
|
||||
private final Int2ObjectMap<Biome> biomes = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public BiomeManager() {
|
||||
@ -29,7 +28,7 @@ public final class BiomeManager {
|
||||
* @param biome the biome to add
|
||||
*/
|
||||
public synchronized void addBiome(Biome biome) {
|
||||
this.biomes.put(biome.getId(), biome);
|
||||
this.biomes.put(biome.id(), biome);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +37,7 @@ public final class BiomeManager {
|
||||
* @param biome the biome to remove
|
||||
*/
|
||||
public synchronized void removeBiome(Biome biome) {
|
||||
this.biomes.remove(biome.getId());
|
||||
this.biomes.remove(biome.id());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +45,7 @@ public final class BiomeManager {
|
||||
*
|
||||
* @return an immutable copy of the biomes already registered
|
||||
*/
|
||||
public Collection<Biome> unmodifiableCollection() {
|
||||
public synchronized Collection<Biome> unmodifiableCollection() {
|
||||
return Collections.unmodifiableCollection(biomes.values());
|
||||
}
|
||||
|
||||
@ -56,14 +55,14 @@ public final class BiomeManager {
|
||||
* @param id the id of the biome
|
||||
* @return the {@link Biome} linked to this id
|
||||
*/
|
||||
public Biome getById(int id) {
|
||||
public synchronized Biome getById(int id) {
|
||||
return biomes.get(id);
|
||||
}
|
||||
|
||||
public Biome getByName(NamespaceID namespaceID) {
|
||||
public synchronized Biome getByName(NamespaceID namespaceID) {
|
||||
Biome biome = null;
|
||||
for (final Biome biomeT : biomes.values()) {
|
||||
if (biomeT.getName().equals(namespaceID)) {
|
||||
if (biomeT.name().equals(namespaceID)) {
|
||||
biome = biomeT;
|
||||
break;
|
||||
}
|
||||
@ -71,7 +70,7 @@ public final class BiomeManager {
|
||||
return biome;
|
||||
}
|
||||
|
||||
public NBTCompound toNBT() {
|
||||
public synchronized NBTCompound toNBT() {
|
||||
NBTCompound biomes = new NBTCompound();
|
||||
biomes.setString("type", "minecraft:worldgen/biome");
|
||||
NBTList<NBTCompound> biomesList = new NBTList<>(NBTTypes.TAG_Compound);
|
||||
|
Loading…
Reference in New Issue
Block a user