Skip to content

Commit f4a6aa2

Browse files
committed
player/player.go: checkOnGround: Use an epsilon for BBox intersection checks.
Resolves #779.
1 parent e9ed5f2 commit f4a6aa2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server/player/player.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,17 +2630,17 @@ func (p *Player) checkEntityInsiders(entityBBox cube.BBox) {
26302630

26312631
// checkOnGround checks if the player is currently considered to be on the ground.
26322632
func (p *Player) checkOnGround() bool {
2633-
box := Type.BBox(p).Translate(p.Position())
2633+
box := Type.BBox(p).Translate(p.Position()).Extend(mgl64.Vec3{0, -0.05})
26342634
b := box.Grow(1)
26352635

2636-
low, high := cube.PosFromVec3(b.Min()), cube.PosFromVec3(b.Max())
2636+
epsilon := mgl64.Vec3{mgl64.Epsilon, mgl64.Epsilon, mgl64.Epsilon}
2637+
low, high := cube.PosFromVec3(b.Min().Add(epsilon)), cube.PosFromVec3(b.Max().Sub(epsilon))
26372638
for x := low[0]; x <= high[0]; x++ {
26382639
for z := low[2]; z <= high[2]; z++ {
26392640
for y := low[1]; y < high[1]; y++ {
26402641
pos := cube.Pos{x, y, z}
2641-
boxList := p.tx.Block(pos).Model().BBox(pos, p.tx)
2642-
for _, bb := range boxList {
2643-
if bb.GrowVec3(mgl64.Vec3{0, 0.05}).Translate(pos.Vec3()).IntersectsWith(box) {
2642+
for _, bb := range p.tx.Block(pos).Model().BBox(pos, p.tx) {
2643+
if bb.Translate(pos.Vec3()).IntersectsWith(box) {
26442644
return true
26452645
}
26462646
}

0 commit comments

Comments
 (0)