use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModifierInventory method setInventorySlotContents.
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
if (index >= stacks.size()) {
return;
}
stacks.set(index, stack);
if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit()) {
stack.setCount(getInventoryStackLimit());
}
convertItemsToNBT(tagCompound, stacks);
markDirty();
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModifierInventory method decrStackSize.
@Override
public ItemStack decrStackSize(int index, int amount) {
NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
if (index >= stacks.size()) {
return ItemStack.EMPTY;
}
if (!stacks.get(index).isEmpty()) {
if (stacks.get(index).getCount() <= amount) {
ItemStack old = stacks.get(index);
stacks.set(index, ItemStack.EMPTY);
convertItemsToNBT(tagCompound, stacks);
markDirty();
return old;
}
ItemStack its = stacks.get(index).splitStack(amount);
if (stacks.get(index).isEmpty()) {
stacks.set(index, ItemStack.EMPTY);
convertItemsToNBT(tagCompound, stacks);
}
markDirty();
return its;
}
return ItemStack.EMPTY;
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModifierInventory method getStackInSlot.
@Override
public ItemStack getStackInSlot(int index) {
NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
return stacks.get(index);
}
use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.
the class CraftingStationTileEntity method request.
public boolean request(ItemStack item, @Nullable Inventory destination) {
for (BlockPos p : processorList) {
TileEntity te = getWorld().getTileEntity(p);
if (te instanceof ProcessorTileEntity) {
ProcessorTileEntity processor = (ProcessorTileEntity) te;
ItemStackList items = ItemStackList.create();
processor.getCraftableItems(items);
for (ItemStack i : items) {
if (item.isItemEqual(i)) {
String ticket = getNewTicket(destination);
if (!checkRequestAmount()) {
return false;
}
activeCraftingRequests.add(new CraftingRequest(ticket, i, 1));
processor.fireCraftEvent(ticket, i);
return true;
}
}
}
}
return false;
}
use of mcjty.lib.varia.ItemStackList in project XNet by McJty.
the class ItemConnectorSettings method getMatcher.
public Predicate<ItemStack> getMatcher() {
if (matcher == null) {
ItemStackList filterList = ItemStackList.create();
for (ItemStack stack : filters) {
if (!stack.isEmpty()) {
filterList.add(stack);
}
}
if (filterList.isEmpty()) {
matcher = itemStack -> true;
} else {
ItemFilterCache filterCache = new ItemFilterCache(metaMode, oredictMode, blacklist, nbtMode, filterList);
matcher = filterCache::match;
}
}
return matcher;
}
Aggregations