Raycasts: take a state's context rule from its collision flag

The name test (scaffolding, powder_snow) missed the liquid rule, so with
an entity's context a lava block took its cached empty shape, where
collision_shape_with_context gives a strider the lava's stable shape.
Read the registry's contextual flag instead, as collision_shape_with_context
does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Horizon agentandClaude Opus 5.5 committed 2026-11-09 17:15:50 +01:00
1 parent a9a14c810e
commit 6ee08b4a5a
2 files changed
+11 -4

No files matched your search

+3 -4
View File
@@ -297,10 +297,9 @@ impl MobWorld<'_> {
if !self.collision.may_collide(state) {
return None;
}
let is_contextual = context.is_some() && {
let name = &self.facts.get(state).name;
name.ends_with("scaffolding") || name.ends_with("powder_snow")
};
// Scaffolding, liquids (a strider stands on lava) and powder snow
// take the entity's context; every other state has its cached shape.
let is_contextual = context.is_some() && self.collision.has_context_rule(state);
if !is_contextual
&& let Ok(Some(shape)) = self.collision.cached_shapes().cached_shape(state)
{
@@ -174,6 +174,14 @@ impl<'r> BlockCollisionRegistry<'r> {
.get(state.0 as usize)
.is_none_or(|flags| flags & 4 == 0)
}
/// Whether `state` has a contextual collision rule (scaffolding, a liquid, powder snow):
/// its shape with an entity's context may differ from the cached one. States outside the
/// registry count.
pub fn has_context_rule(&self, state: BlockStateId) -> bool {
self.scan_flags
.get(state.0 as usize)
.is_none_or(|flags| flags & 8 != 0)
}
/// Whether a scan keeps `state` in the cells around its box: a large
/// collision shape or a moving piston. States outside the registry count.
pub fn reaches_out(&self, state: BlockStateId) -> bool {