mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 09:51:35 +01:00
Remove precipitation enum and add boolean (#2648)
This commit is contained in:
parent
87f6524aeb
commit
10c7d711de
@ -37,16 +37,12 @@ public sealed interface Biome extends Biomes, ProtocolObject permits BiomeImpl {
|
|||||||
|
|
||||||
@NotNull BiomeEffects effects();
|
@NotNull BiomeEffects effects();
|
||||||
|
|
||||||
@NotNull Precipitation precipitation();
|
boolean hasPrecipitation();
|
||||||
|
|
||||||
@NotNull TemperatureModifier temperatureModifier();
|
@NotNull TemperatureModifier temperatureModifier();
|
||||||
|
|
||||||
@Nullable Registry.BiomeEntry registry();
|
@Nullable Registry.BiomeEntry registry();
|
||||||
|
|
||||||
enum Precipitation {
|
|
||||||
NONE, RAIN, SNOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum TemperatureModifier {
|
enum TemperatureModifier {
|
||||||
NONE, FROZEN;
|
NONE, FROZEN;
|
||||||
}
|
}
|
||||||
@ -78,7 +74,7 @@ public sealed interface Biome extends Biomes, ProtocolObject permits BiomeImpl {
|
|||||||
private float temperature = 0.25f;
|
private float temperature = 0.25f;
|
||||||
private float downfall = 0.8f;
|
private float downfall = 0.8f;
|
||||||
private BiomeEffects effects = DEFAULT_EFFECTS;
|
private BiomeEffects effects = DEFAULT_EFFECTS;
|
||||||
private Precipitation precipitation = Precipitation.RAIN;
|
private boolean hasPrecipitation = false;
|
||||||
private TemperatureModifier temperatureModifier = TemperatureModifier.NONE;
|
private TemperatureModifier temperatureModifier = TemperatureModifier.NONE;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
@ -103,8 +99,8 @@ public sealed interface Biome extends Biomes, ProtocolObject permits BiomeImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Contract(value = "_ -> this", pure = true)
|
@Contract(value = "_ -> this", pure = true)
|
||||||
public @NotNull Builder precipitation(@NotNull Biome.Precipitation precipitation) {
|
public @NotNull Builder hasPrecipitation(boolean precipitation) {
|
||||||
this.precipitation = precipitation;
|
this.hasPrecipitation = precipitation;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +112,7 @@ public sealed interface Biome extends Biomes, ProtocolObject permits BiomeImpl {
|
|||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
public @NotNull Biome build() {
|
public @NotNull Biome build() {
|
||||||
return new BiomeImpl(temperature, downfall, effects, precipitation, temperatureModifier, null);
|
return new BiomeImpl(temperature, downfall, effects, hasPrecipitation, temperatureModifier, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ record BiomeImpl(
|
|||||||
float temperature,
|
float temperature,
|
||||||
float downfall,
|
float downfall,
|
||||||
@NotNull BiomeEffects effects,
|
@NotNull BiomeEffects effects,
|
||||||
@NotNull Precipitation precipitation,
|
boolean hasPrecipitation,
|
||||||
@NotNull TemperatureModifier temperatureModifier,
|
@NotNull TemperatureModifier temperatureModifier,
|
||||||
@Nullable Registry.BiomeEntry registry
|
@Nullable Registry.BiomeEntry registry
|
||||||
) implements Biome {
|
) implements Biome {
|
||||||
// https://minecraft.wiki/w/Rain
|
// https://minecraft.wiki/w/Rain
|
||||||
private final static Double SNOW_TEMPERATURE = 0.15;
|
private final static double SNOW_TEMPERATURE = 0.15;
|
||||||
|
|
||||||
static final BinaryTagSerializer<Biome> REGISTRY_NBT_TYPE = BinaryTagSerializer.COMPOUND.map(
|
static final BinaryTagSerializer<Biome> REGISTRY_NBT_TYPE = BinaryTagSerializer.COMPOUND.map(
|
||||||
tag -> {
|
tag -> {
|
||||||
@ -27,8 +27,7 @@ record BiomeImpl(
|
|||||||
CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder()
|
CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder()
|
||||||
.putFloat("temperature", biome.temperature())
|
.putFloat("temperature", biome.temperature())
|
||||||
.putFloat("downfall", biome.downfall())
|
.putFloat("downfall", biome.downfall())
|
||||||
.putByte("has_precipitation", (byte) (biome.precipitation() == Precipitation.NONE ? 0 : 1))
|
.putBoolean("has_precipitation", biome.hasPrecipitation());
|
||||||
.putString("precipitation", biome.precipitation().name().toLowerCase(Locale.ROOT));
|
|
||||||
if (biome.temperatureModifier() != TemperatureModifier.NONE)
|
if (biome.temperatureModifier() != TemperatureModifier.NONE)
|
||||||
builder.putString("temperature_modifier", biome.temperatureModifier().name().toLowerCase(Locale.ROOT));
|
builder.putString("temperature_modifier", biome.temperatureModifier().name().toLowerCase(Locale.ROOT));
|
||||||
return builder
|
return builder
|
||||||
@ -39,11 +38,7 @@ record BiomeImpl(
|
|||||||
|
|
||||||
BiomeImpl(Registry.BiomeEntry entry) {
|
BiomeImpl(Registry.BiomeEntry entry) {
|
||||||
this(entry.temperature(), entry.downfall(), getBuilder(entry).build(),
|
this(entry.temperature(), entry.downfall(), getBuilder(entry).build(),
|
||||||
entry.hasPrecipitation()
|
entry.hasPrecipitation(),
|
||||||
? entry.temperature() < SNOW_TEMPERATURE
|
|
||||||
? Precipitation.SNOW
|
|
||||||
: Precipitation.RAIN
|
|
||||||
: Precipitation.NONE,
|
|
||||||
entry.temperature() < SNOW_TEMPERATURE ? TemperatureModifier.FROZEN : TemperatureModifier.NONE,
|
entry.temperature() < SNOW_TEMPERATURE ? TemperatureModifier.FROZEN : TemperatureModifier.NONE,
|
||||||
entry
|
entry
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user