2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei;
|
|
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
import codechicken.nei.api.ItemFilter;
|
|
|
|
|
import net.minecraft.block.Block;
|
2014-04-29 10:54:20 +10:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
public class ItemStackSet implements ItemFilter
|
2014-04-29 10:54:20 +10:00
|
|
|
{
|
|
|
|
|
ItemStackMap<Object> underlying = new ItemStackMap<Object>();
|
|
|
|
|
|
2014-06-29 20:31:37 +10:00
|
|
|
public ItemStackSet with(ItemStack... items) {
|
|
|
|
|
for(ItemStack item : items)
|
|
|
|
|
add(item);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStackSet with(Item... items) {
|
|
|
|
|
for(Item item : items)
|
|
|
|
|
add(ItemStackMap.wildcard(item));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStackSet with(Block... blocks) {
|
|
|
|
|
for(Block block : blocks)
|
|
|
|
|
add(ItemStackMap.wildcard(Item.getItemFromBlock(block)));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
public void add(ItemStack item) {
|
|
|
|
|
underlying.put(item, new Object());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean remove(ItemStack item) {
|
|
|
|
|
return underlying.remove(item) != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean contains(ItemStack item) {
|
|
|
|
|
return underlying.get(item) != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean containsAll(Item item) {
|
2014-06-29 20:31:37 +10:00
|
|
|
return underlying.get(ItemStackMap.wildcard(item)) != null;
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ItemStack> values() {
|
|
|
|
|
return underlying.keys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clear() {
|
|
|
|
|
underlying.clear();
|
|
|
|
|
}
|
2014-06-29 20:31:37 +10:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean matches(ItemStack item) {
|
|
|
|
|
return contains(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int size() {
|
|
|
|
|
return underlying.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isEmpty() {
|
|
|
|
|
return underlying.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ItemStackSet of(Block... blocks) {
|
|
|
|
|
return new ItemStackSet().with(blocks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ItemStackSet of(Item... items) {
|
|
|
|
|
return new ItemStackSet().with(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ItemStackSet of(ItemStack... items) {
|
|
|
|
|
return new ItemStackSet().with(items);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|