diff --git a/camping-supplies-addon/camping_supplies_BP/scripts/main.js b/camping-supplies-addon/camping_supplies_BP/scripts/main.js index 650bbab..ce7d8f3 100644 --- a/camping-supplies-addon/camping_supplies_BP/scripts/main.js +++ b/camping-supplies-addon/camping_supplies_BP/scripts/main.js @@ -104,13 +104,14 @@ function tryPlaceTent(player) { const feetX = Math.floor(player.location.x); const feetZ = Math.floor(player.location.z); let feetY = Math.floor(player.location.y); - // If the block at feet level is air (player's mid-jump or location rounded up), - // scan downward up to 3 blocks to find the ground. + // If the block at feet level is solid (player inside a block, e.g. standing in + // 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++) { - const here = dim.getBlock({ x: feetX, y: feetY - 1, z: feetZ }); - if (here && here.isSolid) break; - const onSolid = dim.getBlock({ x: feetX, y: feetY, z: feetZ }); - if (onSolid && onSolid.isSolid) { feetY += 1; break; } + const below = dim.getBlock({ x: feetX, y: feetY - 1, z: feetZ }); + if (below && !below.isAir && !below.isLiquid) break; feetY -= 1; } const ox = feetX + fx; @@ -347,6 +348,11 @@ function toggleHammock(player, loc) { player.addEffect("saturation", 40, { amplifier: 0, showParticles: false }); player.addEffect("regeneration", 200, { amplifier: 1, showParticles: false }); } 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.)"); } @@ -374,6 +380,7 @@ function exitHammock(player) { } } 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."); }