diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 2f8a20b545..ae15639cfb 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -96,6 +96,6 @@ object Versions { } object Minestom { - const val minestom = "2025.10.31-1.21.10" + const val minestom = "2025.12.20c-1.21.11" } } diff --git a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/TerraMinestomPlatform.java b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/TerraMinestomPlatform.java index 810426f830..ba5d6bb66a 100644 --- a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/TerraMinestomPlatform.java +++ b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/TerraMinestomPlatform.java @@ -7,6 +7,8 @@ import net.minestom.server.MinecraftServer; import net.minestom.server.instance.Instance; import net.minestom.server.sound.SoundEvent; +import net.minestom.server.world.attribute.AmbientParticle; +import net.minestom.server.world.attribute.AmbientSounds; import net.minestom.server.world.biome.BiomeEffects; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -82,9 +84,9 @@ public void register(TypeRegistry registry) { (TypeLoader) (annotatedType, o, configLoader, depthTracker) -> new MinestomEntityType((String) o)) .registerLoader(BlockState.class, (TypeLoader) (annotatedType, o, configLoader, depthTracker) -> worldHandle.createBlockState((String) o)) - .registerLoader(BiomeEffects.Particle.class, BiomeParticleConfigTemplate::new) - .registerLoader(BiomeEffects.MoodSound.class, BiomeMoodSoundTemplate::new) - .registerLoader(BiomeEffects.AdditionsSound.class, BiomeAdditionsSoundTemplate::new) + .registerLoader(AmbientParticle.class, BiomeParticleConfigTemplate::new) + .registerLoader(AmbientSounds.Mood.class, BiomeMoodSoundTemplate::new) + .registerLoader(AmbientSounds.Additions.class, BiomeAdditionsSoundTemplate::new) .registerLoader(SoundEvent.class, SoundEventTemplate::new); } diff --git a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomUserDefinedBiomeFactory.java b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomUserDefinedBiomeFactory.java index 644350d494..29ea5b117f 100644 --- a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomUserDefinedBiomeFactory.java +++ b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomUserDefinedBiomeFactory.java @@ -5,6 +5,7 @@ import net.minestom.server.color.Color; import net.minestom.server.registry.DynamicRegistry; import net.minestom.server.registry.RegistryKey; +import net.minestom.server.world.attribute.EnvironmentAttribute; import net.minestom.server.world.biome.Biome; import net.minestom.server.world.biome.BiomeEffects; import org.intellij.lang.annotations.Subst; @@ -27,6 +28,11 @@ private static T mergeNullable(T first, T second) { return first; } + private static void applyAttributeIfNotNull(Biome.Builder biomeBuilder, EnvironmentAttribute attribute, T value) { + if (value == null) return; + biomeBuilder.setAttribute(attribute, value); + } + @Subst("value") protected static String createBiomeID(ConfigPack pack, String biomeId) { return pack.getID().toLowerCase() + "/" + biomeId.toLowerCase(Locale.ROOT); @@ -41,32 +47,25 @@ public UserDefinedBiome create(ConfigPack pack, com.dfsek.terra.api.world.biome. Key key = Key.key("terra", createBiomeID(pack, source.getID())); BiomeEffects.Builder effectsBuilder = BiomeEffects.builder() - .fogColor(mergeNullable(properties.getFogColor(), parentEffects.fogColor())) - .skyColor(mergeNullable(properties.getSkyColor(), parentEffects.skyColor())) .waterColor(mergeNullable(properties.getWaterColor(), parentEffects.waterColor())) - .waterFogColor(mergeNullable(properties.getWaterFogColor(), parentEffects.waterFogColor())) .foliageColor(mergeNullable(properties.getFoliageColor(), parentEffects.foliageColor())) .grassColor(mergeNullable(properties.getGrassColor(), parentEffects.grassColor())) - .grassColorModifier(mergeNullable(properties.getGrassColorModifier(), parentEffects.grassColorModifier())) - .biomeParticle(mergeNullable(properties.getParticleConfig(), parentEffects.biomeParticle())) - .ambientSound(mergeNullable(properties.getLoopSound(), parentEffects.ambientSound())) - .moodSound(mergeNullable(properties.getMoodSound(), parentEffects.moodSound())) - .additionsSound(mergeNullable(properties.getAdditionsSound(), parentEffects.additionsSound())) - // TODO music - .music(parentEffects.music()) - .musicVolume(parentEffects.musicVolume()); - - if(effectsBuilder.build().equals(BiomeEffects.PLAINS_EFFECTS)) { - effectsBuilder.fogColor(new Color(0xC0D8FE)); // circumvent a minestom bug - } + .grassColorModifier(mergeNullable(properties.getGrassColorModifier(), parentEffects.grassColorModifier())); - Biome target = Biome.builder() + Biome.Builder targetBuilder = Biome.builder() .downfall(mergeNullable(properties.getDownfall(), parent.downfall())) - .hasPrecipitation(mergeNullable(properties.getPrecipitation(), parent.hasPrecipitation())) + .precipitation(mergeNullable(properties.getPrecipitation(), parent.hasPrecipitation())) .temperature(mergeNullable(properties.getTemperature(), parent.temperature())) - .temperatureModifier(mergeNullable(properties.getTemperatureModifier(), parent.temperatureModifier())) - .effects(effectsBuilder.build()) - .build(); + .effects(effectsBuilder.build()); + + applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.FOG_COLOR, properties.getFogColor()); + applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.SKY_COLOR, properties.getSkyColor()); + applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.WATER_FOG_COLOR, properties.getWaterFogColor()); + applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.AMBIENT_PARTICLES, properties.getParticleConfig()); + applyAttributeIfNotNull(targetBuilder, EnvironmentAttribute.AMBIENT_SOUNDS, properties.getAmbientSoundConfig()); + // TODO music + + Biome target = targetBuilder.build(); RegistryKey registryKey = MinecraftServer.getBiomeRegistry().register(key, target); return new UserDefinedBiome(key, registryKey, source.getID(), target); diff --git a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/config/BiomeAdditionsSoundTemplate.java b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/config/BiomeAdditionsSoundTemplate.java index 85e4499fc5..c5686688aa 100644 --- a/platforms/minestom/src/main/java/com/dfsek/terra/minestom/config/BiomeAdditionsSoundTemplate.java +++ b/platforms/minestom/src/main/java/com/dfsek/terra/minestom/config/BiomeAdditionsSoundTemplate.java @@ -4,10 +4,11 @@ import com.dfsek.tectonic.api.config.template.annotations.Value; import com.dfsek.tectonic.api.config.template.object.ObjectTemplate; import net.minestom.server.sound.SoundEvent; +import net.minestom.server.world.attribute.AmbientSounds; import net.minestom.server.world.biome.BiomeEffects; -public class BiomeAdditionsSoundTemplate implements ObjectTemplate { +public class BiomeAdditionsSoundTemplate implements ObjectTemplate { @Value("sound") @Default private SoundEvent sound = null; @@ -17,8 +18,8 @@ public class BiomeAdditionsSoundTemplate implements ObjectTemplate { +public class BiomeMoodSoundTemplate implements ObjectTemplate { @Value("sound") @Default private SoundEvent sound = null; @@ -25,9 +26,9 @@ public class BiomeMoodSoundTemplate implements ObjectTemplate { +public class BiomeParticleConfigTemplate implements ObjectTemplate { @Value("particle") @Default private String particle = null; @@ -18,7 +19,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate getParticleConfig() { + if (particleConfig == null) return null; + return List.of(particleConfig); } public Boolean getPrecipitation() { @@ -125,15 +130,12 @@ public Float getDownfall() { return downfall; } - public SoundEvent getLoopSound() { - return loopSound; - } - - public BiomeEffects.MoodSound getMoodSound() { - return moodSound; - } - - public BiomeEffects.AdditionsSound getAdditionsSound() { - return additionsSound; + public AmbientSounds getAmbientSoundConfig() { + List additions = additionsSound == null ? List.of() : List.of(additionsSound); + return new AmbientSounds( + loopSound, + moodSound, + additions + ); } }