use of com.bluepowermod.container.inventory.InventoryProjectTableCrafting in project BluePower by Qmunity.
the class TileAutoProjectTable method removeItem.
@Override
public ItemStack removeItem(int slot, int amount) {
if (slot == OUTPUT_SLOT) {
InventoryProjectTableCrafting craftingInv = new InventoryProjectTableCrafting(null, this, 3, 3);
ItemStack itemstack = ItemStack.EMPTY;
Optional<ICraftingRecipe> optional = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, craftingInv, level);
if (optional.isPresent()) {
ICraftingRecipe icraftingrecipe = optional.get();
itemstack = icraftingrecipe.assemble(craftingInv);
}
for (int i = 0; i < 9; i++) {
ItemStack slotStack = craftingGrid.get(i);
if (slotStack.getCount() == 1) {
// Get items from the Inventory to Craft
for (int ptSlot = 0; ptSlot < 19; ++ptSlot) {
if (ptSlot == 18) {
// No available items so end here to keep template
return ItemStack.EMPTY;
}
ItemStack ptStack = getItem(ptSlot);
if (ptStack.getItem() == slotStack.getItem() && ptStack.getTag() == slotStack.getTag()) {
slotStack.setCount(2);
craftingGrid.set(i, slotStack);
removeItem(ptSlot, 1);
break;
}
}
}
}
for (int i = 0; i < 9; i++) {
ItemStack currentItem = craftingGrid.get(i);
currentItem.setCount(currentItem.getCount() - 1);
craftingGrid.set(i, currentItem);
}
return itemstack;
} else {
return super.removeItem(slot, amount);
}
}
use of com.bluepowermod.container.inventory.InventoryProjectTableCrafting in project BluePower by Qmunity.
the class TileAutoProjectTable method getItem.
@Override
public ItemStack getItem(int i) {
if (i == OUTPUT_SLOT) {
InventoryProjectTableCrafting craftingInv = new InventoryProjectTableCrafting(null, this, 3, 3);
ItemStack itemstack = ItemStack.EMPTY;
Optional<ICraftingRecipe> optional = level.getServer().getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, craftingInv, level);
if (optional.isPresent()) {
ICraftingRecipe icraftingrecipe = optional.get();
itemstack = icraftingrecipe.assemble(craftingInv);
}
return itemstack;
} else {
return super.getItem(i);
}
}
Aggregations