Compare commits

..

17 Commits

Author SHA1 Message Date
Zoe Gidiere 3ca90808f0 Fix up 2024-10-29 14:23:45 -06:00
Zoe Gidiere 9d91440997 fixup 2024-10-29 14:14:25 -06:00
Zoe Gidiere f98062d417 Merge remote-tracking branch 'origin/dev/bukkit/biome-settings' into dev/biomes3 2024-10-29 13:53:08 -06:00
Zoe Gidiere 40a938be19 Merge branch 'ver/6.6.0' into dev/biomes3 2024-10-12 15:44:19 -06:00
Zoe Gidiere da16f65ea2 Merge branch 'ver/6.6.0' into dev/biomes3 2024-10-12 15:39:03 -06:00
Zoe Gidiere d45256b2f7 Another merge fixup 2024-10-12 14:52:11 -06:00
Zoe Gidiere 16d8e8f29d Fix up merge 2024-10-12 14:49:53 -06:00
Zoe Gidiere a58b2a5193 Merge remote-tracking branch 'origin/dev/biome2' into ver/6.6.0 2024-10-12 14:40:33 -06:00
Zoë Gidiere 0efb0916e6 Initial Bukkit Biome Config 2023-11-17 16:16:18 -07:00
Zoë Gidiere 82fbf796da Refractor BiomeUtil 2023-11-17 15:26:53 -07:00
Zoë Gidiere 94bf67d09d fix dev env by having fabric api at runtime 2023-11-17 14:57:14 -07:00
Zoë Gidiere f86d4bae32 remove old bukkit versions 2023-11-17 13:22:10 -07:00
Zoë Gidiere c7cecaebe6 Merge remote-tracking branch 'origin/dev/biome2' into ver/6.5.0 2023-11-17 13:21:39 -07:00
Zoë Gidiere 70b1c3bbf3 warning 2023-09-30 12:06:21 -06:00
Zoë Gidiere e9b145b6c3 unbreaking via deprecation 2023-09-30 11:50:15 -06:00
Zoë 99d848b394 UX tweaks to biome config 2023-09-30 11:42:05 -06:00
Zoë Gidiere 4828d51da4 Merge branch 'dev/physics' into dev/biome2 2023-09-30 11:38:18 -06:00
22 changed files with 491 additions and 106 deletions
@@ -1,5 +1,7 @@
package com.dfsek.terra.bukkit.nms.v1_21;
import com.dfsek.terra.bukkit.nms.v1_21.config.VanillaBiomeProperties;
import com.google.common.collect.ImmutableMap;
import net.minecraft.core.Holder;
import net.minecraft.core.Holder.Reference;
@@ -42,7 +44,10 @@ public class AwfulBukkitHacks {
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
vanillaBukkitKey.getKey());
Biome platform = NMSBiomeInjector.createBiome(biome, biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value());
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(), vanillaBiomeProperties);
ResourceKey<Biome> delegateKey = ResourceKey.create(
Registries.BIOME,
@@ -22,14 +22,12 @@ public class NMSBiomeInjector {
.flatMap(registry::get);
}
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla)
public static Biome createBiome(Biome vanilla, VanillaBiomeProperties vanillaBiomeProperties)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
@@ -0,0 +1,28 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientAdditionsSettings> {
@Value("sound")
@Default
private SoundEvent sound = null;
@Value("sound-chance")
@Default
private Double soundChance = null;
@Override
public AmbientAdditionsSettings get() {
if(sound == null || soundChance == null) {
return null;
} else {
return new AmbientAdditionsSettings(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), soundChance);
}
}
}
@@ -0,0 +1,36 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.biome.AmbientMoodSettings;
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientMoodSettings> {
@Value("sound")
@Default
private SoundEvent sound = null;
@Value("cultivation-ticks")
@Default
private Integer soundCultivationTicks = null;
@Value("spawn-range")
@Default
private Integer soundSpawnRange = null;
@Value("extra-distance")
@Default
private Double soundExtraDistance = null;
@Override
public AmbientMoodSettings get() {
if(sound == null || soundCultivationTicks == null || soundSpawnRange == null || soundExtraDistance == null) {
return null;
} else {
return new AmbientMoodSettings(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), soundCultivationTicks, soundSpawnRange, soundExtraDistance);
}
}
}
@@ -0,0 +1,36 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.arguments.ParticleArgument;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.biome.AmbientParticleSettings;
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticleSettings> {
@Value("particle")
@Default
private String particle = null;
@Value("probability")
@Default
private Integer probability = null;
@Override
public AmbientParticleSettings get() {
if(particle == null || probability == null) {
return null;
}
try {
return new AmbientParticleSettings(ParticleArgument.readParticle(new StringReader(particle),
(Provider) BuiltInRegistries.PARTICLE_TYPE.asHolderIdMap()), probability);
} catch(CommandSyntaxException e) {
throw new RuntimeException(e);
}
}
}
@@ -0,0 +1,21 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
@Value("id")
@Default
private ResourceLocation id = null;
@Override
public EntityType<?> get() {
return BuiltInRegistries.ENTITY_TYPE.get(id).orElseThrow().value();
}
}
@@ -0,0 +1,36 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;
public class MusicSoundTemplate implements ObjectTemplate<Music> {
@Value("sound")
@Default
private SoundEvent sound = null;
@Value("min-delay")
@Default
private Integer minDelay = null;
@Value("max-delay")
@Default
private Integer maxDelay = null;
@Value("replace-current-music")
@Default
private Boolean replaceCurrentMusic = null;
@Override
public Music get() {
if(sound == null || minDelay == null || maxDelay == null || replaceCurrentMusic == null) {
return null;
} else {
return new Music(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), minDelay, maxDelay, replaceCurrentMusic);
}
}
}
@@ -0,0 +1,29 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
public class SoundEventTemplate implements ObjectTemplate<SoundEvent> {
@Value("id")
@Default
private ResourceLocation id = null;
@Value("distance-to-travel")
@Default
private Float distanceToTravel = null;
@Override
public SoundEvent get() {
if(id == null) {
return null;
} else if(distanceToTravel == null) {
return SoundEvent.createVariableRangeEvent(id);
} else {
return SoundEvent.createFixedRangeEvent(id, distanceToTravel);
}
}
}
@@ -0,0 +1,38 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.world.entity.EntityType;
public class SpawnCostConfig implements ObjectTemplate<SpawnCostConfig> {
@Value("type")
@Default
private EntityType<?> type = null;
@Value("mass")
@Default
private Double mass = null;
@Value("gravity")
@Default
private Double gravity = null;
public EntityType<?> getType() {
return type;
}
public Double getMass() {
return mass;
}
public Double getGravity() {
return gravity;
}
@Override
public SpawnCostConfig get() {
return this;
}
}
@@ -0,0 +1,31 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
public class SpawnEntryTemplate implements ObjectTemplate<SpawnerData> {
@Value("type")
@Default
private EntityType<?> type = null;
@Value("weight")
@Default
private Integer weight = null;
@Value("min-group-size")
@Default
private Integer minGroupSize = null;
@Value("max-group-size")
@Default
private Integer maxGroupSize = null;
@Override
public SpawnerData get() {
return new SpawnerData(type, weight, minGroupSize, maxGroupSize);
}
}
@@ -0,0 +1,49 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import java.util.List;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SpawnSettingsTemplate implements ObjectTemplate<MobSpawnSettings> {
private static final Logger logger = LoggerFactory.getLogger(SpawnTypeConfig.class);
private static boolean used = false;
@Value("spawns")
@Default
private List<SpawnTypeConfig> spawns = null;
@Value("costs")
@Default
private List<SpawnCostConfig> costs = null;
@Value("probability")
@Default
private Float probability = null;
@Override
public MobSpawnSettings get() {
MobSpawnSettings.Builder builder = new MobSpawnSettings.Builder();
for(SpawnTypeConfig spawn : spawns) {
MobCategory group = spawn.getGroup();
for(SpawnerData entry : spawn.getEntries()) {
builder.addSpawn(group, entry);
}
}
for(SpawnCostConfig cost : costs) {
builder.addMobCharge(cost.getType(), cost.getMass(), cost.getGravity());
}
if(probability != null) {
builder.creatureGenerationProbability(probability);
}
return builder.build();
}
}
@@ -0,0 +1,32 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import java.util.List;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
@Value("group")
@Default
private MobCategory group = null;
@Value("entries")
@Default
private List<SpawnerData> entries = null;
public MobCategory getGroup() {
return group;
}
public List<SpawnerData> getEntries() {
return entries;
}
@Override
public SpawnTypeConfig get() {
return this;
}
}
@@ -0,0 +1,23 @@
package com.dfsek.terra.bukkit.nms.v1_21.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryCodecs;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.npc.VillagerType;
public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
@Value("id")
@Default
private ResourceLocation id = null;
@Override
public VillagerType get() {
return BuiltInRegistries.VILLAGER_TYPE.get(id).orElseThrow().value();
}
}
@@ -60,13 +60,13 @@ public final class BiomeUtil {
} else {
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome,
net.minecraft.world.biome.Biome minecraftBiome = com.dfsek.terra.mod.util.BiomeUtil.createBiome(biome,
ForgeRegistries.BIOMES.getDelegateOrThrow(
vanilla.getKey().orElseThrow())
.value(),
vanillaBiomeProperties);
Identifier identifier = new Identifier("terra", MinecraftUtil.createBiomeID(pack, id));
Identifier identifier = new Identifier("terra", com.dfsek.terra.mod.util.BiomeUtil.createBiomeID(pack, id));
if(ForgeRegistries.BIOMES.containsKey(identifier)) {
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(ForgeRegistries.BIOMES.getHolder(identifier)
@@ -83,7 +83,7 @@ public final class BiomeUtil {
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
villagerMap.getOrDefault(vanilla.getKey().orElseThrow(), VillagerType.PLAINS)));
MinecraftUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.getKey().orElseThrow().getValue(), i -> new ArrayList<>()).add(
com.dfsek.terra.mod.util.BiomeUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.getKey().orElseThrow().getValue(), i -> new ArrayList<>()).add(
identifier);
}
}
@@ -51,7 +51,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
@Value("climate.precipitation")
@Default
private Boolean precipitation = true;
private Boolean precipitation = null;
@Value("climate.temperature")
@Default
@@ -0,0 +1,12 @@
package com.dfsek.terra.mod.mixin.invoke;
import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Biome.class)
public interface BiomeInvoker {
@Invoker("getDefaultGrassColor")
int invokeGetDefaultGrassColor();
}
@@ -0,0 +1,96 @@
package com.dfsek.terra.mod.util;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Builder;
import net.minecraft.world.biome.BiomeEffects;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.mod.config.VanillaBiomeProperties;
import com.dfsek.terra.mod.mixin.access.BiomeAccessor;
import com.dfsek.terra.mod.mixin.invoke.BiomeInvoker;
public class BiomeUtil {
public static final Map<Identifier, List<Identifier>>
TERRA_BIOME_MAP = new HashMap<>();
public static Biome createBiome(Biome vanilla, VanillaBiomeProperties vanillaBiomeProperties) {
BiomeEffects.Builder effects = new BiomeEffects.Builder();
net.minecraft.world.biome.Biome.Builder builder = new Builder();
effects.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
.grassColorModifier(
Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getEffects().getGrassColorModifier()))
.grassColor(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(),
vanilla.getEffects().getGrassColor().orElseGet(() -> ((BiomeInvoker) ((Object) vanilla)).invokeGetDefaultGrassColor())))
.foliageColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
if(vanillaBiomeProperties.getParticleConfig() == null) {
vanilla.getEffects().getParticleConfig().ifPresent(effects::particleConfig);
} else {
effects.particleConfig(vanillaBiomeProperties.getParticleConfig());
}
if(vanillaBiomeProperties.getLoopSound() == null) {
vanilla.getEffects().getLoopSound().ifPresent(effects::loopSound);
} else {
effects.loopSound(Registries.SOUND_EVENT.getEntry(vanillaBiomeProperties.getLoopSound()));
}
if(vanillaBiomeProperties.getMoodSound() == null) {
vanilla.getEffects().getMoodSound().ifPresent(effects::moodSound);
} else {
effects.moodSound(vanillaBiomeProperties.getMoodSound());
}
if(vanillaBiomeProperties.getAdditionsSound() == null) {
vanilla.getEffects().getAdditionsSound().ifPresent(effects::additionsSound);
} else {
effects.additionsSound(vanillaBiomeProperties.getAdditionsSound());
}
if(vanillaBiomeProperties.getMusic() == null) {
vanilla.getEffects().getMusic().ifPresent(effects::music);
} else {
effects.music(vanillaBiomeProperties.getMusic());
}
builder.precipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
builder.temperature(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperature(), vanilla.getTemperature()));
builder.downfall(Objects.requireNonNullElse(vanillaBiomeProperties.getDownfall(),
((BiomeAccessor) ((Object) vanilla)).getWeather().downfall()));
builder.temperatureModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperatureModifier(),
((BiomeAccessor) ((Object) vanilla)).getWeather().temperatureModifier()));
builder.spawnSettings(Objects.requireNonNullElse(vanillaBiomeProperties.getSpawnSettings(), vanilla.getSpawnSettings()));
return builder
.effects(effects.build())
.generationSettings(vanilla.getGenerationSettings())
.build();
}
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
return pack.getID()
.toLowerCase() + "/" + biomeID.getNamespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
}
public static Map<Identifier, List<Identifier>> getTerraBiomeMap() {
return Map.copyOf(TERRA_BIOME_MAP);
}
}
@@ -38,8 +38,6 @@ import com.dfsek.terra.mod.mixin_ifaces.FloraFeatureHolder;
public final class MinecraftUtil {
public static final Logger logger = LoggerFactory.getLogger(MinecraftUtil.class);
public static final Map<Identifier, List<Identifier>>
TERRA_BIOME_MAP = new HashMap<>();
private MinecraftUtil() {
@@ -64,7 +62,7 @@ public final class MinecraftUtil {
public static void registerFlora(Registry<net.minecraft.world.biome.Biome> biomes) {
logger.info("Injecting flora into Terra biomes...");
TERRA_BIOME_MAP
BiomeUtil.TERRA_BIOME_MAP
.forEach((vb, terraBiomes) ->
biomes.getOptionalValue(vb)
.ifPresentOrElse(vanilla -> terraBiomes
@@ -87,92 +85,7 @@ public final class MinecraftUtil {
}
public static Map<Identifier, List<Identifier>> getTerraBiomeMap() {
return Map.copyOf(TERRA_BIOME_MAP);
}
public static RegistryKey<Biome> registerKey(Identifier identifier) {
return RegistryKey.of(RegistryKeys.BIOME, identifier);
}
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla,
VanillaBiomeProperties vanillaBiomeProperties) {
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
BiomeEffects.Builder effects = new BiomeEffects.Builder();
net.minecraft.world.biome.Biome.Builder builder = new Builder();
effects.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getEffects().getGrassColorModifier()))
.grassColor(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(), vanilla.getEffects().getGrassColor().orElseGet(vanilla.getDefaultGrassColor())))
.foliageColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
if(vanillaBiomeProperties.getFoliageColor() == null) {
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
} else {
effects.foliageColor(vanillaBiomeProperties.getFoliageColor());
}
if(vanillaBiomeProperties.getGrassColor() == null) {
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
} else {
effects.grassColor(vanillaBiomeProperties.getGrassColor());
}
if(vanillaBiomeProperties.getParticleConfig() == null) {
vanilla.getEffects().getParticleConfig().ifPresent(effects::particleConfig);
} else {
effects.particleConfig(vanillaBiomeProperties.getParticleConfig());
}
if(vanillaBiomeProperties.getLoopSound() == null) {
vanilla.getEffects().getLoopSound().ifPresent(effects::loopSound);
} else {
effects.loopSound(Registries.SOUND_EVENT.getEntry(vanillaBiomeProperties.getLoopSound()));
}
if(vanillaBiomeProperties.getMoodSound() == null) {
vanilla.getEffects().getMoodSound().ifPresent(effects::moodSound);
} else {
effects.moodSound(vanillaBiomeProperties.getMoodSound());
}
if(vanillaBiomeProperties.getAdditionsSound() == null) {
vanilla.getEffects().getAdditionsSound().ifPresent(effects::additionsSound);
} else {
effects.additionsSound(vanillaBiomeProperties.getAdditionsSound());
}
if(vanillaBiomeProperties.getMusic() == null) {
vanilla.getEffects().getMusic().ifPresent(effects::music);
} else {
effects.music(vanillaBiomeProperties.getMusic());
}
builder.precipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
builder.temperature(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperature(), vanilla.getTemperature()));
builder.downfall(Objects.requireNonNullElse(vanillaBiomeProperties.getDownfall(),
((BiomeAccessor) ((Object) vanilla)).getWeather().downfall()));
builder.temperatureModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperatureModifier(),
((BiomeAccessor) ((Object) vanilla)).getWeather().temperatureModifier()));
builder.spawnSettings(Objects.requireNonNullElse(vanillaBiomeProperties.getSpawnSettings(), vanilla.getSpawnSettings()));
return builder
.effects(effects.build())
.generationSettings(generationSettings.build())
.build();
}
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
return pack.getID()
.toLowerCase() + "/" + biomeID.getNamespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
}
}
@@ -58,7 +58,7 @@ public final class TagUtil {
logger.info("Doing biome tag garbage....");
Map<TagKey<Biome>, List<RegistryEntry<Biome>>> collect = tagsToMutableMap(registry);
MinecraftUtil
BiomeUtil
.getTerraBiomeMap()
.forEach((vb, terraBiomes) ->
MinecraftUtil
@@ -26,7 +26,7 @@ import java.util.stream.Stream;
import com.dfsek.terra.addon.EphemeralAddon;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.lifecycle.util.BiomeUtil;
import com.dfsek.terra.lifecycle.util.LifecycleBiomeUtil;
import com.dfsek.terra.mod.CommonPlatform;
import com.dfsek.terra.mod.ModPlatform;
import com.dfsek.terra.mod.generation.MinecraftChunkGeneratorWrapper;
@@ -84,7 +84,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
if(server != null) {
BiomeUtil.registerBiomes(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME));
LifecycleBiomeUtil.registerBiomes(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME));
server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
LOGGER.warn("Failed to execute reload", throwable);
return null;
@@ -1,5 +1,7 @@
package com.dfsek.terra.lifecycle.util;
import com.dfsek.terra.mod.util.BiomeUtil;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
@@ -22,10 +24,10 @@ import com.dfsek.terra.mod.mixin.access.VillagerTypeAccessor;
import com.dfsek.terra.mod.util.MinecraftUtil;
public final class BiomeUtil {
private static final Logger logger = LoggerFactory.getLogger(BiomeUtil.class);
public final class LifecycleBiomeUtil {
private static final Logger logger = LoggerFactory.getLogger(LifecycleBiomeUtil.class);
private BiomeUtil() {
private LifecycleBiomeUtil() {
}
@@ -55,10 +57,10 @@ public final class BiomeUtil {
} else {
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)),
net.minecraft.world.biome.Biome minecraftBiome = BiomeUtil.createBiome(Objects.requireNonNull(registry.get(vanilla)),
vanillaBiomeProperties);
Identifier identifier = Identifier.of("terra", MinecraftUtil.createBiomeID(pack, id));
Identifier identifier = Identifier.of("terra", BiomeUtil.createBiomeID(pack, id));
if(registry.containsId(identifier)) {
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)
@@ -76,7 +78,7 @@ public final class BiomeUtil {
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
villagerMap.getOrDefault(vanilla, VillagerType.PLAINS)));
MinecraftUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.getValue(), i -> new ArrayList<>()).add(identifier);
BiomeUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.getValue(), i -> new ArrayList<>()).add(identifier);
}
}
@@ -20,7 +20,7 @@ public final class LifecycleUtil {
public static void initialize(MutableRegistry<Biome> biomeMutableRegistry, MutableRegistry<WorldPreset> worldPresetMutableRegistry) {
CommonPlatform.get().getEventManager().callEvent(new PlatformInitializationEvent());
BiomeUtil.registerBiomes(biomeMutableRegistry);
LifecycleBiomeUtil.registerBiomes(biomeMutableRegistry);
CommonPlatform.get().registerWorldTypes(
(id, preset) -> Registry.register(worldPresetMutableRegistry, RegistryKey.of(RegistryKeys.WORLD_PRESET, id), preset));
}