use of crazypants.enderio.base.machine.baselegacy.SlotDefinition in project EnderIO by SleepyTrousers.
the class AbstractMachineContainer method transferStackInSlot.
@Override
@Nonnull
public ItemStack transferStackInSlot(@Nonnull EntityPlayer entityPlayer, int slotNumber) {
hasAlreadyJustSuccessfullyTransferedAStack = false;
SlotDefinition slotDef = te.getSlotDefinition();
ItemStack copystack = Prep.getEmpty();
Slot slot = inventorySlots.get(slotNumber);
if (slot != null && slot.getHasStack()) {
ItemStack origStack = slot.getStack();
if (Prep.isValid(origStack)) {
copystack = origStack.copy();
boolean merged = false;
for (SlotRange range : getTargetSlotsForTransfer(slotNumber, slot)) {
if (mergeItemStack(origStack, range.getStart(), range.getEnd(), range.reverse)) {
while (mergeItemStack(origStack, range.getStart(), range.getEnd(), range.reverse)) {
}
merged = true;
break;
}
}
if (!merged) {
return Prep.getEmpty();
}
if (slotDef.isOutputSlot(slot.getSlotIndex())) {
slot.onSlotChange(origStack, copystack);
}
if (Prep.isInvalid(origStack)) {
slot.putStack(Prep.getEmpty());
} else {
slot.onSlotChanged();
}
if (origStack.getCount() == copystack.getCount()) {
return Prep.getEmpty();
}
slot.onTake(entityPlayer, origStack);
}
}
hasAlreadyJustSuccessfullyTransferedAStack = true;
return copystack;
}
use of crazypants.enderio.base.machine.baselegacy.SlotDefinition in project EnderIO by SleepyTrousers.
the class LegacyMachineWrapper method computeSlotMappings.
protected void computeSlotMappings() {
final IoMode ioMode = machine.getIoMode(side);
if (ioMode != lastIoMode) {
slots.clear();
final SlotDefinition slotDefinition = machine.getSlotDefinition();
for (int i = 0; i < slotDefinition.getNumSlots(); i++) {
if ((ioMode.canRecieveInput() && slotDefinition.isInputSlot(i)) || ((ioMode.canOutput() && slotDefinition.isOutputSlot(i)))) {
slots.add(i);
}
}
lastIoMode = ioMode;
}
}
Aggregations