Fix up blacklist for cardboard boxes!

This commit is contained in:
Aidan Brady 2014-01-18 00:45:27 -05:00
parent 705352e7c4
commit f5c607bef0
4 changed files with 50 additions and 12 deletions

View file

@ -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<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>();
private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>();
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;

View file

@ -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.");

View file

@ -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();

View file

@ -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;