Added checks to prevent biome id conflicts with BoP

This commit is contained in:
Adubbz 2015-12-31 19:47:00 +11:00
parent d4f31617f6
commit bf25777886
3 changed files with 59 additions and 7 deletions

View file

@ -39,7 +39,7 @@ public class ModBiomes
private static int nextBiomeId = 40;
private static File biomeIdMapFile;
private static BOPConfig.IConfigObj biomeIdMapConf;
private static Map<String, Integer> biomeIdMap;
protected static Map<String, Integer> biomeIdMap;
private static Set<Integer> idsReservedInConfig;
public static Map<Integer, List<Integer>> subBiomesMap;
public static Map<Integer, List<Integer>> mutatedBiomesMap;

View file

@ -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<String, Integer> biomeIdMap = ModBiomes.biomeIdMap;
for (Entry<String, Integer> 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");
}
}

View file

@ -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)
{