From a016be6919d267b89c7a338505f5876c9e7b9107 Mon Sep 17 00:00:00 2001 From: fabricator77 Date: Thu, 3 Apr 2014 12:36:08 +1030 Subject: [PATCH] Auto assign Biome Ids Finds unused Biome IDs if the ones in the config are in use by other mods. Also saves change to config file. Changed default Biome Ids to 126 and 127 which are just below a block used by Minecraft. --- common/buildcraft/BuildCraftEnergy.java | 20 +++++++++++++++++++- common/buildcraft/core/DefaultProps.java | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 4bb28de1..65b96e35 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -133,7 +133,6 @@ public class BuildCraftEnergy extends BuildCraftMod { biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId); } - engineBlock = new BlockEngine(); CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class); @@ -255,6 +254,25 @@ public class BuildCraftEnergy extends BuildCraftMod { CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", 'w', Items.iron_ingot, 'g', Blocks.glass, 'G', BuildCraftCore.ironGearItem, 'p', Blocks.piston}); } + + private int findUnusedBiomeID (String biomeName) { + int freeBiomeID = 0; + // code to find a free biome + for (int i=1; i<256; i++) { + if (BiomeGenBase.getBiomeGenArray()[i] == null) { + freeBiomeID = i; + return freeBiomeID; + } + } + // failed to find any free biome IDs + class BiomeIdLimitException extends RuntimeException { + public BiomeIdLimitException(String biome) { + super(String.format("You have a run out of free Biome Ids for %s", biome)); + } + } + + throw new BiomeIdLimitException(biomeName); + } private int findUnusedBiomeID (String biomeName) { int freeBiomeID = 0; diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 33d77c54..2c056f9f 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -124,6 +124,6 @@ public class DefaultProps { public static final int FILLER_LIFESPAN_TOUGH = 20; public static final int FILLER_LIFESPAN_NORMAL = 6000; - public static int BIOME_OIL_OCEAN = 215; - public static int BIOME_OIL_DESERT = 216; + public static int BIOME_OIL_OCEAN = 126; + public static int BIOME_OIL_DESERT = 127; }