mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Started adding more biome settings to bukkit
This commit is contained in:
@@ -4,18 +4,15 @@ import ca.solostudios.strata.Versions;
|
|||||||
import ca.solostudios.strata.version.Version;
|
import ca.solostudios.strata.version.Version;
|
||||||
|
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.world.biome.Biome;
|
|
||||||
import com.dfsek.terra.bukkit.config.PreLoadCompatibilityOptions;
|
import com.dfsek.terra.bukkit.config.PreLoadCompatibilityOptions;
|
||||||
import com.dfsek.terra.bukkit.config.VanillaBiomeProperties;
|
|
||||||
|
|
||||||
|
|
||||||
public class BukkitAddon implements BaseAddon {
|
public class BukkitAddon implements BaseAddon {
|
||||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||||
|
|
||||||
private final PlatformImpl terraBukkitPlugin;
|
protected final PlatformImpl terraBukkitPlugin;
|
||||||
|
|
||||||
public BukkitAddon(PlatformImpl terraBukkitPlugin) {
|
public BukkitAddon(PlatformImpl terraBukkitPlugin) {
|
||||||
this.terraBukkitPlugin = terraBukkitPlugin;
|
this.terraBukkitPlugin = terraBukkitPlugin;
|
||||||
@@ -28,16 +25,6 @@ public class BukkitAddon implements BaseAddon {
|
|||||||
.register(this, ConfigPackPreLoadEvent.class)
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().getContext().put(event.loadTemplate(new PreLoadCompatibilityOptions())))
|
.then(event -> event.getPack().getContext().put(event.loadTemplate(new PreLoadCompatibilityOptions())))
|
||||||
.global();
|
.global();
|
||||||
|
|
||||||
terraBukkitPlugin.getEventManager()
|
|
||||||
.getHandler(FunctionalEventHandler.class)
|
|
||||||
.register(this, ConfigurationLoadEvent.class)
|
|
||||||
.then(event -> {
|
|
||||||
if(event.is(Biome.class)) {
|
|
||||||
event.getLoadedObject(Biome.class).getContext().put(event.load(new VanillaBiomeProperties()));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.global();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
package com.dfsek.terra.bukkit.config;
|
|
||||||
|
|
||||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
|
||||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
|
||||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.Properties;
|
|
||||||
|
|
||||||
|
|
||||||
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
|
||||||
@Value("colors.grass")
|
|
||||||
@Default
|
|
||||||
private Integer grassColor = null;
|
|
||||||
|
|
||||||
@Value("colors.fog")
|
|
||||||
@Default
|
|
||||||
private Integer fogColor = null;
|
|
||||||
|
|
||||||
@Value("colors.water")
|
|
||||||
@Default
|
|
||||||
private Integer waterColor = null;
|
|
||||||
|
|
||||||
@Value("colors.water-fog")
|
|
||||||
@Default
|
|
||||||
private Integer waterFogColor = null;
|
|
||||||
|
|
||||||
@Value("colors.foliage")
|
|
||||||
@Default
|
|
||||||
private Integer foliageColor = null;
|
|
||||||
|
|
||||||
@Value("colors.sky")
|
|
||||||
@Default
|
|
||||||
private Integer skyColor = null;
|
|
||||||
|
|
||||||
public Integer getFogColor() {
|
|
||||||
return fogColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getFoliageColor() {
|
|
||||||
return foliageColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getGrassColor() {
|
|
||||||
return grassColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getWaterColor() {
|
|
||||||
return waterColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getWaterFogColor() {
|
|
||||||
return waterFogColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSkyColor() {
|
|
||||||
return skyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,8 @@ public interface Initializer {
|
|||||||
Logger logger = LoggerFactory.getLogger(Initializer.class);
|
Logger logger = LoggerFactory.getLogger(Initializer.class);
|
||||||
try {
|
try {
|
||||||
String packageVersion = NMS;
|
String packageVersion = NMS;
|
||||||
if(NMS.equals("v1_21_1")) {
|
if(NMS.equals("v1_21_3")) {
|
||||||
packageVersion = "v1_21";
|
packageVersion = "v1_21"; // TODO: Refactor nms package to v1_21_3
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
|
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_21;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
|
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||||
|
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||||
|
import com.dfsek.terra.bukkit.nms.v1_21.config.VanillaBiomeProperties;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSAddon extends BukkitAddon {
|
||||||
|
|
||||||
|
public NMSAddon(PlatformImpl terraBukkitPlugin) {
|
||||||
|
super(terraBukkitPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
|
||||||
|
terraBukkitPlugin.getEventManager()
|
||||||
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigurationLoadEvent.class)
|
||||||
|
.then(event -> {
|
||||||
|
if(event.is(Biome.class)) {
|
||||||
|
event.getLoadedObject(Biome.class).getContext().put(event.load(new VanillaBiomeProperties()));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.global();
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
-23
@@ -11,7 +11,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.bukkit.config.VanillaBiomeProperties;
|
import com.dfsek.terra.bukkit.nms.v1_21.config.VanillaBiomeProperties;
|
||||||
|
|
||||||
|
|
||||||
public class NMSBiomeInjector {
|
public class NMSBiomeInjector {
|
||||||
@@ -26,17 +26,8 @@ public class NMSBiomeInjector {
|
|||||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||||
Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
|
Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
|
||||||
|
|
||||||
builder
|
|
||||||
.downfall(vanilla.climateSettings.downfall())
|
|
||||||
.temperature(vanilla.getBaseTemperature())
|
|
||||||
.mobSpawnSettings(vanilla.getMobSettings())
|
|
||||||
.generationSettings(vanilla.getGenerationSettings());
|
|
||||||
|
|
||||||
|
|
||||||
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
||||||
|
|
||||||
effects.grassColorModifier(vanilla.getSpecialEffects().getGrassColorModifier());
|
|
||||||
|
|
||||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||||
|
|
||||||
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
|
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
|
||||||
@@ -45,13 +36,11 @@ public class NMSBiomeInjector {
|
|||||||
|
|
||||||
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
||||||
|
|
||||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()));
|
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()))
|
||||||
vanilla.getSpecialEffects().getFoliageColorOverride().ifPresent(effects::foliageColorOverride);
|
|
||||||
} else {
|
.foliageColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
||||||
effects.foliageColorOverride(vanillaBiomeProperties.getFoliageColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||||
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
||||||
@@ -60,15 +49,50 @@ public class NMSBiomeInjector {
|
|||||||
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
vanilla.getAmbientLoop().ifPresent(effects::ambientLoopSound);
|
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
||||||
vanilla.getAmbientAdditions().ifPresent(effects::ambientAdditionsSound);
|
vanilla.getSpecialEffects().getAmbientParticleSettings().ifPresent(effects::ambientParticle);
|
||||||
vanilla.getAmbientMood().ifPresent(effects::ambientMoodSound);
|
} else {
|
||||||
vanilla.getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
effects.ambientParticle(vanillaBiomeProperties.getParticleConfig());
|
||||||
vanilla.getAmbientParticle().ifPresent(effects::ambientParticle);
|
}
|
||||||
|
|
||||||
builder.specialEffects(effects.build());
|
if(vanillaBiomeProperties.getLoopSound() == null) {
|
||||||
|
vanilla.getSpecialEffects().getAmbientLoopSoundEvent().ifPresent(effects::ambientLoopSound);
|
||||||
|
} else {
|
||||||
|
RegistryFetcher.soundEventRegistry().get(vanillaBiomeProperties.getLoopSound().location()).ifPresent(effects::ambientLoopSound);
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
if(vanillaBiomeProperties.getMoodSound() == null) {
|
||||||
|
vanilla.getSpecialEffects().getAmbientMoodSettings().ifPresent(effects::ambientMoodSound);
|
||||||
|
} else {
|
||||||
|
effects.ambientMoodSound(vanillaBiomeProperties.getMoodSound());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getAdditionsSound() == null) {
|
||||||
|
vanilla.getSpecialEffects().getAmbientAdditionsSettings().ifPresent(effects::ambientAdditionsSound);
|
||||||
|
} else {
|
||||||
|
effects.ambientAdditionsSound(vanillaBiomeProperties.getAdditionsSound());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getMusic() == null) {
|
||||||
|
vanilla.getSpecialEffects().getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
||||||
|
} else {
|
||||||
|
effects.backgroundMusic(vanillaBiomeProperties.getMusic());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.hasPrecipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
|
||||||
|
|
||||||
|
builder.temperature(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperature(), vanilla.getBaseTemperature()));
|
||||||
|
|
||||||
|
builder.downfall(Objects.requireNonNullElse(vanillaBiomeProperties.getDownfall(), vanilla.climateSettings.downfall()));
|
||||||
|
|
||||||
|
builder.temperatureAdjustment(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperatureModifier(), vanilla.climateSettings.temperatureModifier()));
|
||||||
|
|
||||||
|
builder.mobSpawnSettings(Objects.requireNonNullElse(vanillaBiomeProperties.getSpawnSettings(), vanilla.getMobSettings()));
|
||||||
|
|
||||||
|
return builder
|
||||||
|
.specialEffects(effects.build())
|
||||||
|
.generationSettings(vanilla.getGenerationSettings())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||||
|
|||||||
+5
@@ -4,6 +4,7 @@ import net.minecraft.core.Registry;
|
|||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
@@ -23,4 +24,8 @@ public class RegistryFetcher {
|
|||||||
public static Registry<Biome> biomeRegistry() {
|
public static Registry<Biome> biomeRegistry() {
|
||||||
return getRegistry(Registries.BIOME);
|
return getRegistry(Registries.BIOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Registry<SoundEvent> soundEventRegistry() {
|
||||||
|
return getRegistry(Registries.SOUND_EVENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+164
@@ -0,0 +1,164 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_21.config;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.properties.Properties;
|
||||||
|
|
||||||
|
import net.minecraft.sounds.Music;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.world.entity.npc.VillagerType;
|
||||||
|
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||||
|
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||||
|
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||||
|
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
||||||
|
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||||
|
|
||||||
|
|
||||||
|
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||||
|
@Value("colors.grass")
|
||||||
|
@Default
|
||||||
|
private Integer grassColor = null;
|
||||||
|
|
||||||
|
@Value("colors.fog")
|
||||||
|
@Default
|
||||||
|
private Integer fogColor = null;
|
||||||
|
|
||||||
|
@Value("colors.water")
|
||||||
|
@Default
|
||||||
|
private Integer waterColor = null;
|
||||||
|
|
||||||
|
@Value("colors.water-fog")
|
||||||
|
@Default
|
||||||
|
private Integer waterFogColor = null;
|
||||||
|
|
||||||
|
@Value("colors.foliage")
|
||||||
|
@Default
|
||||||
|
private Integer foliageColor = null;
|
||||||
|
|
||||||
|
@Value("colors.sky")
|
||||||
|
@Default
|
||||||
|
private Integer skyColor = null;
|
||||||
|
|
||||||
|
@Value("colors.modifier")
|
||||||
|
@Default
|
||||||
|
private GrassColorModifier grassColorModifier = null;
|
||||||
|
|
||||||
|
@Value("particles")
|
||||||
|
@Default
|
||||||
|
private AmbientParticleSettings particleConfig = null;
|
||||||
|
|
||||||
|
@Value("climate.precipitation")
|
||||||
|
@Default
|
||||||
|
private Boolean precipitation = true;
|
||||||
|
|
||||||
|
@Value("climate.temperature")
|
||||||
|
@Default
|
||||||
|
private Float temperature = null;
|
||||||
|
|
||||||
|
@Value("climate.temperature-modifier")
|
||||||
|
@Default
|
||||||
|
private TemperatureModifier temperatureModifier = null;
|
||||||
|
|
||||||
|
@Value("climate.downfall")
|
||||||
|
@Default
|
||||||
|
private Float downfall = null;
|
||||||
|
|
||||||
|
@Value("sound.loop-sound.sound")
|
||||||
|
@Default
|
||||||
|
private SoundEvent loopSound = null;
|
||||||
|
|
||||||
|
@Value("sound.mood-sound")
|
||||||
|
@Default
|
||||||
|
private AmbientMoodSettings moodSound = null;
|
||||||
|
|
||||||
|
@Value("sound.additions-sound")
|
||||||
|
@Default
|
||||||
|
private AmbientAdditionsSettings additionsSound = null;
|
||||||
|
|
||||||
|
@Value("sound.music")
|
||||||
|
@Default
|
||||||
|
private Music music = null;
|
||||||
|
|
||||||
|
@Value("spawning")
|
||||||
|
@Default
|
||||||
|
private MobSpawnSettings spawnSettings = null;
|
||||||
|
|
||||||
|
@Value("villager-type")
|
||||||
|
@Default
|
||||||
|
private VillagerType villagerType = null;
|
||||||
|
|
||||||
|
public Integer getFogColor() {
|
||||||
|
return fogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFoliageColor() {
|
||||||
|
return foliageColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getGrassColor() {
|
||||||
|
return grassColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getWaterColor() {
|
||||||
|
return waterColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getWaterFogColor() {
|
||||||
|
return waterFogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSkyColor() {
|
||||||
|
return skyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GrassColorModifier getGrassColorModifier() {
|
||||||
|
return grassColorModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbientParticleSettings getParticleConfig() {
|
||||||
|
return particleConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPrecipitation() {
|
||||||
|
return precipitation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getTemperature() {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemperatureModifier getTemperatureModifier() {
|
||||||
|
return temperatureModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getDownfall() {
|
||||||
|
return downfall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SoundEvent getLoopSound() {
|
||||||
|
return loopSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbientMoodSettings getMoodSound() {
|
||||||
|
return moodSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbientAdditionsSettings getAdditionsSound() {
|
||||||
|
return additionsSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Music getMusic() {
|
||||||
|
return music;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MobSpawnSettings getSpawnSettings() {
|
||||||
|
return spawnSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VillagerType getVillagerType() {
|
||||||
|
return villagerType;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user