Skip to content

Commit f132cdb

Browse files
committed
player/player.go: Correctly deplete items on use when offhand is not empty
1 parent d529467 commit f132cdb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/player/player.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,12 +1510,16 @@ func (p *Player) handleUseContext(ctx *item.UseContext) {
15101510
p.SetHeldItems(p.subtractItem(p.damageItem(i, ctx.Damage), ctx.CountSub), left)
15111511
p.addNewItem(ctx)
15121512
for _, it := range ctx.ConsumedItems {
1513-
_ = p.offHand.RemoveItem(it)
1514-
it = it.Grow(-left.Count())
1513+
_, offHand := p.HeldItems()
1514+
if offHand.Comparable(it) {
1515+
if err := p.offHand.RemoveItem(it); err == nil {
1516+
continue
1517+
}
15151518

1516-
if !it.Empty() {
1517-
_ = p.Inventory().RemoveItem(it)
1519+
it = it.Grow(-offHand.Count())
15181520
}
1521+
1522+
_ = p.Inventory().RemoveItem(it)
15191523
}
15201524
}
15211525

0 commit comments

Comments
 (0)