diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiome.java b/src/main/java/biomesoplenty/api/biome/BOPBiome.java index 38f2d1801..9428fa8e8 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiome.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiome.java @@ -13,29 +13,29 @@ import net.minecraft.world.biome.BiomeGenBase; public class BOPBiome extends BiomeGenBase implements IExtendedBiome { - private GenerationManager generationManager = new GenerationManager(); - - public BOPBiome() - { - super(-1, false); - - this.theBiomeDecorator.treesPerChunk = -999; - this.theBiomeDecorator.flowersPerChunk = -999; - this.theBiomeDecorator.grassPerChunk = -999; - this.theBiomeDecorator.sandPerChunk = -999; - this.theBiomeDecorator.sandPerChunk2 = -999; - this.theBiomeDecorator.clayPerChunk = -999; - } + private GenerationManager generationManager = new GenerationManager(); - @Override - public BiomeOwner getBiomeOwner() - { - return BiomeOwner.BIOMESOPLENTY; - } + public BOPBiome() + { + super(-1, false); - @Override - public GenerationManager getGenerationManager() - { - return this.generationManager; - } + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.flowersPerChunk = -999; + this.theBiomeDecorator.grassPerChunk = -999; + this.theBiomeDecorator.sandPerChunk = -999; + this.theBiomeDecorator.sandPerChunk2 = -999; + this.theBiomeDecorator.clayPerChunk = -999; + } + + @Override + public BiomeOwner getBiomeOwner() + { + return BiomeOwner.BIOMESOPLENTY; + } + + @Override + public GenerationManager getGenerationManager() + { + return this.generationManager; + } } diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiomes.java b/src/main/java/biomesoplenty/api/biome/BOPBiomes.java index d537f860a..cba81a9ae 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiomes.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiomes.java @@ -12,5 +12,5 @@ import net.minecraft.world.biome.BiomeGenBase; public class BOPBiomes { - public static BiomeGenBase alps; + public static BiomeGenBase alps; } diff --git a/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java b/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java index 5b792ed88..39cd6032c 100644 --- a/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java +++ b/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java @@ -20,85 +20,85 @@ import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate; public class ExtendedBiomeRegistry { - private static Map externalExtensions = new HashMap(); - - public static boolean isRegistered(BiomeGenBase biome) - { - return biome.biomeID != -1; - } - - public static BiomeExtension createExtension(BiomeGenBase biome) - { - return externalExtensions.put(biome, new BiomeExtension(biome)); - } - - public static IExtendedBiome getExtension(BiomeGenBase biome) - { - if (biome instanceof IExtendedBiome) - { - return (IExtendedBiome)biome; - } - else if (externalExtensions.containsKey(biome)) - { - return externalExtensions.get(biome); - } - - return null; - } - - public static class BiomeExtension implements IExtendedBiome - { - public BiomeGenBase biome; - private GenerationManager generationManager = new GenerationManager(); - - private BiomeExtension(BiomeGenBase biome) - { - this.biome = biome; - } - - @Override - public BiomeOwner getBiomeOwner() - { - return BiomeOwner.OTHER; - } + private static Map externalExtensions = new HashMap(); - @Override - public GenerationManager getGenerationManager() - { - return this.generationManager; - } - } - - public static class GenerationManager - { - private Map> generatorMap = new HashMap(); - //TODO: Come up with a better sequencing system - private Map generatorSequenceMap = new HashMap();; - - public void addGenerator(String key, IGenerator generator, Decorate.EventType nextFeature) - { - this.generatorMap.put(key, generator); - this.generatorSequenceMap.put(key, nextFeature); - } - - public void addGenerator(String key, IGenerator generator) - { - this.addGenerator(key, generator, Decorate.EventType.CUSTOM); - } + public static boolean isRegistered(BiomeGenBase biome) + { + return biome.biomeID != -1; + } - public void configureGenerators(Map> generatorMap) - { - this.generatorMap.putAll(generatorMap); - } + public static BiomeExtension createExtension(BiomeGenBase biome) + { + return externalExtensions.put(biome, new BiomeExtension(biome)); + } - public Map> getGeneratorMap() - { - return Collections.unmodifiableMap(this.generatorMap); - } - - public Decorate.EventType getGeneratorStage(String key) - { - return generatorSequenceMap.get(key); - } - } + public static IExtendedBiome getExtension(BiomeGenBase biome) + { + if (biome instanceof IExtendedBiome) + { + return (IExtendedBiome)biome; + } + else if (externalExtensions.containsKey(biome)) + { + return externalExtensions.get(biome); + } + + return null; + } + + public static class BiomeExtension implements IExtendedBiome + { + public BiomeGenBase biome; + private GenerationManager generationManager = new GenerationManager(); + + private BiomeExtension(BiomeGenBase biome) + { + this.biome = biome; + } + + @Override + public BiomeOwner getBiomeOwner() + { + return BiomeOwner.OTHER; + } + + @Override + public GenerationManager getGenerationManager() + { + return this.generationManager; + } + } + + public static class GenerationManager + { + private Map> generatorMap = new HashMap(); + //TODO: Come up with a better sequencing system + private Map generatorSequenceMap = new HashMap();; + + public void addGenerator(String key, IGenerator generator, Decorate.EventType nextFeature) + { + this.generatorMap.put(key, generator); + this.generatorSequenceMap.put(key, nextFeature); + } + + public void addGenerator(String key, IGenerator generator) + { + this.addGenerator(key, generator, Decorate.EventType.CUSTOM); + } + + public void configureGenerators(Map> generatorMap) + { + this.generatorMap.putAll(generatorMap); + } + + public Map> getGeneratorMap() + { + return Collections.unmodifiableMap(this.generatorMap); + } + + public Decorate.EventType getGeneratorStage(String key) + { + return generatorSequenceMap.get(key); + } + } } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenAlps.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenAlps.java index 8845f4761..fe1da3b45 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenAlps.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenAlps.java @@ -13,16 +13,16 @@ import biomesoplenty.api.biome.BOPBiome; public class BiomeGenAlps extends BOPBiome { - private static final Height biomeHeight = new Height(8.0F, 0.025F); - - public BiomeGenAlps() - { - this.setHeight(biomeHeight); + private static final Height biomeHeight = new Height(8.0F, 0.025F); + + public BiomeGenAlps() + { + this.setHeight(biomeHeight); this.setColor(13421772); this.setEnableSnow(); this.setTemperatureRainfall(0.0F, 0.5F); - - this.topBlock = Blocks.snow.getDefaultState(); - this.fillerBlock = Blocks.snow.getDefaultState(); - } + + this.topBlock = Blocks.snow.getDefaultState(); + this.fillerBlock = Blocks.snow.getDefaultState(); + } } diff --git a/src/main/java/biomesoplenty/common/config/BiomeConfigurationHandler.java b/src/main/java/biomesoplenty/common/config/BiomeConfigurationHandler.java index 94ec56f43..c1ba4892a 100644 --- a/src/main/java/biomesoplenty/common/config/BiomeConfigurationHandler.java +++ b/src/main/java/biomesoplenty/common/config/BiomeConfigurationHandler.java @@ -80,16 +80,16 @@ public class BiomeConfigurationHandler public static void translateVanillaValues(BiomeGenBase biome) { - /*IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome); + /*IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome); GenerationManager generationManager = extendedBiome.getGenerationManager(); - + if (extendedBiome.getBiomeOwner() == BiomeOwner.OTHER) { if (biome.theBiomeDecorator.cactiPerChunk > 0) { WorldGenCactus cactusGen = new WorldGenCactus(); IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen) cactusGen; - + extendedCactusGen.setCactiPerChunk(biome.theBiomeDecorator.cactiPerChunk); generationManager.addGenerator("cactus", extendedCactusGen, Decorate.EventType.CACTUS); biome.theBiomeDecorator.cactiPerChunk = 0; @@ -99,42 +99,42 @@ public class BiomeConfigurationHandler private static void configureBiomeWithJson(BiomeGenBase biome, JsonBiome jsonBiome) { - IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome); + IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome); - if (extendedBiome != null) - { - GenerationManager generationManager = extendedBiome.getGenerationManager(); + if (extendedBiome != null) + { + GenerationManager generationManager = extendedBiome.getGenerationManager(); - if (extendedBiome.getBiomeOwner() == BiomeOwner.BIOMESOPLENTY) - { - if (jsonBiome.biomeId != -1) - { - biome.biomeID = jsonBiome.biomeId; - BiomeGenBase.getBiomeGenArray()[jsonBiome.biomeId] = biome; - } - else - { - biome.biomeID = -1; - } - } + if (extendedBiome.getBiomeOwner() == BiomeOwner.BIOMESOPLENTY) + { + if (jsonBiome.biomeId != -1) + { + biome.biomeID = jsonBiome.biomeId; + BiomeGenBase.getBiomeGenArray()[jsonBiome.biomeId] = biome; + } + else + { + biome.biomeID = -1; + } + } - biome.biomeName = jsonBiome.biomeName; - biome.topBlock = jsonBiome.topBlock; - biome.fillerBlock = jsonBiome.fillerBlock; - biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation)); - biome.temperature = jsonBiome.temperature; - biome.rainfall = jsonBiome.rainfall; - // TODO: Reflect and modify enableRain and enableSnow - biome.color = jsonBiome.color; - biome.waterColorMultiplier = jsonBiome.waterColorMultiplier; - JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome); + biome.biomeName = jsonBiome.biomeName; + biome.topBlock = jsonBiome.topBlock; + biome.fillerBlock = jsonBiome.fillerBlock; + biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation)); + biome.temperature = jsonBiome.temperature; + biome.rainfall = jsonBiome.rainfall; + // TODO: Reflect and modify enableRain and enableSnow + biome.color = jsonBiome.color; + biome.waterColorMultiplier = jsonBiome.waterColorMultiplier; + JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome); - generationManager.configureGenerators(jsonBiome.decoration); - } + generationManager.configureGenerators(jsonBiome.decoration); + } } - + public static Map getConfigFileMap() { - return BiomeConfigurationHandler.configFileMap; + return BiomeConfigurationHandler.configFileMap; } } diff --git a/src/main/java/biomesoplenty/common/config/MiscConfigurationHandler.java b/src/main/java/biomesoplenty/common/config/MiscConfigurationHandler.java index dc00e1ba8..1cea1c509 100644 --- a/src/main/java/biomesoplenty/common/config/MiscConfigurationHandler.java +++ b/src/main/java/biomesoplenty/common/config/MiscConfigurationHandler.java @@ -15,28 +15,28 @@ import net.minecraftforge.common.config.Configuration; public class MiscConfigurationHandler { - public static Configuration config; - - public static boolean useBoPWorldTypeDefault; - + public static Configuration config; + + public static boolean useBoPWorldTypeDefault; + public static void init(File configFile) { - config = new Configuration(configFile); + config = new Configuration(configFile); - try - { - config.load(); - - //TODO: Make this default to true once all biomes have been implemented - useBoPWorldTypeDefault = config.getBoolean("Default to BoP World Type", "GUI Settings", false, "Use the Biomes O' Plenty World Type by default when selecting a world."); - } - catch (Exception e) - { - BiomesOPlenty.logger.error("Biomes O' Plenty has encountered a problem loading misc.cfg", e); - } - finally - { - if (config.hasChanged()) config.save(); - } + try + { + config.load(); + + //TODO: Make this default to true once all biomes have been implemented + useBoPWorldTypeDefault = config.getBoolean("Default to BoP World Type", "GUI Settings", false, "Use the Biomes O' Plenty World Type by default when selecting a world."); + } + catch (Exception e) + { + BiomesOPlenty.logger.error("Biomes O' Plenty has encountered a problem loading misc.cfg", e); + } + finally + { + if (config.hasChanged()) config.save(); + } } } diff --git a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java index deaf33dc4..48578b894 100644 --- a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java +++ b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java @@ -29,21 +29,21 @@ public class DecorateBiomeEventHandler BlockPos pos = event.pos.add(16, 0, 16); BiomeGenBase biome = world.getBiomeGenForCoords(pos); IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome); - + if (extendedBiome != null) { - GenerationManager generationManager = extendedBiome.getGenerationManager(); + GenerationManager generationManager = extendedBiome.getGenerationManager(); - for (Entry> entry : generationManager.getGeneratorMap().entrySet()) - { - String key = entry.getKey(); - IGenerator generator = entry.getValue(); + for (Entry> entry : generationManager.getGeneratorMap().entrySet()) + { + String key = entry.getKey(); + IGenerator generator = entry.getValue(); - if (generationManager.getGeneratorStage(key) == event.type) - { - generator.generate(world, event.rand, event.pos); - } - } + if (generationManager.getGeneratorStage(key) == event.type) + { + generator.generate(world, event.rand, event.pos); + } + } } } } diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index adf398edb..69473cce0 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -21,27 +21,27 @@ import biomesoplenty.common.world.WorldTypeBOP; public class ModBiomes { public static WorldTypeBOP worldTypeBOP; - + private static int nextBiomeId = 40; public static void init() { worldTypeBOP = new WorldTypeBOP(); - + registerBiomes(); registerExternalBiomes(); } - + private static void registerBiomes() { - alps = registerBiome(new BiomeGenAlps().setBiomeName("Alps"), "alps"); - - BiomeManager.addBiome(BiomeType.DESERT, new BiomeEntry(alps, 100)); - BiomeManager.addBiome(BiomeType.WARM, new BiomeEntry(alps, 100)); - BiomeManager.addBiome(BiomeType.COOL, new BiomeEntry(alps, 100)); - BiomeManager.addBiome(BiomeType.ICY, new BiomeEntry(alps, 100)); + alps = registerBiome(new BiomeGenAlps().setBiomeName("Alps"), "alps"); + + BiomeManager.addBiome(BiomeType.DESERT, new BiomeEntry(alps, 100)); + BiomeManager.addBiome(BiomeType.WARM, new BiomeEntry(alps, 100)); + BiomeManager.addBiome(BiomeType.COOL, new BiomeEntry(alps, 100)); + BiomeManager.addBiome(BiomeType.ICY, new BiomeEntry(alps, 100)); } - + private static void registerExternalBiomes() { registerExternalBiome(BiomeGenBase.ocean, "ocean"); @@ -85,38 +85,38 @@ public class ModBiomes registerExternalBiome(BiomeGenBase.mesaPlateau_F, "mesa_plateau_f"); registerExternalBiome(BiomeGenBase.mesaPlateau, "mesa_plateau"); } - + private static BiomeGenBase registerBiome(BiomeGenBase biome, String id) { - biome.biomeID = getNextFreeBiomeId(); + biome.biomeID = getNextFreeBiomeId(); BiomeConfigurationHandler.getConfigFileMap().put(biome, id); - + return biome; } - + private static void registerExternalBiome(BiomeGenBase biome, String id) { - ExtendedBiomeRegistry.createExtension(biome); + ExtendedBiomeRegistry.createExtension(biome); BiomeConfigurationHandler.translateVanillaValues(biome); BiomeConfigurationHandler.getConfigFileMap().put(biome, id); } - + public static int getNextFreeBiomeId() { - for (int i = nextBiomeId; i < 256; i++) - { - if (BiomeGenBase.getBiomeGenArray()[i] != null) - { - if (i == 255) throw new IllegalArgumentException("There are no more biome ids avaliable!"); - continue; - } - else - { - nextBiomeId = i + 1; - return i; - } - } + for (int i = nextBiomeId; i < 256; i++) + { + if (BiomeGenBase.getBiomeGenArray()[i] != null) + { + if (i == 255) throw new IllegalArgumentException("There are no more biome ids avaliable!"); + continue; + } + else + { + nextBiomeId = i + 1; + return i; + } + } - return -1; + return -1; } } diff --git a/src/main/java/biomesoplenty/common/init/ModConfiguration.java b/src/main/java/biomesoplenty/common/init/ModConfiguration.java index 321fbce17..93988f3b6 100644 --- a/src/main/java/biomesoplenty/common/init/ModConfiguration.java +++ b/src/main/java/biomesoplenty/common/init/ModConfiguration.java @@ -17,9 +17,9 @@ public class ModConfiguration { public static void init(File configDirectory) { - MiscConfigurationHandler.init(new File(configDirectory, "misc.cfg")); + MiscConfigurationHandler.init(new File(configDirectory, "misc.cfg")); } - + public static void initEnd(File configDirectory) { BiomeConfigurationHandler.init(new File(configDirectory, "biomes")); diff --git a/src/main/java/biomesoplenty/common/util/config/JsonEntitySpawn.java b/src/main/java/biomesoplenty/common/util/config/JsonEntitySpawn.java index db1c1c747..ee9d7defd 100644 --- a/src/main/java/biomesoplenty/common/util/config/JsonEntitySpawn.java +++ b/src/main/java/biomesoplenty/common/util/config/JsonEntitySpawn.java @@ -57,20 +57,20 @@ public class JsonEntitySpawn for (JsonEntitySpawn entitySpawn : jsonBiome.entities) { - if (entitySpawn != null) - { - try - { - EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase()); - Class entityClass = Class.forName(entitySpawn.entityClass); + if (entitySpawn != null) + { + try + { + EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase()); + Class entityClass = Class.forName(entitySpawn.entityClass); - biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount)); - } - catch (ClassNotFoundException e) - { - e.printStackTrace(); - } - } + biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount)); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } } } }