From 93835ca3ff63617104cd6d2b08936c4d7ed61828 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 2 Aug 2015 06:55:32 +0200 Subject: [PATCH] Added a Blacklist for the Ore Magnet, made ores not generate in flat worlds --- .../ellpeck/actuallyadditions/config/ConfigValues.java | 2 ++ .../java/ellpeck/actuallyadditions/gen/OreGen.java | 3 +++ .../actuallyadditions/tile/TileEntityOreMagnet.java | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java index b66cdaecd..a0d1caac1 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigValues.java @@ -15,6 +15,7 @@ public class ConfigValues{ public static String[] crusherRecipeExceptions; public static String[] mashedFoodCraftingExceptions; + public static String[] oreMagnetExceptions; public static void defineConfigValues(Configuration config){ @@ -33,5 +34,6 @@ public class ConfigValues{ crusherRecipeExceptions = config.getStringList("Crusher Recipe Exceptions", ConfigCategories.CRUSHER_RECIPES.name, new String[]{"ingotBrick", "ingotBrickNether"}, "The Ingots, Dusts and Ores blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."); mashedFoodCraftingExceptions = config.getStringList("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING.name, 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."); + oreMagnetExceptions = config.getStringList("Ore Magnet Exceptions", ConfigCategories.MACHINE_VALUES.name, new String[0], "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want any Ore not to be pulled up by the Magnet, put its ORE DICTIONARY name here."); } } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java index 298327c46..c36cd004e 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java @@ -11,6 +11,7 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import org.apache.logging.log4j.Level; @@ -21,6 +22,8 @@ public class OreGen implements IWorldGenerator{ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){ + if(world.provider.terrainType == WorldType.FLAT) return; + switch(world.provider.dimensionId){ case -1: generateNether(world, random, chunkX*16, chunkZ*16); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java index 301829259..0166e121c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java @@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; +import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; @@ -92,7 +93,7 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne for(int ID : oreIDs){ String oreName = OreDictionary.getOreName(ID); //Is the block an ore according to the OreDictionary? - if(oreName.substring(0, 3).equals("ore")){ + if(oreName.substring(0, 3).equals("ore") && !this.hasException(oreName)){ //Remove the Block worldObj.setBlockToAir(xCoord+x, y, zCoord+z); worldObj.playAuxSFX(2001, xCoord+x, y, zCoord+z, Block.getIdFromBlock(block)+(meta << 12)); @@ -129,6 +130,13 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne } } + private boolean hasException(String name){ + for(String except : ConfigValues.oreMagnetExceptions){ + if(except.equals(name)) return true; + } + return false; + } + @SideOnly(Side.CLIENT) public int getEnergyScaled(int i){ return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();