use of forestry.core.gui.slots.SlotCrafter in project ForestryMC by ForestryMC.
the class SlotUtil method transferStackInSlot.
public static ItemStack transferStackInSlot(List<Slot> inventorySlots, EntityPlayer player, int slotIndex) {
Slot slot = inventorySlots.get(slotIndex);
if (slot == null || !slot.getHasStack()) {
return ItemStack.EMPTY;
}
boolean fromCraftingSlot = slot instanceof SlotCrafting || slot instanceof SlotCrafter;
int numSlots = inventorySlots.size();
ItemStack stackInSlot = slot.getStack();
ItemStack originalStack = stackInSlot.copy();
if (!shiftItemStack(inventorySlots, stackInSlot, slotIndex, numSlots, fromCraftingSlot)) {
return ItemStack.EMPTY;
}
slot.onSlotChange(stackInSlot, originalStack);
if (stackInSlot.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (stackInSlot.getCount() == originalStack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTake(player, stackInSlot);
return originalStack;
}
Aggregations