Skip to content

Commit

Permalink
fix: 🐛 Fixed dupe bug in tool swapper when using it together with sta…
Browse files Browse the repository at this point in the history
…ck upgrade and stacked swords
  • Loading branch information
P3pp3rF1y committed Sep 24, 2024
1 parent 03833f5 commit 05106f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version_range=[4,)
mod_id=sophisticatedbackpacks
mod_name=Sophisticated Backpacks
mod_license=GNU General Public License v3.0
mod_version=3.20.12
mod_version=3.20.13
mod_group_id=sophisticatedbackpacks
mod_authors=P3pp3rF1y, Ridanisaurus
mod_description=Fancy and functional backpacks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,15 @@ private boolean swapWeapon(Player player, ItemStack mainHandItem, IItemHandlerSi
return true;
}

InventoryHelper.extractFromInventory(sword, backpackInventory, false);
ItemStack swordCopy = sword.copy();
swordCopy.setCount(1);
InventoryHelper.extractFromInventory(swordCopy, backpackInventory, false);
if (backpackInventory.insertItem(mainHandItem, true).isEmpty()) {
player.setItemInHand(InteractionHand.MAIN_HAND, sword);
player.setItemInHand(InteractionHand.MAIN_HAND, swordCopy);
backpackInventory.insertItem(mainHandItem, false);
return true;
} else {
backpackInventory.insertItem(sword, false);
backpackInventory.insertItem(swordCopy, false);
return false;
}
}
Expand Down

0 comments on commit 05106f6

Please sign in to comment.