diff --git a/crates/horizon-client/examples/scene_motion_probe.rs b/crates/horizon-client/examples/scene_motion_probe.rs index cedc8cb8c..b56da92fa 100644 --- a/crates/horizon-client/examples/scene_motion_probe.rs +++ b/crates/horizon-client/examples/scene_motion_probe.rs @@ -458,7 +458,7 @@ fn main() -> Result<()> { "weaving" => world.player.status.weaving = op["value"].as_bool().unwrap(), "flying" => { let flying = op["value"].as_bool().unwrap(); - world.player.may_fly = flying; + world.player.may_fly = op["may_fly"].as_bool().unwrap_or(flying); world.player.flying = flying; } "trigger" => world.player.jump_trigger_time = op["value"].as_i64().unwrap() as i32, diff --git a/crates/horizon-client/src/landing.rs b/crates/horizon-client/src/landing.rs index 07230023c..e0e510820 100644 --- a/crates/horizon-client/src/landing.rs +++ b/crates/horizon-client/src/landing.rs @@ -360,8 +360,12 @@ impl BlockLandingWorld for MotionWorld<'_, '_, '_> { multiplier: f32, source: LandingDamage, ) -> Result { - // Nonflying player: Player.causeFallDamage records centimeters before - // delegating to LivingEntity. No mayfly ability in the walking scene. + // Player.causeFallDamage exempts players with the mayfly ability, + // including creative players who are currently walking. + if self.player.may_fly { + return Ok(false); + } + // Record centimeters before delegating to LivingEntity. if distance >= 2.0 || distance.is_nan() { let scaled = distance * 100.0; let floor = scaled.floor(); diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java index 49dc7753c..de6e0aed1 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java @@ -392,7 +392,7 @@ public final class VanillaSceneMotionOracle { case "frozen"->p.frozen=op.get("value").getAsInt(); case "portal_tick"->p.portalTick(op.get("creative").getAsBoolean()); case "weaving"->p.weaving=op.get("value").getAsBoolean(); - case "flying"->{var a=p.getAbilities();a.mayfly=a.flying=op.get("value").getAsBoolean();} + case "flying"->{var a=p.getAbilities();a.flying=op.get("value").getAsBoolean();a.mayfly=op.has("may_fly")?op.get("may_fly").getAsBoolean():a.flying;} case "trigger"->trigger.setInt(p,op.get("value").getAsInt()); case "delay"->delay.setInt(p,op.get("value").getAsInt()); case "ack_attributes"->{p.attrs.getAttributesToUpdate().clear();p.attrs.getAttributesToSync().clear();} diff --git a/tools/test_native_scene_motion.py b/tools/test_native_scene_motion.py index 59d49c8e1..8430b29a7 100644 --- a/tools/test_native_scene_motion.py +++ b/tools/test_native_scene_motion.py @@ -340,6 +340,18 @@ def corpus(): yield dict(position=vec((25.5,4,25.5)),ops=[op('seed',seed),op('block',name='minecraft:'+name,position=[25,3,25],properties=properties), *[v for _ in range(8) for v in [op('fall',bits(8)),op('landing',bits(-.1),ground=True,position=[25,3,25])]], op('block',name='minecraft:stone',position=[25,3,25])]) + # Creative players are exempt even while walking. Compare small/big falls, + # block damage multipliers and switching back to survival on the same actor. + for name in ['stone','hay_block','pointed_dripstone']: + for distance in [4,8,20]: + for flying in [False,True]: + ops=[op('block',name='minecraft:'+name,position=[25,3,25]), + op('flying',flying,may_fly=True),op('fall',bits(distance)), + op('landing',bits(-.125),ground=True,position=[25,3,25]), + op('flying',False,may_fly=False),op('fall',bits(distance)), + op('landing',bits(-.125),ground=True,position=[25,3,25]), + op('block',name='minecraft:stone',position=[25,3,25])] + yield dict(position=vec((25.5,4,25.5)),ops=ops) for safe in [0,1,3,6,20]: for multiplier in [0,.5,1,2]: for impact in [None,3,4,4.1,7,18]: