equivalent-exchange-3/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java

120 lines
2.9 KiB
Java
Raw Normal View History

package com.pahimar.ee3.emc;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import com.pahimar.ee3.item.CustomWrappedStack;
public class EmcBlackList {
private static EmcBlackList emcBlackList = null;
private ArrayList<CustomWrappedStack> stackBlackList = new ArrayList<CustomWrappedStack>();
private EmcBlackList() {
}
public static EmcBlackList getInstance() {
2013-05-27 02:09:29 +02:00
if (emcBlackList == null) {
emcBlackList = new EmcBlackList();
2013-05-27 02:09:29 +02:00
emcBlackList.init();
}
return emcBlackList;
}
2013-07-11 21:41:10 +02:00
public List<CustomWrappedStack> getBlackList() {
return stackBlackList;
}
2013-07-11 21:41:10 +02:00
public boolean add(Object object) {
2013-07-11 21:41:10 +02:00
boolean wasAdded = false;
if (CustomWrappedStack.canBeWrapped(object)) {
CustomWrappedStack wrappedStack = new CustomWrappedStack(object);
wrappedStack.setStackSize(1);
if (!stackBlackList.contains(wrappedStack)) {
stackBlackList.add(wrappedStack);
wasAdded = true;
}
}
2013-07-11 21:41:10 +02:00
return wasAdded;
}
2013-07-11 21:41:10 +02:00
public boolean contains(Object object) {
2013-07-11 21:41:10 +02:00
if (CustomWrappedStack.canBeWrapped(object)) {
CustomWrappedStack wrappedStack = new CustomWrappedStack(object);
wrappedStack.setStackSize(1);
return stackBlackList.contains(wrappedStack);
}
2013-07-11 21:41:10 +02:00
return false;
}
2013-07-11 21:41:10 +02:00
public boolean remove(Object object) {
2013-07-11 21:41:10 +02:00
boolean wasRemoved = false;
if (CustomWrappedStack.canBeWrapped(object)) {
CustomWrappedStack wrappedStack = new CustomWrappedStack(object);
wrappedStack.setStackSize(1);
if (stackBlackList.contains(wrappedStack)) {
stackBlackList.remove(wrappedStack);
wasRemoved = true;
}
}
2013-07-11 21:41:10 +02:00
return wasRemoved;
}
2013-05-27 02:09:29 +02:00
private void init() {
2013-05-27 02:09:29 +02:00
add(Block.bed);
add(Block.pistonExtension);
add(Block.pistonMoving);
add(Block.mobSpawner);
add(Block.redstoneWire);
add(Block.crops);
add(Block.furnaceBurning);
add(Block.signPost);
add(Block.doorWood);
add(Block.signWall);
add(Block.doorIron);
add(Block.torchRedstoneIdle);
add(Block.reed);
add(Block.portal);
add(Block.cake);
add(Block.redstoneRepeaterIdle);
add(Block.redstoneRepeaterActive);
add(Block.lockedChest);
add(Block.pumpkinStem);
add(Block.melonStem);
add(Block.netherStalk);
add(Block.brewingStand);
add(Block.cauldron);
add(Block.endPortal);
add(Block.redstoneLampActive);
add(Block.commandBlock);
add(Block.carrot);
add(Block.potato);
add(Block.skull);
add(Block.redstoneComparatorIdle);
add(Block.redstoneComparatorActive);
}
}