From 9b1041ad63eeae97ad1a430a389f6216c78b9a38 Mon Sep 17 00:00:00 2001 From: Amnet Date: Sat, 27 Apr 2013 15:37:08 +0200 Subject: [PATCH] Fixed adding biomes for world types. BOP biomes now accessible in Large Biomes World Type. Biome size is now specific to only BOP World Type. --- README.md | 1 + .../configuration/BOPBiomes.java | 332 +++++++++++++++++- .../configuration/BOPConfiguration.java | 6 +- .../biomesoplenty/helpers/WorldTypeSize.java | 3 +- .../biomesoplenty/worldtype/WTBiomesOP.java | 8 +- 5 files changed, 339 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 13d26f8fe..737fb6528 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ However, thanks to a little Java application I (Adubbz) whipped up, as well as t - Added Thaumcraft compatibility - Updated the regular BOP music disc file (courtesy of Forstride), may require deleting the old bopdisc.ogg to take effect - Allowed Forestry beehives to spawn on Biomes O Plenty certain blocks + - Fixed registering biomes for world types - BOP biomes now accessible in Large Biomes World Type Version 0.5.1 '17-04-2013' - Fixed server crash with mudballs diff --git a/src/minecraft/biomesoplenty/configuration/BOPBiomes.java b/src/minecraft/biomesoplenty/configuration/BOPBiomes.java index d3bf9496e..af04f43fe 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPBiomes.java +++ b/src/minecraft/biomesoplenty/configuration/BOPBiomes.java @@ -1,5 +1,10 @@ package biomesoplenty.configuration; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager; import biomesoplenty.api.Biomes; @@ -8,12 +13,16 @@ import biomesoplenty.worldtype.WTBiomesOP; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import com.google.common.base.Optional; +import com.google.common.collect.ImmutableSet; + import cpw.mods.fml.common.registry.GameRegistry; public class BOPBiomes { public static WTBiomesOP WTBiomesOP; + private static final Set worldTypes = new HashSet(); + public static int getLastBiomeID() { int x; @@ -34,6 +43,9 @@ public class BOPBiomes { //Initialize new world type WTBiomesOP = new WTBiomesOP(); + // Adding biomes to World Types + addBiomes(); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.jungleHills); //Biome Dictionary addToBiomeDictionary(); @@ -559,8 +571,8 @@ public class BOPBiomes { if (BOPConfiguration.mountainGen) registerBiome(Biomes.mountain); - if (BOPConfiguration.mushroomIslandGen) - GameRegistry.addBiome(BiomeGenBase.mushroomIsland); +// if (BOPConfiguration.mushroomIslandGen) +// GameRegistry.addBiome(BiomeGenBase.mushroomIsland); if (BOPConfiguration.mysticGroveGen) registerBiome(Biomes.mysticGrove); @@ -731,6 +743,322 @@ public class BOPBiomes { GameRegistry.removeBiome(BiomeGenBase.jungle); } } + + private static void addBiomes() + { + if (BOPConfiguration.alpsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.alps); + + if (BOPConfiguration.arcticGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.arctic); + + if (BOPConfiguration.badlandsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.badlands); + + if (BOPConfiguration.bambooForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.bambooForest); + + if (BOPConfiguration.bayouGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.bayou); + + if (BOPConfiguration.birchForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.birchForest); + + if (BOPConfiguration.bogGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.bog); + + if (BOPConfiguration.borealForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.borealForest); + + if (BOPConfiguration.canyonGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.canyon); + + if (BOPConfiguration.chaparralGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.chaparral); + + if (BOPConfiguration.cherryBlossomGroveGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.cherryBlossomGrove); + + if (BOPConfiguration.coniferousForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.coniferousForest); + + if (BOPConfiguration.cragGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.crag); + + if (BOPConfiguration.deadForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.deadForest); + + if (BOPConfiguration.deadSwampGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.deadSwamp); + + if (BOPConfiguration.deadlandsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.deadlands); + + if (BOPConfiguration.deciduousForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.deciduousForest); + + if (BOPConfiguration.drylandsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.drylands); + + if (BOPConfiguration.dunesGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.dunes); + + if (BOPConfiguration.fenGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.fen); + + if (BOPConfiguration.fieldGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.field); + + if (BOPConfiguration.frostForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.frostForest); + + if (BOPConfiguration.fungiForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.fungiForest); + + if (BOPConfiguration.gardenGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.garden); + + if (BOPConfiguration.glacierGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.glacier); + + if (BOPConfiguration.grasslandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.grassland); + + if (BOPConfiguration.groveGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.grove); + + if (BOPConfiguration.heathlandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.heathland); + + if (BOPConfiguration.highlandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.highland); + + if (BOPConfiguration.iceSheetGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.iceSheet); + + if (BOPConfiguration.icyHillsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.icyHills); + + if (BOPConfiguration.jadeCliffsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.jadeCliffs); + + if (BOPConfiguration.lushDesertGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.lushDesert); + + if (BOPConfiguration.lushSwampGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.lushSwamp); + + if (BOPConfiguration.mangroveGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.mangrove); + + if (BOPConfiguration.mapleWoodsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.mapleWoods); + + if (BOPConfiguration.marshGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.marsh); + + if (BOPConfiguration.meadowGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.meadow); + + if (BOPConfiguration.mesaGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.mesa); + + if (BOPConfiguration.moorGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.moor); + + if (BOPConfiguration.mountainGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.mountain); + + if (BOPConfiguration.mysticGroveGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.mysticGrove); + + if (BOPConfiguration.oasisGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.oasis); + + if (BOPConfiguration.ominousWoodsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.ominousWoods); + + if (BOPConfiguration.orchardGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.orchard); + + if (BOPConfiguration.originValleyGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.originValley); + + if (BOPConfiguration.outbackGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.outback); + + if (BOPConfiguration.pastureGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.pasture); + + if (BOPConfiguration.prairieGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.prairie); + + if (BOPConfiguration.quagmireGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.quagmire); + + if (BOPConfiguration.rainforestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.rainforest); + + if (BOPConfiguration.redwoodForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.redwoodForest); + + if (BOPConfiguration.sacredSpringsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.sacredSprings); + + if (BOPConfiguration.savannaGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.savanna); + + if (BOPConfiguration.scrublandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.scrubland); + + if (BOPConfiguration.seasonalForestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.seasonalForest); + + if (BOPConfiguration.shieldGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.shield); + + if (BOPConfiguration.shrublandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.shrubland); + + if (BOPConfiguration.snowyWoodsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.snowyWoods); + + if (BOPConfiguration.spruceWoodsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.spruceWoods); + + if (BOPConfiguration.steppeGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.steppe); + + if (BOPConfiguration.swampwoodsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.swampwoods); + + if (BOPConfiguration.temperateRainforestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.temperateRainforest); + + if (BOPConfiguration.thicketGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.thicket); + + if (BOPConfiguration.tropicalRainforestGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.tropicalRainforest); + + if (BOPConfiguration.tropicsGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.tropics); + + if (BOPConfiguration.tundraGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.tundra); + + if (BOPConfiguration.volcanoGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.volcano); + + if (BOPConfiguration.wastelandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.wasteland); + + if (BOPConfiguration.wetlandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.wetland); + + if (BOPConfiguration.woodlandGen) + addBiomeToWorldTypes(getWorldTypes(), Biomes.woodland); + + // Vanilla biomes generation + if (BOPConfiguration.plainsGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.plainsNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.plains); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.plains); + + if (BOPConfiguration.desertGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.desertNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.desert); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.desert); + + if (BOPConfiguration.extremeHillsGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.extremeHillsNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.extremeHills); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.extremeHills); + + if (BOPConfiguration.forestGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.forestNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.forest); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.forest); + + if (BOPConfiguration.taigaGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.taigaNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.taiga); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.taiga); + + if (BOPConfiguration.swamplandGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.swamplandNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.swampland); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.swampland); + + if (BOPConfiguration.jungleGen) + { + if (BOPConfiguration.vanillaEnhanced) + { + addBiomeToWorldTypes(getWorldTypes(), Biomes.jungleNew); + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.jungle); + } + } + else + removeBiomeFromWorldTypes(getWorldTypes(), BiomeGenBase.jungle); + } + + public static Set getWorldTypes() { + if (worldTypes.isEmpty()) { + worldTypes.add(WorldType.DEFAULT); + worldTypes.add(WorldType.LARGE_BIOMES); + worldTypes.add(WTBiomesOP); + } + return ImmutableSet.copyOf(worldTypes); + } + + private static void addBiomeToWorldTypes(Collection worldTypes, Optional biome) + { + for (final WorldType worldType : worldTypes) + if (biome.isPresent()) + worldType.addNewBiome(biome.get()); + } + + private static void removeBiomeFromWorldTypes(Collection worldTypes, BiomeGenBase biome) + { + for (final WorldType worldType : worldTypes) + worldType.removeBiome(biome); + } private static void addSpawnBiome(Optional biome) { diff --git a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java index 42f6d75f1..c2378e136 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java +++ b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java @@ -62,7 +62,7 @@ public class BOPConfiguration { public static boolean mesaGen; public static boolean moorGen; public static boolean mountainGen; - public static boolean mushroomIslandGen; +// public static boolean mushroomIslandGen; public static boolean mysticGroveGen; public static boolean oasisGen; public static boolean ominousWoodsGen; @@ -316,7 +316,7 @@ public class BOPConfiguration { config.load(); skyColors = true; - biomeSize = config.get("Biome Settings", "Biome Size", 4, null).getInt(); + biomeSize = config.get("Biomes O\' Plenty World Type Settings", "Biome Size", 5, "Default World Type has 4. Large Biomes Worl Type has 6.").getInt(); achievements = config.get("Achievement Settings", "Add Biomes O\' Plenty Achievements", true).getBoolean(false); vanillaEnhanced = config.get("Biome Settings", "Enhanced Vanilla Biomes", true).getBoolean(false); promisedLandDimID = config.get("Dimension Settings", "Promised Land Dimension ID", 20, null).getInt(); @@ -368,7 +368,7 @@ public class BOPConfiguration { mesaGen = config.get("Biomes To Generate", "Mesa", true).getBoolean(false); moorGen = config.get("Biomes To Generate", "Moor", true).getBoolean(false); mountainGen = config.get("Biomes To Generate", "Mountain", true).getBoolean(false); - mushroomIslandGen = config.get("Biomes To Generate", "MushroomIsland", true).getBoolean(false); +// mushroomIslandGen = config.get("Biomes To Generate", "MushroomIsland", true).getBoolean(false); mysticGroveGen = config.get("Biomes To Generate", "MysticGrove", true).getBoolean(false); oasisGen = config.get("Biomes To Generate", "Oasis", true).getBoolean(false); ominousWoodsGen = config.get("Biomes To Generate", "OminousWoods", true).getBoolean(false); diff --git a/src/minecraft/biomesoplenty/helpers/WorldTypeSize.java b/src/minecraft/biomesoplenty/helpers/WorldTypeSize.java index 4c642c288..abdb1611a 100644 --- a/src/minecraft/biomesoplenty/helpers/WorldTypeSize.java +++ b/src/minecraft/biomesoplenty/helpers/WorldTypeSize.java @@ -10,7 +10,8 @@ public class WorldTypeSize @ForgeSubscribe public void BiomeSize(WorldTypeEvent.BiomeSize event) { - event.newSize = (byte)BOPConfiguration.biomeSize; + if (event.worldType.getWorldTypeID() == 4) + event.newSize = (byte)BOPConfiguration.biomeSize; } } diff --git a/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java b/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java index 64dae9f81..311500dce 100644 --- a/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java +++ b/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java @@ -1,9 +1,11 @@ package biomesoplenty.worldtype; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.MinecraftForge; import biomesoplenty.api.Biomes; import biomesoplenty.configuration.BOPConfiguration; +import biomesoplenty.helpers.WorldTypeSize; import com.google.common.base.Optional; @@ -11,7 +13,7 @@ public class WTBiomesOP extends WorldTypeBase { public WTBiomesOP() { super(4, "BIOMESOP"); - //this.removeAllBiomes(); + this.removeAllBiomes(); this.removeBiome(BiomeGenBase.plains); this.removeBiome(BiomeGenBase.desert); this.removeBiome(BiomeGenBase.forest); @@ -184,10 +186,6 @@ public class WTBiomesOP extends WorldTypeBase { addNewBiome(Biomes.mountain); } - if (BOPConfiguration.mushroomIslandGen == true) - { - this.addNewBiome(BiomeGenBase.mushroomIsland); - } if (BOPConfiguration.mysticGroveGen == true) { addNewBiome(Biomes.mysticGrove);