From 477741ff490c4d6fd77f45adf433f7e67b20fc05 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 4 Dec 2022 15:57:53 +0000 Subject: [PATCH] Added config option to disable butterflies. #83 --- .../com/minelittlepony/unicopia/Config.java | 4 ++++ .../unicopia/entity/UEntities.java | 24 ++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/Config.java b/src/main/java/com/minelittlepony/unicopia/Config.java index 146b8511..a12d3170 100644 --- a/src/main/java/com/minelittlepony/unicopia/Config.java +++ b/src/main/java/com/minelittlepony/unicopia/Config.java @@ -30,6 +30,10 @@ public class Config extends com.minelittlepony.common.util.settings.Config { .addComment("Disables this mod's built in fix for making sea plants waterlogged") .addComment("Turn this ON if you're using another mod that does something similar of if you encounter copatibility issues with other mods."); + public final Setting disableButterflySpawning = value("compatibility", "disableButterflySpawning", false) + .addComment("Removes butterflies from spawning in your world") + .addComment("Turn this ON if you have another mod that adds butterflies."); + public Config() { super(HEIRARCHICAL_JSON_ADAPTER, GamePaths.getConfigDirectory().resolve("unicopia.json")); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java index 2f1eb0f7..ca0a1dcd 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java @@ -62,18 +62,20 @@ public interface UEntities { FabricDefaultAttributeRegistry.register(TWITTERMITE, FairyEntity.createMobAttributes()); FabricDefaultAttributeRegistry.register(AIR_BALLOON, FlyingEntity.createMobAttributes()); - final Predicate butterflySpawnable = BiomeSelectors.foundInOverworld() - .and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN); + if (!Unicopia.getConfig().disableButterflySpawning.get()) { + final Predicate butterflySpawnable = BiomeSelectors.foundInOverworld() + .and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN); - BiomeModifications.addSpawn(butterflySpawnable.and( - BiomeSelectors.tag(BiomeTags.IS_RIVER) - .or(BiomeSelectors.tag(BiomeTags.IS_FOREST)) - .or(BiomeSelectors.tag(BiomeTags.IS_HILL)) - ), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12); - BiomeModifications.addSpawn(butterflySpawnable.and( - BiomeSelectors.tag(BiomeTags.IS_JUNGLE) - .or(BiomeSelectors.tag(BiomeTags.IS_MOUNTAIN)) - ), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19); + BiomeModifications.addSpawn(butterflySpawnable.and( + BiomeSelectors.tag(BiomeTags.IS_RIVER) + .or(BiomeSelectors.tag(BiomeTags.IS_FOREST)) + .or(BiomeSelectors.tag(BiomeTags.IS_HILL)) + ), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12); + BiomeModifications.addSpawn(butterflySpawnable.and( + BiomeSelectors.tag(BiomeTags.IS_JUNGLE) + .or(BiomeSelectors.tag(BiomeTags.IS_MOUNTAIN)) + ), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19); + } UTradeOffers.bootstrap(); EntityBehaviour.bootstrap();