Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,9 +84,9 @@ public void register(TypeRegistry registry) {
(TypeLoader<EntityType>) (annotatedType, o, configLoader, depthTracker) -> new MinestomEntityType((String) o))
.registerLoader(BlockState.class,
(TypeLoader<BlockState>) (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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,11 @@ private static <T> T mergeNullable(T first, T second) {
return first;
}

private static <T> void applyAttributeIfNotNull(Biome.Builder biomeBuilder, EnvironmentAttribute<T> 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);
Expand All @@ -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<Biome> registryKey = MinecraftServer.getBiomeRegistry().register(key, target);
return new UserDefinedBiome(key, registryKey, source.getID(), target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BiomeEffects.AdditionsSound> {
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientSounds.Additions> {
@Value("sound")
@Default
private SoundEvent sound = null;
Expand All @@ -17,8 +18,8 @@ public class BiomeAdditionsSoundTemplate implements ObjectTemplate<BiomeEffects.
private Double soundChance = null;

@Override
public BiomeEffects.AdditionsSound get() {
public AmbientSounds.Additions get() {
if(sound == null) return null;
return new BiomeEffects.AdditionsSound(sound, soundChance);
return new AmbientSounds.Additions(sound, soundChance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 BiomeMoodSoundTemplate implements ObjectTemplate<BiomeEffects.MoodSound> {
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientSounds.Mood> {
@Value("sound")
@Default
private SoundEvent sound = null;
Expand All @@ -25,9 +26,9 @@ public class BiomeMoodSoundTemplate implements ObjectTemplate<BiomeEffects.MoodS
private Double soundExtraDistance = null;

@Override
public BiomeEffects.MoodSound get() {
public AmbientSounds.Mood get() {
if(sound == null) return null;
return new BiomeEffects.MoodSound(
return new AmbientSounds.Mood(
sound,
soundCultivationTicks,
soundSpawnRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minestom.server.particle.Particle;
import net.minestom.server.world.attribute.AmbientParticle;
import net.minestom.server.world.biome.BiomeEffects;
import org.slf4j.LoggerFactory;


public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeEffects.Particle> {
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticle> {
@Value("particle")
@Default
private String particle = null;
Expand All @@ -18,7 +19,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeEffects.
private Float probability = null;

@Override
public BiomeEffects.Particle get() {
public AmbientParticle get() {
if(particle == null || probability == null) {
return null;
}
Expand All @@ -31,9 +32,9 @@ public BiomeEffects.Particle get() {
return null;
}

return new BiomeEffects.Particle(
probability,
parsedParticle
return new AmbientParticle(
parsedParticle,
probability
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import com.dfsek.tectonic.api.config.template.annotations.Value;
import net.kyori.adventure.util.RGBLike;
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.Biome.TemperatureModifier;
import net.minestom.server.world.biome.BiomeEffects;
import net.minestom.server.world.biome.BiomeEffects.GrassColorModifier;

import com.dfsek.terra.api.properties.Properties;

import java.util.List;


public class VanillaBiomeProperties implements ConfigTemplate, Properties {
@Value("colors.grass")
Expand Down Expand Up @@ -43,7 +47,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {

@Value("particles")
@Default
private BiomeEffects.Particle particleConfig = null;
private AmbientParticle particleConfig = null;

@Value("climate.precipitation")
@Default
Expand All @@ -67,11 +71,11 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {

@Value("sound.mood-sound")
@Default
private BiomeEffects.MoodSound moodSound = null;
private AmbientSounds.Mood moodSound = null;

@Value("sound.additions-sound")
@Default
private BiomeEffects.AdditionsSound additionsSound = null;
private AmbientSounds.Additions additionsSound = null;

// @Value("sound.music")
// @Default
Expand Down Expand Up @@ -105,8 +109,9 @@ public GrassColorModifier getGrassColorModifier() {
return grassColorModifier;
}

public BiomeEffects.Particle getParticleConfig() {
return particleConfig;
public List<AmbientParticle> getParticleConfig() {
if (particleConfig == null) return null;
return List.of(particleConfig);
}

public Boolean getPrecipitation() {
Expand All @@ -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<AmbientSounds.Additions> additions = additionsSound == null ? List.of() : List.of(additionsSound);
return new AmbientSounds(
loopSound,
moodSound,
additions
);
}
}