Skip to content

Commit

Permalink
Merge pull request #1124 from P3pp3rF1y/1.20.x-dev
Browse files Browse the repository at this point in the history
fix: 🐛 Fix stashing items into backpack / shulker to properly take em…
  • Loading branch information
P3pp3rF1y authored Aug 22, 2024
2 parents e1176f8 + d016b70 commit 852579e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,8 @@ public Optional<TooltipComponent> 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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit 852579e

Please sign in to comment.