Skip to content

Commit

Permalink
player/player.go: Correctly deplete items on use when offhand is not …
Browse files Browse the repository at this point in the history
…empty
  • Loading branch information
DaPigGuy committed Jan 30, 2025
1 parent d529467 commit f132cdb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,12 +1510,16 @@ func (p *Player) handleUseContext(ctx *item.UseContext) {
p.SetHeldItems(p.subtractItem(p.damageItem(i, ctx.Damage), ctx.CountSub), left)
p.addNewItem(ctx)
for _, it := range ctx.ConsumedItems {
_ = p.offHand.RemoveItem(it)
it = it.Grow(-left.Count())
_, offHand := p.HeldItems()
if offHand.Comparable(it) {
if err := p.offHand.RemoveItem(it); err == nil {
continue
}

if !it.Empty() {
_ = p.Inventory().RemoveItem(it)
it = it.Grow(-offHand.Count())
}

_ = p.Inventory().RemoveItem(it)
}
}

Expand Down

0 comments on commit f132cdb

Please sign in to comment.