Skip to content

Commit

Permalink
fix lastXPPickup always being nil
Browse files Browse the repository at this point in the history
  • Loading branch information
xNatsuri committed Sep 8, 2024
1 parent cdd8847 commit fe3762b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ func New(name string, skin skin.Skin, pos mgl64.Vec3) *Player {
p.enchantSeed.Store(rand.Int63())
p.scale.Store(math.Float64bits(1))
p.pos.Store(&pos)
now := time.Now()
p.lastXPPickup.Store(&now)
return p
}

Expand Down Expand Up @@ -2147,7 +2149,7 @@ func (p *Player) CollectExperience(value int) bool {
return false
}
last := p.lastXPPickup.Load()
if last == nil || time.Since(*last) < time.Millisecond*100 {
if time.Since(*last) < time.Millisecond*100 {
return false
}
value = p.mendItems(value)
Expand Down

0 comments on commit fe3762b

Please sign in to comment.