fix(camping): scan-down now uses air/liquid check + hammock camera pull
All checks were successful
Deploy Addons / deploy (push) Successful in 15s

The tent's scan-down-for-ground loop still used b.isSolid (undefined
in BDS), so it always fell through the break conditions and
decremented feetY by 3 blocks before checking ground. That's why
clicking grass reported "dirt" and stone reported "dirt/stone from
underneath the surface". Replaced both solid checks with
!isAir && !isLiquid like the main ground check.

Also added a cinematic third-person camera when climbing into the
hammock (ease 0.8s out_sine), cleared on exit. Gives the player a
"lying back, can see myself" view while resting.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 16:32:26 +01:00
parent ad5c365c2c
commit 60603ab74c

View File

@@ -104,13 +104,14 @@ function tryPlaceTent(player) {
const feetX = Math.floor(player.location.x); const feetX = Math.floor(player.location.x);
const feetZ = Math.floor(player.location.z); const feetZ = Math.floor(player.location.z);
let feetY = Math.floor(player.location.y); let feetY = Math.floor(player.location.y);
// If the block at feet level is air (player's mid-jump or location rounded up), // If the block at feet level is solid (player inside a block, e.g. standing in
// scan downward up to 3 blocks to find the ground. // tall grass that rounded up), step up one.
const feetBlock = dim.getBlock({ x: feetX, y: feetY, z: feetZ });
if (feetBlock && !feetBlock.isAir && !feetBlock.isLiquid) feetY += 1;
// If the block below is air (mid-jump / airborne), project down to ground.
for (let probe = 0; probe < 4; probe++) { for (let probe = 0; probe < 4; probe++) {
const here = dim.getBlock({ x: feetX, y: feetY - 1, z: feetZ }); const below = dim.getBlock({ x: feetX, y: feetY - 1, z: feetZ });
if (here && here.isSolid) break; if (below && !below.isAir && !below.isLiquid) break;
const onSolid = dim.getBlock({ x: feetX, y: feetY, z: feetZ });
if (onSolid && onSolid.isSolid) { feetY += 1; break; }
feetY -= 1; feetY -= 1;
} }
const ox = feetX + fx; const ox = feetX + fx;
@@ -347,6 +348,11 @@ function toggleHammock(player, loc) {
player.addEffect("saturation", 40, { amplifier: 0, showParticles: false }); player.addEffect("saturation", 40, { amplifier: 0, showParticles: false });
player.addEffect("regeneration", 200, { amplifier: 1, showParticles: false }); player.addEffect("regeneration", 200, { amplifier: 1, showParticles: false });
} catch (_) {} } catch (_) {}
// Pull the camera back into a cinematic third-person view so the player can see
// themselves lying in the hammock. Ease in smoothly.
try {
player.runCommand("camera @s set minecraft:third_person ease 0.8 out_sine");
} catch (_) {}
player.sendMessage("§a[Camping] §7You settle into the hammock. Wild creatures don't notice you. §8(Sneak to climb out.)"); player.sendMessage("§a[Camping] §7You settle into the hammock. Wild creatures don't notice you. §8(Sneak to climb out.)");
} }
@@ -374,6 +380,7 @@ function exitHammock(player) {
} }
} catch (_) {} } catch (_) {}
try { player.setDynamicProperty(HAMMOCK_ANCHOR_PROP, undefined); } catch (_) {} try { player.setDynamicProperty(HAMMOCK_ANCHOR_PROP, undefined); } catch (_) {}
try { player.runCommand("camera @s clear"); } catch (_) {}
player.sendMessage("§7[Camping] You climb out of the hammock."); player.sendMessage("§7[Camping] You climb out of the hammock.");
} }