diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index a12ea67bc..b2625b8cc 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -39,7 +39,7 @@ public class ModBiomes private static int nextBiomeId = 40; private static File biomeIdMapFile; private static BOPConfig.IConfigObj biomeIdMapConf; - private static Map biomeIdMap; + protected static Map biomeIdMap; private static Set idsReservedInConfig; public static Map> subBiomesMap; public static Map> mutatedBiomesMap; diff --git a/src/main/java/biomesoplenty/common/init/ModChecks.java b/src/main/java/biomesoplenty/common/init/ModChecks.java new file mode 100644 index 000000000..d0715a83b --- /dev/null +++ b/src/main/java/biomesoplenty/common/init/ModChecks.java @@ -0,0 +1,37 @@ +package biomesoplenty.common.init; + +import java.util.Map; +import java.util.Map.Entry; + +import biomesoplenty.common.util.biome.BiomeUtils; +import biomesoplenty.core.BiomesOPlenty; +import net.minecraft.world.biome.BiomeGenBase; + +public class ModChecks +{ + public static void postInit() + { + verifyBiomeIds(); + } + + private static void verifyBiomeIds() + { + BiomesOPlenty.logger.info("Checking for biome id conflicts..."); + + Map biomeIdMap = ModBiomes.biomeIdMap; + + for (Entry entry : biomeIdMap.entrySet()) + { + String biomeIdentifier = entry.getKey(); + int id = entry.getValue(); + BiomeGenBase biome = BiomeGenBase.getBiome(id); + + if (biome == null || !BiomeUtils.getBiomeIdentifier(biome).equals(biomeIdentifier)) + { + throw new RuntimeException("Unexpected biome " + biome.biomeName + " for id " + id + ". This is not a bug, please ensure your biome ids are configured to be unique."); + } + } + + BiomesOPlenty.logger.info("No conflicts found"); + } +} diff --git a/src/main/java/biomesoplenty/core/BiomesOPlenty.java b/src/main/java/biomesoplenty/core/BiomesOPlenty.java index 324a7e4e5..10b913428 100644 --- a/src/main/java/biomesoplenty/core/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/core/BiomesOPlenty.java @@ -10,6 +10,21 @@ package biomesoplenty.core; import java.io.File; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import biomesoplenty.common.command.BOPCommand; +import biomesoplenty.common.init.ModBiomes; +import biomesoplenty.common.init.ModBlockQueries; +import biomesoplenty.common.init.ModBlocks; +import biomesoplenty.common.init.ModChecks; +import biomesoplenty.common.init.ModConfiguration; +import biomesoplenty.common.init.ModCrafting; +import biomesoplenty.common.init.ModEntities; +import biomesoplenty.common.init.ModGenerators; +import biomesoplenty.common.init.ModHandlers; +import biomesoplenty.common.init.ModItems; +import biomesoplenty.common.init.ModPotions; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; @@ -19,12 +34,6 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import biomesoplenty.common.command.BOPCommand; -import biomesoplenty.common.init.*; - @Mod(modid = BiomesOPlenty.MOD_ID, name = BiomesOPlenty.MOD_NAME, dependencies = "required-after:Forge@[11.14.3.1468,)") public class BiomesOPlenty { @@ -67,6 +76,12 @@ public class BiomesOPlenty proxy.registerRenderers(); } + @EventHandler + public void postInit(FMLPostInitializationEvent event) + { + ModChecks.postInit(); + } + @EventHandler public void serverStarting(FMLServerStartingEvent event) {