diff --git a/common/mekanism/api/MekanismAPI.java b/common/mekanism/api/MekanismAPI.java index c920bdfd0..d500de6a9 100644 --- a/common/mekanism/api/MekanismAPI.java +++ b/common/mekanism/api/MekanismAPI.java @@ -3,12 +3,45 @@ package mekanism.api; import java.util.HashSet; import java.util.Set; +import net.minecraftforge.oredict.OreDictionary; + public class MekanismAPI { //Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes - public static Set cardboardBoxIgnore = new HashSet(); + private static Set cardboardBoxIgnore = new HashSet(); - public static class BlockInfo + public static boolean isBlockCompatible(int id, int meta) + { + boolean has = false; + + for(BlockInfo i : cardboardBoxIgnore) + { + if(i.id == id && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta)) + { + has = true; + break; + } + } + + if(!has) + { + return true; + } + + return false; + } + + public static void addBoxBlacklist(int id, int meta) + { + cardboardBoxIgnore.add(new BlockInfo(id, meta)); + } + + public static void removeBoxBlacklist(int id, int meta) + { + cardboardBoxIgnore.remove(new BlockInfo(id, meta)); + } + + private static class BlockInfo { public int id; public int meta; diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index d58c61164..12be3a848 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -3,7 +3,6 @@ package mekanism.common; import java.io.File; import mekanism.api.MekanismAPI; -import mekanism.api.MekanismAPI.BlockInfo; import mekanism.common.entity.EntityRobit; import mekanism.common.inventory.container.ContainerAdvancedElectricMachine; import mekanism.common.inventory.container.ContainerChanceMachine; @@ -209,10 +208,10 @@ public class CommonProxy if(Mekanism.cardboardSpawners) { - MekanismAPI.cardboardBoxIgnore.remove(new BlockInfo(Block.mobSpawner.blockID, 0)); + MekanismAPI.removeBoxBlacklist(Block.mobSpawner.blockID, 0); } else { - MekanismAPI.cardboardBoxIgnore.add(new BlockInfo(Block.mobSpawner.blockID, 0)); + MekanismAPI.addBoxBlacklist(Block.mobSpawner.blockID, 0); } Mekanism.enrichmentChamberUsage = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D).getDouble(50D); @@ -408,10 +407,10 @@ public class CommonProxy { if(Mekanism.cardboardSpawners) { - MekanismAPI.cardboardBoxIgnore.remove(new BlockInfo(Block.mobSpawner.blockID, 0)); + MekanismAPI.removeBoxBlacklist(Block.mobSpawner.blockID, 0); } else { - MekanismAPI.cardboardBoxIgnore.add(new BlockInfo(Block.mobSpawner.blockID, 0)); + MekanismAPI.addBoxBlacklist(Block.mobSpawner.blockID, 0); } System.out.println("[Mekanism] Received config from server."); diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 77c4398be..2c755cda2 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -10,12 +10,12 @@ import java.util.Map; import java.util.Set; import java.util.logging.Logger; +import codechicken.multipart.handler.MultipartProxy; import mekanism.api.ChanceOutput; import mekanism.api.ChemicalPair; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismAPI; -import mekanism.api.MekanismAPI.BlockInfo; import mekanism.api.gas.Gas; import mekanism.api.gas.GasNetwork.GasTransferEvent; import mekanism.api.gas.GasRegistry; @@ -1123,8 +1123,15 @@ public class Mekanism addRecipes(); addEntities(); - MekanismAPI.cardboardBoxIgnore.add(new BlockInfo(BoundingBlock.blockID, 0)); - MekanismAPI.cardboardBoxIgnore.add(new BlockInfo(BoundingBlock.blockID, 1)); + MekanismAPI.addBoxBlacklist(BoundingBlock.blockID, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Block.bedrock.blockID, 0); + MekanismAPI.addBoxBlacklist(Block.portal.blockID, 0); + MekanismAPI.addBoxBlacklist(Block.endPortal.blockID, 0); + MekanismAPI.addBoxBlacklist(Block.endPortalFrame.blockID, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Block.bed.blockID, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Block.doorWood.blockID, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Block.doorIron.blockID, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(MultipartProxy.block().blockID, OreDictionary.WILDCARD_VALUE); registerOreDict(); diff --git a/common/mekanism/common/item/ItemBlockCardboardBox.java b/common/mekanism/common/item/ItemBlockCardboardBox.java index 8e28149df..7ff1343d7 100644 --- a/common/mekanism/common/item/ItemBlockCardboardBox.java +++ b/common/mekanism/common/item/ItemBlockCardboardBox.java @@ -4,7 +4,6 @@ import java.util.List; import mekanism.api.EnumColor; import mekanism.api.MekanismAPI; -import mekanism.api.MekanismAPI.BlockInfo; import mekanism.common.Mekanism; import mekanism.common.block.BlockCardboardBox.BlockData; import mekanism.common.tile.TileEntityCardboardBox; @@ -76,7 +75,7 @@ public class ItemBlockCardboardBox extends ItemBlock int id = world.getBlockId(x, y, z); int meta = world.getBlockMetadata(x, y, z); - if(!world.isRemote && !MekanismAPI.cardboardBoxIgnore.contains(new BlockInfo(id, meta))) + if(!world.isRemote && !MekanismAPI.isBlockCompatible(id, meta)) { BlockData data = new BlockData(); data.id = id;