Skip to content

Commit 4e265ee

Browse files
committed
player/player.go: Attempt to collect item into offhand slot
1 parent b33c061 commit 4e265ee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/player/player.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,8 +2158,15 @@ func (p *Player) Collect(s item.Stack) (int, bool) {
21582158
if p.Handler().HandleItemPickup(ctx, &s); ctx.Cancelled() {
21592159
return 0, false
21602160
}
2161-
n, _ := p.Inventory().AddItem(s)
2162-
return n, true
2161+
var added int
2162+
if _, offHand := p.HeldItems(); !offHand.Empty() && offHand.Comparable(s) {
2163+
added, _ = p.offHand.AddItem(s)
2164+
}
2165+
if s.Count() != added {
2166+
n, _ := p.Inventory().AddItem(s.Grow(-added))
2167+
added += n
2168+
}
2169+
return added, true
21632170
}
21642171

21652172
// Experience returns the amount of experience the player has.

0 commit comments

Comments
 (0)