From b0324077a2f34110fda4b9b9a637c8169a1f7a42 Mon Sep 17 00:00:00 2001 From: HashimTheArab Date: Tue, 21 Jul 2026 01:56:45 -0400 Subject: [PATCH 1/2] fix: detect non-collidable cobweb volume --- simulation.go | 8 ++------ simulator_test.go | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/simulation.go b/simulation.go index c076d6e..d6427dd 100644 --- a/simulation.go +++ b/simulation.go @@ -1018,12 +1018,8 @@ func (s *Simulator) isInsideCobweb(state *MovementState) bool { continue } - boxes := s.World.BlockCollisions(pos) - for _, box := range boxes { - if bb.IntersectsWith(box.Translate(posVec3(pos))) { - insideCobweb = true - break - } + if bb.IntersectsWith(cube.Box32(0, 0, 0, 1, 1, 1).Translate(posVec3(pos))) { + insideCobweb = true } if insideCobweb { break diff --git a/simulator_test.go b/simulator_test.go index 19e4c21..8e790ff 100644 --- a/simulator_test.go +++ b/simulator_test.go @@ -40,6 +40,10 @@ type cobwebWorld struct { pos cube.Pos } +type nonCollidingCobwebWorld struct { + cobwebWorld +} + func (w cobwebWorld) Block(pos cube.Pos) world.Block { if pos == w.pos { return block.Cobweb{} @@ -54,6 +58,10 @@ func (w cobwebWorld) BlockCollisions(pos cube.Pos) []cube.BBox32 { return []cube.BBox32{cube.Box32(0, 0, 0, 1, 1, 1)} } +func (nonCollidingCobwebWorld) BlockCollisions(cube.Pos) []cube.BBox32 { + return nil +} + func (cobwebWorld) GetNearbyBBoxes(cube.BBox32) []cube.BBox32 { return nil } @@ -147,7 +155,7 @@ func newBaseState() *MovementState { } } -func TestInsideCobwebTranslatesBlockLocalCollisionBoxes(t *testing.T) { +func TestInsideCobwebTranslatesBlockVolume(t *testing.T) { pos := cube.Pos{32, 64, -24} sim := &Simulator{World: cobwebWorld{pos: pos}} state := newBaseState() @@ -158,6 +166,17 @@ func TestInsideCobwebTranslatesBlockLocalCollisionBoxes(t *testing.T) { } } +func TestInsideCobwebUsesFullBlockVolumeWithoutCollisionBoxes(t *testing.T) { + pos := cube.Pos{32, 64, -24} + sim := &Simulator{World: nonCollidingCobwebWorld{cobwebWorld{pos: pos}}} + state := newBaseState() + state.Pos = mgl32.Vec3{float32(pos.X()) + 0.5, float32(pos.Y()), float32(pos.Z()) + 0.5} + + if !sim.isInsideCobweb(state) { + t.Fatal("expected a non-collidable cobweb to occupy its full block volume") + } +} + func containsLog(logs []string, needle string) bool { for _, line := range logs { if strings.Contains(line, needle) { From 79a0b06020b7d5f466fa2a459000d5def73590b1 Mon Sep 17 00:00:00 2001 From: HashimTheArab Date: Tue, 21 Jul 2026 02:24:14 -0400 Subject: [PATCH 2/2] test: clarify cobweb volume failure --- simulator_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulator_test.go b/simulator_test.go index 8e790ff..0392347 100644 --- a/simulator_test.go +++ b/simulator_test.go @@ -162,7 +162,7 @@ func TestInsideCobwebTranslatesBlockVolume(t *testing.T) { state.Pos = mgl32.Vec3{float32(pos.X()) + 0.5, float32(pos.Y()), float32(pos.Z()) + 0.5} if !sim.isInsideCobweb(state) { - t.Fatal("expected collision with block-local cobweb box away from the origin") + t.Fatal("expected intersection with translated cobweb block volume away from the origin") } }