use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.
the class CraftingStationTileEntity method findItem.
private int findItem(String itemName, int meta, String nbtString) {
int index = 0;
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 item : items) {
if (item.getItemDamage() == meta && itemName.equals(item.getItem().getRegistryName().toString())) {
if (item.hasTagCompound()) {
if (nbtString.equalsIgnoreCase(item.serializeNBT().toString())) {
return index;
}
} else {
return index;
}
}
index++;
}
}
}
return -1;
}
use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.
the class CraftingStationTileEntity method findCraftableItem.
private Pair<ProcessorTileEntity, ItemStack> findCraftableItem(int index) {
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 item : items) {
if (index == 0) {
// found!
return Pair.of(processor, item);
}
index--;
}
}
}
return null;
}
use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.
the class CraftingCardItem method getStacksFromItem.
public static ItemStackList getStacksFromItem(ItemStack craftingCard) {
NBTTagCompound tagCompound = craftingCard.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
craftingCard.setTagCompound(tagCompound);
}
ItemStackList stacks = ItemStackList.create(CraftingCardContainer.INPUT_SLOTS + 1);
NBTTagList bufferTagList = tagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < bufferTagList.tagCount(); i++) {
NBTTagCompound nbtTagCompound = bufferTagList.getCompoundTagAt(i);
stacks.set(i, new ItemStack(nbtTagCompound));
}
return stacks;
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class RemoteStorageItemInventory method isItemValidForSlot.
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
ItemStackList s = getStacks();
if (index >= s.size()) {
return false;
}
if (isServer()) {
RemoteStorageTileEntity storage = getRemoteStorage();
if (storage == null) {
return false;
}
int si = storage.findRemoteIndex(getStorageID());
if (si == -1) {
return false;
}
if (index >= storage.getMaxStacks(si)) {
return false;
}
}
return true;
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class RemoteStorageTileEntity method decrStackSizeRemote.
public ItemStack decrStackSizeRemote(int si, int index, int amount) {
if (index >= slots[si].size()) {
return ItemStack.EMPTY;
}
ItemStackList stacks = slots[si];
boolean hasOld = !stacks.get(index).isEmpty();
ItemStack its = ItemStack.EMPTY;
if (!stacks.get(index).isEmpty()) {
if (stacks.get(index).getCount() <= amount) {
ItemStack old = stacks.get(index);
stacks.set(index, ItemStack.EMPTY);
its = old;
} else {
its = stacks.get(index).splitStack(amount);
if (stacks.get(index).isEmpty()) {
stacks.set(index, ItemStack.EMPTY);
}
}
}
boolean hasNew = !stacks.get(index).isEmpty();
if (hasOld && !hasNew) {
numStacks[si]--;
} else if (hasNew && !hasOld) {
numStacks[si]++;
}
StorageModuleItem.updateStackSize(getStackInSlot(si), numStacks[si]);
markDirty();
return its;
}
Aggregations