-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement crawling #936
implement crawling #936
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looks good! Just a few little comments
server/block/cube/bbox.go
Outdated
@@ -282,3 +282,26 @@ func (box BBox) ZOffset(nearby BBox, deltaZ float64) float64 { | |||
} | |||
return deltaZ | |||
} | |||
|
|||
// Corners returns slice of all hitbox corners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a full stop at the end of this doc and the other 2 in this file.
server/block/cube/bbox.go
Outdated
xyZ := mgl64.Vec3{min[0], min[1], max[2]} | ||
xYz := mgl64.Vec3{min[0], max[1], min[2]} | ||
xYZ := mgl64.Vec3{min[0], max[1], max[2]} | ||
XYz := mgl64.Vec3{max[0], max[1], min[2]} | ||
XyZ := mgl64.Vec3{max[0], min[1], max[2]} | ||
Xyz := mgl64.Vec3{max[0], min[1], min[2]} | ||
return []mgl64.Vec3{min, max, xyZ, xYz, xYZ, XYz, XyZ, Xyz} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove these variables and do something like this:
return []mgl64.Vec3{
{min[0], min[1], max[2]},
{min[0], max[1], min[2]},
// etc.
}```
server/player/player.go
Outdated
var isAir bool | ||
for _, corner := range p.Type().BBox(p).Translate(p.Position()).Corners() { | ||
_, isAir = p.World().Block(cube.PosFromVec3(corner).Add(cube.Pos{0, 1, 0})).(block.Air) | ||
if !isAir { | ||
break | ||
} | ||
} | ||
|
||
if !isAir && !p.crawling.CompareAndSwap(false, true) { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be slightly simplified to
for _, corner := range p.Type().BBox(p).Translate(p.Position()).Corners() {
_, isAir = p.World().Block(cube.PosFromVec3(corner).Add(cube.Pos{0, 1, 0})).(block.Air)
if !isAir {
if !p.crawling.CompareAndSwap(false, true) {
return
}
break
}
}
server/player/player.go
Outdated
default: | ||
return 1.62 | ||
} | ||
return 1.62 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point changing this to a default cause, keep how it was before
server/player/player.go
Outdated
// EyeHeight returns the eye height of the player: 1.62, or 0.52 if the player is swimming. | ||
// EyeHeight returns the eye height of the player. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could keep the last part of the doc and say "0.52 if the player is crawling or swimming, 1.26 when sneaking or 1.62 when standing."
server/block/cube/bbox.go
Outdated
return BBox{min: box.min.Mul(val), max: box.max.Mul(val)} | ||
} | ||
|
||
// Volume calculates Volume of the BBox. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little nitpick, second "Volume" makes more sense to be "the volume"
server/player/player.go
Outdated
@@ -2617,8 +2646,11 @@ func (p *Player) OnGround() bool { | |||
|
|||
// EyeHeight returns the eye height of the player: 1.62, or 0.52 if the player is swimming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if you could update this doc as previously mentioned to describe all states
Thanks! |
No description provided.