Skip to content

Commit

Permalink
player/player.go: Attempt to collect item into offhand slot
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jan 25, 2025
1 parent b33c061 commit 4e265ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -2158,8 +2158,15 @@ func (p *Player) Collect(s item.Stack) (int, bool) {
if p.Handler().HandleItemPickup(ctx, &s); ctx.Cancelled() {
return 0, false
}
n, _ := p.Inventory().AddItem(s)
return n, true
var added int
if _, offHand := p.HeldItems(); !offHand.Empty() && offHand.Comparable(s) {
added, _ = p.offHand.AddItem(s)
}
if s.Count() != added {
n, _ := p.Inventory().AddItem(s.Grow(-added))
added += n
}
return added, true
}

// Experience returns the amount of experience the player has.
Expand Down

0 comments on commit 4e265ee

Please sign in to comment.