From 194fa38b9fcbabefe327628f2f2f70f87827edef Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sun, 14 Jun 2020 11:28:32 +0200 Subject: [PATCH] When shift-clicking items into a container, and the same item is already in the target slot while its capacity is full, do not needlessly trigger an inventory change. This resets the progress of blocks like the inscriber. --- .../appeng/container/AEBaseContainer.java | 89 ++++++++----------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index f1407c551..d9163479a 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -481,7 +481,7 @@ public abstract class AEBaseContainer extends Container { final ItemStack t = d.getStack().copy(); - if( Platform.itemComparisons().isSameItem( tis, t ) ) // t.isItemEqual(tis)) + if( Platform.itemComparisons().isSameItem( t, tis ) ) { int maxSize = t.getMaxStackSize(); if( maxSize > d.getSlotStackLimit() ) @@ -489,38 +489,34 @@ public abstract class AEBaseContainer extends Container maxSize = d.getSlotStackLimit(); } - int placeAble = maxSize - t.getCount(); + int placeable = maxSize - t.getCount(); + if (placeable > 0) { + if (tis.getCount() < placeable) { + placeable = tis.getCount(); + } - if( tis.getCount() < placeAble ) - { - placeAble = tis.getCount(); - } + t.setCount(t.getCount() + placeable); + tis.setCount(tis.getCount() - placeable); - t.setCount( t.getCount() + placeAble ); - tis.setCount( tis.getCount() - placeAble ); + d.putStack(t); - d.putStack( t ); + if (tis.getCount() <= 0) { + clickSlot.putStack(ItemStack.EMPTY); + d.onSlotChanged(); - if( tis.getCount() <= 0 ) - { - clickSlot.putStack( ItemStack.EMPTY ); - d.onSlotChanged(); - - // if ( hasMETiles ) updateClient(); - - this.updateSlot( clickSlot ); - this.updateSlot( d ); - return ItemStack.EMPTY; - } - else - { - this.updateSlot( d ); + this.updateSlot(clickSlot); + this.updateSlot(d); + return ItemStack.EMPTY; + } else { + this.updateSlot(d); + } } } } } } + // FIXME figure out whats the difference between this and the one above ?! // any match.. for( final Slot d : selectedSlots ) { @@ -538,39 +534,32 @@ public abstract class AEBaseContainer extends Container if( Platform.itemComparisons().isSameItem( t, tis ) ) { int maxSize = t.getMaxStackSize(); - if( d.getSlotStackLimit() < maxSize ) + if( maxSize > d.getSlotStackLimit() ) { maxSize = d.getSlotStackLimit(); } - int placeAble = maxSize - t.getCount(); + int placeable = maxSize - t.getCount(); + if (placeable > 0) { + if (tis.getCount() < placeable) { + placeable = tis.getCount(); + } - if( tis.getCount() < placeAble ) - { - placeAble = tis.getCount(); - } + t.setCount(t.getCount() + placeable); + tis.setCount(tis.getCount() - placeable); - t.setCount( t.getCount() + placeAble ); - tis.setCount( tis.getCount() - placeAble ); + d.putStack(t); - d.putStack( t ); + if (tis.getCount() <= 0) { + clickSlot.putStack(ItemStack.EMPTY); + d.onSlotChanged(); - if( tis.getCount() <= 0 ) - { - clickSlot.putStack( ItemStack.EMPTY ); - d.onSlotChanged(); - - // if ( worldEntity != null ) - // worldEntity.markDirty(); - // if ( hasMETiles ) updateClient(); - - this.updateSlot( clickSlot ); - this.updateSlot( d ); - return ItemStack.EMPTY; - } - else - { - this.updateSlot( d ); + this.updateSlot(clickSlot); + this.updateSlot(d); + return ItemStack.EMPTY; + } else { + this.updateSlot(d); + } } } } @@ -596,10 +585,6 @@ public abstract class AEBaseContainer extends Container clickSlot.putStack( ItemStack.EMPTY ); d.onSlotChanged(); - // if ( worldEntity != null ) - // worldEntity.markDirty(); - // if ( hasMETiles ) updateClient(); - this.updateSlot( clickSlot ); this.updateSlot( d ); return ItemStack.EMPTY;