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 f4647b2 commit 35c19ce
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 @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedbackpacks
mod_group_id=sophisticatedbackpacks
mod_version=3.20.7
mod_version=3.20.8
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 @@ -254,13 +254,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 35c19ce

Please sign in to comment.