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.
This commit is contained in:
parent
2245e85773
commit
e401a69782
1 changed files with 29 additions and 2 deletions
|
@ -113,14 +113,22 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
|
||||
if (oilDesertBiomeId > 0) {
|
||||
if (BiomeGenBase.getBiomeGenArray () [oilDesertBiomeId] != null) {
|
||||
throw new BiomeIdException("oilDesert", oilDesertBiomeId);
|
||||
//throw new BiomeIdException("oilDesert", oilDesertBiomeId);
|
||||
oilDesertBiomeId = findUnusedBiomeID("oilDesert");
|
||||
// save changes to config file
|
||||
BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId);
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertBiomeId);
|
||||
}
|
||||
|
||||
if (oilOceanBiomeId > 0) {
|
||||
if (BiomeGenBase.getBiomeGenArray () [oilOceanBiomeId] != null) {
|
||||
throw new BiomeIdException("oilOcean", oilOceanBiomeId);
|
||||
//throw new BiomeIdException("oilOcean", oilOceanBiomeId);
|
||||
oilOceanBiomeId = findUnusedBiomeID("oilOcean");
|
||||
// save changes to config file
|
||||
BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId);
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId);
|
||||
}
|
||||
|
@ -248,6 +256,25 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
'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 BiomeIdLimitExceptio(biomeName);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
|
||||
InterModComms.processIMC(event);
|
||||
|
|
Loading…
Reference in a new issue