From e8d90642ed65089a172d7f34b18792212b25f00b Mon Sep 17 00:00:00 2001 From: Adubbz Date: Wed, 4 Jun 2014 17:32:30 +1000 Subject: [PATCH] Removed old default world hackery in favour of the new Forge 1110 biome system. In turn, the mod now requires 1110+ --- build.properties | 4 +- .../biomesoplenty/api/BOPBiomeManager.java | 12 +- .../BOPConfigurationStrongholds.java | 2 +- .../structures/BOPConfigurationVillages.java | 2 +- .../biomesoplenty/common/core/BOPBiomes.java | 2 +- .../common/eventhandler/BOPEventHandlers.java | 2 - .../world/DefaultWorldEventHandler.java | 142 ------------------ .../common/world/layer/GenLayerBiomeBOP.java | 14 +- .../common/world/layer/GenLayerSubBiome.java | 2 +- .../layer/hell/BiomeLayerHellBiomes.java | 4 +- 10 files changed, 20 insertions(+), 166 deletions(-) delete mode 100644 src/main/java/biomesoplenty/common/eventhandler/world/DefaultWorldEventHandler.java diff --git a/build.properties b/build.properties index 1b0bed13a..3256c9a0e 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,3 @@ minecraft_version=1.7.2 -forge_version=10.12.1.1074 +forge_version=10.12.1.1110 mod_version=2.0.0 -worldcore_version=1.1.0.17 -fmp_version=1.0.0.182 diff --git a/src/main/java/biomesoplenty/api/BOPBiomeManager.java b/src/main/java/biomesoplenty/api/BOPBiomeManager.java index 45a88bde7..58b3ce5fe 100644 --- a/src/main/java/biomesoplenty/api/BOPBiomeManager.java +++ b/src/main/java/biomesoplenty/api/BOPBiomeManager.java @@ -5,6 +5,7 @@ import java.util.List; import net.minecraft.util.WeightedRandom; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import biomesoplenty.common.configuration.BOPConfigurationBiomeGen; import biomesoplenty.common.configuration.BOPConfigurationBiomeWeights; import biomesoplenty.common.configuration.BOPConfigurationIDs; @@ -95,15 +96,4 @@ public class BOPBiomeManager public static final int COOL = 2; public static final int ICY = 3; } - - public static class BiomeEntry extends WeightedRandom.Item - { - public BiomeGenBase biome; - - public BiomeEntry(BiomeGenBase biome, int weight) - { - super(weight); - this.biome = biome; - } - } } diff --git a/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationStrongholds.java b/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationStrongholds.java index 2ec188649..212759b42 100644 --- a/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationStrongholds.java +++ b/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationStrongholds.java @@ -6,12 +6,12 @@ import java.util.List; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import net.minecraftforge.common.config.Configuration; import org.apache.logging.log4j.Level; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; import biomesoplenty.api.content.BOPCBiomes; import cpw.mods.fml.common.FMLLog; diff --git a/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationVillages.java b/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationVillages.java index b936e8230..313b68804 100644 --- a/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationVillages.java +++ b/src/main/java/biomesoplenty/common/configuration/structures/BOPConfigurationVillages.java @@ -6,12 +6,12 @@ import java.util.List; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import net.minecraftforge.common.config.Configuration; import org.apache.logging.log4j.Level; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; import biomesoplenty.api.content.BOPCBiomes; import cpw.mods.fml.common.FMLLog; diff --git a/src/main/java/biomesoplenty/common/core/BOPBiomes.java b/src/main/java/biomesoplenty/common/core/BOPBiomes.java index 5d7fd28ac..5a573cfaa 100644 --- a/src/main/java/biomesoplenty/common/core/BOPBiomes.java +++ b/src/main/java/biomesoplenty/common/core/BOPBiomes.java @@ -10,11 +10,11 @@ import net.minecraft.world.biome.WorldChunkManager; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.BiomeManager; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import org.apache.logging.log4j.Level; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; import biomesoplenty.api.BOPBiomeManager.TemperatureType; import biomesoplenty.api.content.BOPCBiomes; import biomesoplenty.common.biomes.nether.BiomeGenBoneyard; diff --git a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java index 4f7f17279..c8b0bdf32 100755 --- a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java +++ b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java @@ -14,7 +14,6 @@ import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler; import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler; import biomesoplenty.common.eventhandler.world.BiomeSizeEventHandler; import biomesoplenty.common.eventhandler.world.DecorationModificationEventHandler; -import biomesoplenty.common.eventhandler.world.DefaultWorldEventHandler; import biomesoplenty.common.eventhandler.world.MapGenEventHandler; import biomesoplenty.common.eventhandler.world.VillageMaterialEventHandler; import cpw.mods.fml.common.FMLCommonHandler; @@ -38,7 +37,6 @@ public class BOPEventHandlers private static void registerWorldEventHandlers() { - MinecraftForge.TERRAIN_GEN_BUS.register(new DefaultWorldEventHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new DecorationModificationEventHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeSizeEventHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMaterialEventHandler()); diff --git a/src/main/java/biomesoplenty/common/eventhandler/world/DefaultWorldEventHandler.java b/src/main/java/biomesoplenty/common/eventhandler/world/DefaultWorldEventHandler.java deleted file mode 100644 index 895e79265..000000000 --- a/src/main/java/biomesoplenty/common/eventhandler/world/DefaultWorldEventHandler.java +++ /dev/null @@ -1,142 +0,0 @@ -package biomesoplenty.common.eventhandler.world; - -import org.apache.logging.log4j.Level; - -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.layer.GenLayer; -import net.minecraft.world.gen.layer.GenLayerBiome; -import net.minecraft.world.gen.layer.GenLayerRiverMix; -import net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; -import biomesoplenty.common.configuration.BOPConfigurationBiomeGen; -import biomesoplenty.common.configuration.BOPConfigurationIDs; -import biomesoplenty.common.configuration.BOPConfigurationMain; -import biomesoplenty.common.core.BOPBiomes; -import biomesoplenty.common.utils.BOPLogger; -import biomesoplenty.common.world.layer.GenLayerBiomeBOP; -import cpw.mods.fml.common.ObfuscationReflectionHelper; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class DefaultWorldEventHandler -{ - @SubscribeEvent(priority=EventPriority.LOWEST) - public void onInitBiomeGens(InitBiomeGens event) - { - if (event.worldType == BOPBiomes.worldTypeBOP) - { - GenLayer[] originalBiomeGens = event.originalBiomeGens; - - GenLayer parent = originalBiomeGens[0]; - GenLayerBiomeBOP genLayerBiome = null; - - if (parent instanceof GenLayerRiverMix) - { - GenLayerRiverMix genLayerRiverMix = (GenLayerRiverMix)parent; - GenLayer biomePatternGeneratorChain = ObfuscationReflectionHelper.getPrivateValue(GenLayerRiverMix.class, genLayerRiverMix, "biomePatternGeneratorChain", "field_75910_b"); - - if (biomePatternGeneratorChain != null) parent = biomePatternGeneratorChain; - } - - while (genLayerBiome == null) - { - if (parent instanceof GenLayerBiomeBOP) - { - genLayerBiome = (GenLayerBiomeBOP)parent; - } - - GenLayer newParent = ObfuscationReflectionHelper.getPrivateValue(GenLayer.class, parent, "parent", "field_75909_a"); - - if (newParent == null) - { - throw new RuntimeException("Failed to find GenLayerBiome in chain"); - } - else - { - parent = newParent; - } - } - - if (genLayerBiome != null) - { - try - { - BOPConfigurationBiomeGen.config.load(); - BiomeGenBase[] vanillaDesertBiomes = (BiomeGenBase[])ObfuscationReflectionHelper.getPrivateValue(GenLayerBiome.class, genLayerBiome, "field_151623_c"); - BiomeGenBase[] vanillaWarmBiomes = (BiomeGenBase[])ObfuscationReflectionHelper.getPrivateValue(GenLayerBiome.class, genLayerBiome, "field_151621_d"); - BiomeGenBase[] vanillaCoolBiomes = (BiomeGenBase[])ObfuscationReflectionHelper.getPrivateValue(GenLayerBiome.class, genLayerBiome, "field_151622_e"); - BiomeGenBase[] vanillaIcyBiomes = (BiomeGenBase[])ObfuscationReflectionHelper.getPrivateValue(GenLayerBiome.class, genLayerBiome, "field_151620_f"); - - - for (BiomeGenBase biome : vanillaDesertBiomes) - { - if (biome != null) - { - if (BOPConfigurationMain.debugMode) BOPLogger.info("Adding biome " + biome.biomeName + " from the default world."); - - BiomeEntry entry = new BiomeEntry(biome, 10); - - if (BOPConfigurationBiomeGen.config.get("Default World" + " Biomes To Generate", biome.biomeName, true).getBoolean(false)) - { - genLayerBiome.biomeLists[0].add(entry); - } - } - } - - for (BiomeGenBase biome : vanillaWarmBiomes) - { - if (biome != null) - { - if (BOPConfigurationMain.debugMode) BOPLogger.info("Adding biome " + biome.biomeName + " from the default world."); - - BiomeEntry entry = new BiomeEntry(biome, 10); - - if (BOPConfigurationBiomeGen.config.get("Default World" + " Biomes To Generate", biome.biomeName, true).getBoolean(false)) - { - genLayerBiome.biomeLists[1].add(entry); - } - } - } - - for (BiomeGenBase biome : vanillaCoolBiomes) - { - if (biome != null) - { - if (BOPConfigurationMain.debugMode) BOPLogger.info("Adding biome " + biome.biomeName + " from the default world."); - - BiomeEntry entry = new BiomeEntry(biome, 10); - - if (BOPConfigurationBiomeGen.config.get("Default World" + " Biomes To Generate", biome.biomeName, true).getBoolean(false)) - { - genLayerBiome.biomeLists[2].add(entry); - } - } - } - - for (BiomeGenBase biome : vanillaIcyBiomes) - { - if (biome != null) - { - if (BOPConfigurationMain.debugMode) BOPLogger.info("Adding biome " + biome.biomeName + " from the default world."); - - BiomeEntry entry = new BiomeEntry(biome, 10); - - if (BOPConfigurationBiomeGen.config.get("Default World" + " Biomes To Generate", biome.biomeName, true).getBoolean(false)) - { - genLayerBiome.biomeLists[3].add(entry); - } - } - } - } - catch (Exception e) - { - BOPLogger.log(Level.ERROR, "Biomes O Plenty has had a problem loading its configuration", e); - } - finally - { - if (BOPConfigurationBiomeGen.config.hasChanged()) BOPConfigurationBiomeGen.config.save(); - } - } - } - } -} diff --git a/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java b/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java index ad13595ea..39ce2cfc1 100644 --- a/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java +++ b/src/main/java/biomesoplenty/common/world/layer/GenLayerBiomeBOP.java @@ -10,8 +10,9 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.GenLayerBiome; import net.minecraft.world.gen.layer.IntCache; +import net.minecraftforge.common.BiomeManager; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; import biomesoplenty.common.configuration.BOPConfigurationBiomeGen; import biomesoplenty.common.core.BOPBiomes; @@ -28,6 +29,15 @@ public class GenLayerBiomeBOP extends GenLayerBiome this.biomeLists[1].addAll(BOPBiomeManager.overworldBiomes[1]); this.biomeLists[2].addAll(BOPBiomeManager.overworldBiomes[2]); this.biomeLists[3].addAll(BOPBiomeManager.overworldBiomes[3]); + + this.biomeLists[0].addAll(BiomeManager.desertBiomes); + this.biomeLists[1].addAll(BiomeManager.warmBiomes); + this.biomeLists[2].addAll(BiomeManager.coolBiomes); + this.biomeLists[3].addAll(BiomeManager.icyBiomes); + + this.biomeLists[0].add(new BiomeEntry(BiomeGenBase.desert, 30)); + this.biomeLists[0].add(new BiomeEntry(BiomeGenBase.savanna, 20)); + this.biomeLists[0].add(new BiomeEntry(BiomeGenBase.plains, 10)); } @@ -157,7 +167,7 @@ public class GenLayerBiomeBOP extends GenLayerBiome private int getWeightedBiomeFromList(List biomeList) { - return ((BiomeEntry)WeightedRandom.getItem(biomeList, this.nextInt(WeightedRandom.getTotalWeight(biomeList)))).biome.biomeID; + return ((BiomeEntry)WeightedRandom.getItem(biomeList, (int)this.nextLong(WeightedRandom.getTotalWeight(biomeList) / 10) * 10)).biome.biomeID; } private boolean isBiomeOceanicAndEnabled(int biomeId) diff --git a/src/main/java/biomesoplenty/common/world/layer/GenLayerSubBiome.java b/src/main/java/biomesoplenty/common/world/layer/GenLayerSubBiome.java index 92664c44e..3ba97fd40 100644 --- a/src/main/java/biomesoplenty/common/world/layer/GenLayerSubBiome.java +++ b/src/main/java/biomesoplenty/common/world/layer/GenLayerSubBiome.java @@ -5,11 +5,11 @@ import java.util.List; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.IntCache; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import org.apache.commons.lang3.tuple.Pair; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; import biomesoplenty.common.biomes.BOPSubBiome; import biomesoplenty.common.world.noise.SimplexNoise; diff --git a/src/main/java/biomesoplenty/common/world/layer/hell/BiomeLayerHellBiomes.java b/src/main/java/biomesoplenty/common/world/layer/hell/BiomeLayerHellBiomes.java index 8c8de7c25..229e4d0b2 100644 --- a/src/main/java/biomesoplenty/common/world/layer/hell/BiomeLayerHellBiomes.java +++ b/src/main/java/biomesoplenty/common/world/layer/hell/BiomeLayerHellBiomes.java @@ -6,8 +6,8 @@ import java.util.List; import net.minecraft.util.WeightedRandom; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.IntCache; +import net.minecraftforge.common.BiomeManager.BiomeEntry; import biomesoplenty.api.BOPBiomeManager; -import biomesoplenty.api.BOPBiomeManager.BiomeEntry; public class BiomeLayerHellBiomes extends BiomeLayerHell { @@ -43,6 +43,6 @@ public class BiomeLayerHellBiomes extends BiomeLayerHell private int getWeightedBiomeFromList(List biomeList) { - return ((BiomeEntry)WeightedRandom.getItem(biomeList, this.nextInt(WeightedRandom.getTotalWeight(biomeList)))).biome.biomeID; + return ((BiomeEntry)WeightedRandom.getItem(biomeList, (int)this.nextLong(WeightedRandom.getTotalWeight(biomeList) / 10) * 10)).biome.biomeID; } } \ No newline at end of file