Storage Controller won't insert into empty drawers anymore when interacting, closes #21

This commit is contained in:
Buuz135 2022-03-21 20:28:20 +01:00
parent 467a9a3e8e
commit d312fecc2a
2 changed files with 2 additions and 3 deletions

View File

@ -76,15 +76,13 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
return InteractionResult.PASS;
if (isServer()) {
for (int slot = 0; slot < getStorage().getSlots(); slot++) {
if (!stack.isEmpty() && getStorage().insertItem(slot, stack, true).getCount() != stack.getCount()) {
if (!stack.isEmpty() && !getStorage().getStackInSlot(slot).isEmpty() && getStorage().insertItem(slot, stack, true).getCount() != stack.getCount()) {
playerIn.setItemInHand(hand, getStorage().insertItem(slot, stack, false));
return InteractionResult.SUCCESS;
} else if (System.currentTimeMillis() - INTERACTION_LOGGER.getOrDefault(playerIn.getUUID(), System.currentTimeMillis()) < 300) {
boolean worked = false;
for (ItemStack itemStack : playerIn.getInventory().items) {
if (!itemStack.isEmpty() && !getStorage().getStackInSlot(slot).isEmpty() && getStorage().insertItem(slot, itemStack, true).getCount() != itemStack.getCount()) {
itemStack.setCount(getStorage().insertItem(slot, itemStack.copy(), false).getCount());
worked = true;
}
}
}

View File

@ -106,6 +106,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
if (slot < type.getSlots()){
BigStack bigStack = this.storedStacks.get(slot);
ItemStack fl = bigStack.getStack();
if (isLocked() && fl.isEmpty()) return false;
return fl.isEmpty() || (fl.sameItem(stack) && ItemStack.tagMatches(fl, stack));
}
return false;