diff --git a/gradle.properties b/gradle.properties index 555d05af..1c192ac3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.20.5 +mod_version=3.20.6 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java index c2d23370..facedd72 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackItem.java @@ -386,9 +386,8 @@ public Optional getInventoryTooltip(ItemStack stack) { return Optional.of(new BackpackItem.BackpackContentsTooltip(stack)); } - @Override - public ItemStack stash(ItemStack storageStack, ItemStack stack) { - return storageStack.getCapability(CapabilityBackpackWrapper.getCapabilityInstance()).map(wrapper -> wrapper.getInventoryForUpgradeProcessing().insertItem(stack, false)).orElse(stack); + public ItemStack stash(ItemStack storageStack, ItemStack stack, boolean simulate) { + return storageStack.getCapability(CapabilityBackpackWrapper.getCapabilityInstance()).map(wrapper -> wrapper.getInventoryForUpgradeProcessing().insertItem(stack, simulate)).orElse(stack); } @Override @@ -418,10 +417,11 @@ public boolean overrideStackedOnOther(ItemStack storageStack, Slot slot, ClickAc } ItemStack stackToStash = slot.getItem(); - ItemStack stashResult = stash(storageStack, stackToStash); - if (stashResult.getCount() != stackToStash.getCount()) { - slot.set(stashResult); - slot.onTake(player, stashResult); + ItemStack stashResult = stash(storageStack, stackToStash, true); + if (stashResult.getCount() < stackToStash.getCount()) { + int countToTake = stackToStash.getCount() - stashResult.getCount(); + ItemStack takeResult = slot.safeTake(countToTake, countToTake, player); + stash(storageStack, takeResult, false); return true; } @@ -434,7 +434,7 @@ public boolean overrideOtherStackedOnMe(ItemStack storageStack, ItemStack otherS return super.overrideOtherStackedOnMe(storageStack, otherStack, slot, action, player, carriedAccess); } - ItemStack result = stash(storageStack, otherStack); + ItemStack result = stash(storageStack, otherStack, false); if (result.getCount() != otherStack.getCount()) { carriedAccess.set(result); slot.set(storageStack);