From d016b70303730d0a7862c3848b1d2a0af10680fc Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 20 Aug 2024 08:58:31 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20stashing=20items=20?= =?UTF-8?q?into=20backpack=20/=20shulker=20to=20properly=20take=20emc=20wh?= =?UTF-8?q?en=20interacting=20with=20ProjectE=20tablet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../backpack/BackpackItem.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) 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);