mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Cleanup BiomeParticle
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
72448d6481
commit
b3f1bfdf59
@ -8,7 +8,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public record BiomeEffects(int fogColor, int skyColor, int waterColor, int waterFogColor, int foliageColor,
|
public record BiomeEffects(int fogColor, int skyColor, int waterColor, int waterFogColor, int foliageColor,
|
||||||
int grassColor,
|
int grassColor,
|
||||||
GrassColorModifier grassColorModifier, BiomeParticles biomeParticles,
|
GrassColorModifier grassColorModifier, BiomeParticle biomeParticle,
|
||||||
NamespaceID ambientSound, MoodSound moodSound, AdditionsSound additionsSound,
|
NamespaceID ambientSound, MoodSound moodSound, AdditionsSound additionsSound,
|
||||||
Music music) {
|
Music music) {
|
||||||
|
|
||||||
@ -26,8 +26,8 @@ public record BiomeEffects(int fogColor, int skyColor, int waterColor, int water
|
|||||||
nbt.setInt("water_fog_color", waterFogColor);
|
nbt.setInt("water_fog_color", waterFogColor);
|
||||||
if (grassColorModifier != null)
|
if (grassColorModifier != null)
|
||||||
nbt.setString("grass_color_modifier", grassColorModifier.name().toLowerCase(Locale.ROOT));
|
nbt.setString("grass_color_modifier", grassColorModifier.name().toLowerCase(Locale.ROOT));
|
||||||
if (biomeParticles != null)
|
if (biomeParticle != null)
|
||||||
nbt.set("particle", biomeParticles.toNbt());
|
nbt.set("particle", biomeParticle.toNbt());
|
||||||
if (ambientSound != null)
|
if (ambientSound != null)
|
||||||
nbt.setString("ambient_sound", ambientSound.toString());
|
nbt.setString("ambient_sound", ambientSound.toString());
|
||||||
if (moodSound != null)
|
if (moodSound != null)
|
||||||
@ -82,7 +82,7 @@ public record BiomeEffects(int fogColor, int skyColor, int waterColor, int water
|
|||||||
private int foliageColor = -1;
|
private int foliageColor = -1;
|
||||||
private int grassColor = -1;
|
private int grassColor = -1;
|
||||||
private GrassColorModifier grassColorModifier;
|
private GrassColorModifier grassColorModifier;
|
||||||
private BiomeParticles biomeParticles;
|
private BiomeParticle biomeParticle;
|
||||||
private NamespaceID ambientSound;
|
private NamespaceID ambientSound;
|
||||||
private MoodSound moodSound;
|
private MoodSound moodSound;
|
||||||
private AdditionsSound additionsSound;
|
private AdditionsSound additionsSound;
|
||||||
@ -126,8 +126,8 @@ public record BiomeEffects(int fogColor, int skyColor, int waterColor, int water
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder biomeParticles(BiomeParticles biomeParticles) {
|
public Builder biomeParticle(BiomeParticle biomeParticle) {
|
||||||
this.biomeParticles = biomeParticles;
|
this.biomeParticle = biomeParticle;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public record BiomeEffects(int fogColor, int skyColor, int waterColor, int water
|
|||||||
|
|
||||||
public BiomeEffects build() {
|
public BiomeEffects build() {
|
||||||
return new BiomeEffects(fogColor, skyColor, waterColor, waterFogColor, foliageColor,
|
return new BiomeEffects(fogColor, skyColor, waterColor, waterFogColor, foliageColor,
|
||||||
grassColor, grassColorModifier, biomeParticles,
|
grassColor, grassColorModifier, biomeParticle,
|
||||||
ambientSound, moodSound, additionsSound, music);
|
ambientSound, moodSound, additionsSound, music);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,43 +3,26 @@ package net.minestom.server.world.biomes;
|
|||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.utils.NamespaceID;
|
import net.minestom.server.utils.NamespaceID;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BiomeParticles {
|
public record BiomeParticle(float probability, Option option) {
|
||||||
|
|
||||||
private final float probability;
|
|
||||||
private final ParticleOptions options;
|
|
||||||
|
|
||||||
public BiomeParticles(float probability, ParticleOptions options) {
|
|
||||||
this.probability = probability;
|
|
||||||
this.options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
NBTCompound nbt = new NBTCompound();
|
NBTCompound nbt = new NBTCompound();
|
||||||
nbt.setFloat("probability", probability);
|
nbt.setFloat("probability", probability);
|
||||||
nbt.set("options", options.toNbt());
|
nbt.set("options", option.toNbt());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ParticleOptions {
|
public interface Option {
|
||||||
NBTCompound toNbt();
|
NBTCompound toNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BlockParticle implements ParticleOptions {
|
public record BlockOption(Block block) implements Option {
|
||||||
|
|
||||||
//TODO also can be falling_dust
|
//TODO also can be falling_dust
|
||||||
private static final String type = "block";
|
private static final String type = "block";
|
||||||
|
|
||||||
private final Block block;
|
|
||||||
|
|
||||||
public BlockParticle(Block block) {
|
|
||||||
this.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
NBTCompound nbtCompound = new NBTCompound();
|
NBTCompound nbtCompound = new NBTCompound();
|
||||||
@ -53,25 +36,11 @@ public class BiomeParticles {
|
|||||||
}
|
}
|
||||||
return nbtCompound;
|
return nbtCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DustParticle implements ParticleOptions {
|
public record DustOption(float red, float green, float blue, float scale) implements Option {
|
||||||
|
|
||||||
private static final String type = "dust";
|
private static final String type = "dust";
|
||||||
|
|
||||||
private final float red;
|
|
||||||
private final float green;
|
|
||||||
private final float blue;
|
|
||||||
private final float scale;
|
|
||||||
|
|
||||||
public DustParticle(float red, float green, float blue, float scale) {
|
|
||||||
this.red = red;
|
|
||||||
this.green = green;
|
|
||||||
this.blue = blue;
|
|
||||||
this.scale = scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
NBTCompound nbtCompound = new NBTCompound();
|
NBTCompound nbtCompound = new NBTCompound();
|
||||||
@ -82,19 +51,11 @@ public class BiomeParticles {
|
|||||||
nbtCompound.setFloat("scale", scale);
|
nbtCompound.setFloat("scale", scale);
|
||||||
return nbtCompound;
|
return nbtCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ItemParticle implements ParticleOptions {
|
public record ItemOption(ItemStack item) implements Option {
|
||||||
|
|
||||||
private static final String type = "item";
|
private static final String type = "item";
|
||||||
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public ItemParticle(ItemStack item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
//todo test count might be wrong type
|
//todo test count might be wrong type
|
||||||
@ -102,23 +63,14 @@ public class BiomeParticles {
|
|||||||
nbtCompound.setString("type", type);
|
nbtCompound.setString("type", type);
|
||||||
return nbtCompound;
|
return nbtCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NormalParticle implements ParticleOptions {
|
public record NormalOption(NamespaceID type) implements Option {
|
||||||
|
|
||||||
private final NamespaceID type;
|
|
||||||
|
|
||||||
public NormalParticle(@NotNull NamespaceID type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTCompound toNbt() {
|
public NBTCompound toNbt() {
|
||||||
NBTCompound nbtCompound = new NBTCompound();
|
NBTCompound nbtCompound = new NBTCompound();
|
||||||
nbtCompound.setString("type", type.toString());
|
nbtCompound.setString("type", type.toString());
|
||||||
return nbtCompound;
|
return nbtCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user