From 84db3bbcefaba5fc0e99cd869c1884ad736829a5 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 20 Nov 2015 20:52:03 +0100 Subject: [PATCH] Added oregen and plantgen dimension blacklist --- .../config/ConfigValues.java | 5 +++++ .../event/WorldDecorationEvent.java | 14 +++++++----- .../ellpeck/actuallyadditions/gen/OreGen.java | 22 +++++++++++-------- .../ellpeck/actuallyadditions/util/Util.java | 9 ++++++++ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java index 43f7279e7..7522a0283 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java @@ -29,6 +29,9 @@ public class ConfigValues{ public static String[] paxelExtraMiningWhitelist; public static String[] drillExtraminingWhitelist; + public static int[] oreGenDimensionBlacklist; + public static int[] plantDimensionBlacklist; + public static void defineConfigValues(Configuration config){ for(ConfigCrafting currConf : craftingConfig){ @@ -48,5 +51,7 @@ public class ConfigValues{ mashedFoodCraftingExceptions = config.get(ConfigCategories.ITEMS_CRAFTING.name, "Mashed Food Crafting Exceptions", new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); paxelExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "AIOT Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); drillExtraminingWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "Drill Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList(); + oreGenDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "OreGen Dimension Blacklist", new int[0], "The IDs of the dimensions that Actually Additions OreGen (Black Quartz for example) is banned in").getIntList(); + plantDimensionBlacklist = config.get(ConfigCategories.WORLD_GEN.name, "Plant Blacklist", new int[0], "The IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in").getIntList(); } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java index 20c7b7ea6..10c19be4f 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java @@ -14,8 +14,10 @@ import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheWildPlants; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -29,11 +31,13 @@ public class WorldDecorationEvent{ @SubscribeEvent public void onWorldDecoration(DecorateBiomeEvent.Decorate event){ if((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)){ - this.generateRice(event); - this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.grass, event); - this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.grass, event); - this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.COFFEE.ordinal(), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.grass, event); - this.genPlantNormally(InitBlocks.blockBlackLotus, 0, ConfigIntValues.BLACK_LOTUS_AMOUNT.getValue(), ConfigBoolValues.DO_LOTUS_GEN.isEnabled(), Material.grass, event); + if(Util.arrayContains(ConfigValues.plantDimensionBlacklist, event.world.provider.dimensionId) < 0){ + this.generateRice(event); + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.grass, event); + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.grass, event); + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.COFFEE.ordinal(), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.grass, event); + this.genPlantNormally(InitBlocks.blockBlackLotus, 0, ConfigIntValues.BLACK_LOTUS_AMOUNT.getValue(), ConfigBoolValues.DO_LOTUS_GEN.isEnabled(), Material.grass, event); + } //Generate Treasure Chests if(ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()){ diff --git a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java index 7a268e8c6..4c0d74952 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java @@ -14,9 +14,11 @@ import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.registry.GameRegistry; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.Util; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; @@ -40,15 +42,17 @@ public class OreGen implements IWorldGenerator{ return; } - switch(world.provider.dimensionId){ - case -1: - generateNether(world, random, chunkX*16, chunkZ*16); - //case 0: - // generateSurface(world, random, chunkX*16, chunkZ*16); - case 1: - generateEnd(world, random, chunkX*16, chunkZ*16); - default: - generateSurface(world, random, chunkX*16, chunkZ*16); + if(Util.arrayContains(ConfigValues.oreGenDimensionBlacklist, world.provider.dimensionId) < 0){ + switch(world.provider.dimensionId){ + case -1: + generateNether(world, random, chunkX*16, chunkZ*16); + //case 0: + // generateSurface(world, random, chunkX*16, chunkZ*16); + case 1: + generateEnd(world, random, chunkX*16, chunkZ*16); + default: + generateSurface(world, random, chunkX*16, chunkZ*16); + } } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/Util.java b/src/main/java/ellpeck/actuallyadditions/util/Util.java index a8ad80c7c..cbf11eb1f 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/Util.java +++ b/src/main/java/ellpeck/actuallyadditions/util/Util.java @@ -48,6 +48,15 @@ public class Util{ return -1; } + public static int arrayContains(int[] array, int num){ + for(int i = 0; i < array.length; i++){ + if(num == array[i]){ + return i; + } + } + return -1; + } + public static class GetRecipes{ public static CrusherRecipeRegistry.CrusherRecipe lastCrusherRecipe(){