🎬 Cinemalya
🎥 一个用于让角色在电影运镜中飞行的 Minecraft 数据包库。
- ✨ 沿样条线将玩家平滑移动至任意位置,支持缓动、弧线和粒子轨迹。
- 🎞️ 内置片头标题卡,并提供信号以接入自定义逻辑。
- 🧭 可从命令方块执行:全程支持
~ 和 ^ 坐标。
- 🎯 旋转精度完整保留,相机平滑扫过而非出现阶梯状卡顿。
- ⚡ 路径仅在启动时计算一次;播放过程每步仅弹出下一帧。
📦 嵌入式库:将其打包在你的数据包内,而非单独分发。
需要 LanternLoad 和 Bookshelf Spline。
⚡ 快速开始
execute as @p run function #cinemalya:v1/launch {with:{x:19.5,y:82.5,z:23.5,duration:60,arc_side:1,particle:"minecraft:glow"}}
每个入口点接受一个 with 复合标签,因此其中的每个字段都是可选的。
🔧 入口点
#cinemalya:v1/launch
execute as <player> run function #cinemalya:v1/launch {with:{x:19.5,y:82.5,z:23.5,duration:60,arc_side:1}}
x / y / z 是玩家最终站立的位置,而非相机停止的位置。
#cinemalya:v1/launch_here
目的地由执行位置和旋转决定,因此相对坐标是有效的。NBT 无法存储 ~,这就是为什么 launch 需要绝对数值,而此函数存在的意义所在。
execute positioned ~12 ~8 ~-4 rotated 90 20 as @a[distance=..30] run function #cinemalya:v1/launch_here {with:{duration:60,arc_side:1}}
注意顺序:positioned 在 as 交换执行者之前相对于命令方块解析,因此目的地是固定的,而每个玩家仍从自己的脚部开始。facing 和 ^ 同样有效。
#cinemalya:v1/launch_at_entity
execute as <player> run function #cinemalya:v1/launch_at_entity {with:{target:"@e[tag=camera_anchor,limit=1]",duration:60,ease:"ease_in_out"}}
#cinemalya:v1/launch_path
穿越明确的路径点。此处位置为相机位置,按字面意思使用。
execute as <player> run function #cinemalya:v1/launch_path {with:{duration:90,ease:"ease_in_out",waypoints:[{args:[-112,75,-21,-30,4]},{args:[-116,77,28,-121,16]},{args:[-72,68,20,92,-11.7]}]}}
waypoints[0] 是起点,因此三个路径点意味着两个片段。只提供一个路径点时,玩家自身的位置将作为路径起点。路径点有三种写法:
| 键 |
示例 |
|
args |
{args:[x,y,z,yaw,pitch,duration]} |
扁平化,3 或 5 个值即可停止。整数即可 |
pos / rot |
{pos:[0.5,90.0,0.5],rot:[0.0,20.0]} |
显式指定 |
at |
{at:"~30 ~12 ~-30",rot:[135,20]} |
相对于命令运行位置,支持 ~ 或 ^ |
缺少 rot 则保持之前的朝向。没有 duration 的路径点将根据到达它们的线段长度按比例共享持续时间,使相机以恒定速度平稳飞越它们;它们共同获得的部分相当于平均分配时的份额。at 会覆盖 pos。局部 ^ 需要执行旋转,因此从命令方块使用时请添加 rotated。
缓动。 路径级的 ease 塑造整个行程:它从第一个路径点加速出发,以恒定速度巡航经过中间路径点,最后平缓降落至最后一个路径点。若将 ease 放在路径点上,则仅塑造到达该点的跳跃过程:
execute as <player> run function #cinemalya:v1/launch_path {with:{waypoints:[{args:[-112,75,-21,-30,4]},{args:[-116,77,28,-121,16,55],ease:"ease_out"},{args:[-72,68,20,92,-11.7,25],ease:"ease_in"}]}}
这会在中间路径点附近减速至近乎静止,停留片刻,然后再次加速离开。
传送。 带有 tp:true 的路径点通过传送到达:不会从前一个路径点飞行至此。环绕建筑一圈,然后切入内部并继续前进:
execute as <player> run function #cinemalya:v1/launch_path {with:{duration:120,waypoints:[{args:[0,70,0]},{args:[10,70,10]},{args:[20,70,0]},{args:[200,64,0,90,0],tp:true,delay:20},{args:[210,64,0]}]}}
每次传送都会切断路径,每一段单独采样,因此曲线不会跨越切割点弯曲。它们根据每段飞行的比例共享 duration,且 ease 适用于每一段。相机精确落在 tp 路径点上,然后在其 delay 刻数(默认为 0)内停留,以便周围区块加载完成。一条路径最多包含 8 个片段。该键通过存在性读取,因此 tp:false 仍被视为传送:若要排除,请直接省略该键。距离小于 64 块的传送通常会在客户端平滑过渡,因此相机的前一 tick 会将 teleport_duration 设为 0。
路径点事件。 带有 function:"<namespace>:<path>" 的路径点在相机到达时运行该函数,执行者为玩家(对于 gamemode:"none" 则为相机),位置在相机处。所有路径点也会触发 on_waypoint。第一个路径点在第一步时触发,位于起点约一个方块之后。
#cinemalya:v1/intro
保持开场镜头,命名场景,定位每位玩家,并将他们全部引入。在镜头的位置和旋转状态下运行此函数。
execute positioned 36.29 102.97 81.36 rotated 145.55 21.76 run function #cinemalya:v1/intro {with:{title:"Warden Forest",subtitle:"by Stoupy",display_time:130,duration:50}}
target_function 作为每位玩家执行,用于将他们传送至各自位置;省略则他们保持原位。同时支持 selector、sound、title_color、subtitle_color 以及所有 launch 字段。
#cinemalya:v1/stop
execute as <player> run function #cinemalya:v1/stop {with:{}}
玩家将停留在相机所在的位置,由你决定他们的归属地。restore:false 会使他们保持在旁观模式。
#cinemalya:v1/editor/start
在游戏中录制路径而非手动输入坐标。start 提供编辑器物品,editor/stop 收回该物品。
function #cinemalya:v1/editor/start
| 持有物品时 |
操作 |
| 右键点击 |
在你的眼睛位置放置关键帧,附带你的旋转角度 |
| 左键点击 |
移除最后一个关键帧 |
| 潜行 + 右键点击 |
预览路径 |
| 切换主副手(默认 F) |
将最后一个关键帧设为传送,或飞行至该关键点 |
| 丢弃物品 |
打开导出界面,并将物品返还给你 |
导出结果会生成两个 launch_path 命令供你复制到命令方块中:一个使用绝对坐标,另一个使用相对于其 execute positioned 坐标的相对位置(起始于第一帧关键帧),因此编辑这些坐标会移动整个路径。这两个命令的持续时长均为 duration:200 刻,并在关键帧之间以 ease:"linear"(线性)进行移动;你可以在命令中直接编辑此值(其他可选值为 ease_in、ease_out 和 ease_in_out)。除 particle(粒子)和 spline(样条线)外,所有其他选项均按其默认值写入。每个编辑器共享相同的路径,最多支持 128 个关键帧,当最后一个关键帧停止时路径会被清除。
📋 选项
| 字段 |
类型 |
默认值 |
含义 |
duration |
int |
60 |
行程长度,单位为刻 |
smoothing |
int |
1 |
帧之间的间隔刻数。数值越高越节省性能且画面更柔和 |
delay |
int |
0 |
移动前保持静止的刻数 |
ease |
string |
"linear" |
linear、ease_in、ease_out、ease_in_out |
spline |
string |
auto |
bezier(2 个航点)或 catmull_rom(更多航点) |
arc_side |
float |
0.0 |
侧向摆动幅度,占距离一半的比例 |
arc_height |
float |
0.0 |
弧线最高点超出较高端点的距离,详见下方说明 |
particle |
string |
none |
跟随摄像机轨迹的粒子 |
gamemode |
string |
"restore" |
restore(恢复)、keep(保持,适用于已是旁观者模式的情况)、none(无玩家参与) |
mode |
string |
"spectator" |
spectator(旁观者模式),或 ride(在你自己的游戏模式下坐在摄像机上,详见 ride) |
body |
string |
none |
mannequin:一个穿着你的皮肤、盔甲并拥有手臂的人体模型站在摄像机后方一格处,供其他玩家观看。垂直向下看仍能看到其头盔和双手 |
pose |
string |
"standing" |
配合 body 使用:standing(站立)、crouching(蹲伏)、swimming(游泳)或 fall_flying(滑翔坠落) |
protect |
bool |
false |
整个行程期间的保护效果,结束时清除,以确保乘客不受伤害 |
tags |
list |
[] |
添加到电影实体的额外标签 |
precise_rotation |
bool |
true |
详见 旋转精度 |
yaw / pitch |
float |
target's |
覆盖最终旋转角度 |
各入口点参数:launch 接受 x/y/z,launch_at_entity 接受 target,launch_path 接受 waypoints,launch_here 不接受任何参数。yaw/pitch 不适用于 launch_path,因为每个航点自带其自身的 rot。
弧线。 arc_height:0.0 会使两点间的行程(通过 launch、launch_here、launch_at_entity 或包含两个航点的 launch_path)沿直线飞行。设置如 10 到 20 的值可将摄像机在长距离行程的中部抬高,通常当起点和终点相距较远或处于不同高度时,这样看起来效果更好。经过三个或更多航点的路径会遵循其自身的曲线,并忽略此参数。
限制
所有用于限定循环的参数都会在启动时被截断,因此拼写错误只会导致电影效果看起来不正确,而不会导致服务器卡死。
| 参数 |
边界 |
超出边界后的行为 |
duration, .duration |
36000 (30 分钟) |
被截断,针对每次行程及每个航点分别计算 |
smoothing |
1 至 100 |
被截断 |
waypoints |
128 |
拒绝执行,向玩家显示红色消息并返回 fail |
| 片段数(传送 + 1) |
8 |
拒绝执行,向玩家显示红色消息并返回 fail |
tags |
32 |
多余的标签将被丢弃 |
| 发出的帧数 |
600 |
提高平滑度,以保持路径完整长度 |
如果某次行程请求的帧数超过预算,系统会采用更柔和的 smoothing 而非缩短路径,因此即使设置为 duration:36000,摄像机仍能到达指定位置。此上限确保单次启动的命令数量不超过 Minecraft 默认的 max_command_sequence_length(65536 条命令),否则 Minecraft 将丢弃剩余命令,导致摄像机无法出现。
📡 信号
请将你自己的函数添加至以下标签。它们将在玩家身上运行,或在路径没有玩家时作为摄像机运行。
| 标签 |
触发时机 |
#cinemalya:v1/signals/on_launch |
摄像机接管控制权前瞬间。取消跑酷计时器、战斗标记等任何应被传送中断的状态 |
#cinemalya:v1/signals/on_finish |
放置完成后且游戏模式恢复后 |
#cinemalya:v1/signals/on_waypoint |
摄像机每次到达航点时,在摄像机处触发。#waypoint cinemalya.data 为其从 0 开始的索引 |
🔍 备注
读取状态。 #entities cinemalya.data 统计当前正在播放的电影数量,因此你可以据此设置条件门控(例如:execute if score #entities cinemalya.data matches 1.. run return 1)。摄像机实体携带 cinemalya.cinematic 标签以及你在 tags 中传入的任何额外标签。
骑乘。 mode:"ride" 让玩家保持自己的游戏模式,并坐在摄像机上,因此玩家保留双手、HUD(抬头显示)和身体模型,而摄像机则位于玩家的视野位置。玩家的头部保持自由:没有任何东西可以平滑地控制其转动,因为强制旋转只能以每刻钟(tick)为单位进行步进。如需实现平滑的扫描镜头效果,请使用默认的旁观者模式(spectator mode)。潜行无法使骑手脱离,摄像机会将其重新放置,但游戏仍会打印退出骑乘的提示信息。建议搭配 protect:true 使用,这样在旅途中玩家不会受到伤害。旅程结束后,该设置会清除玩家自身的抗性效果。
旋转精度。 Minecraft 将旋转量化为 360/256 = 1.40625° 的步长,这会导致 /spectate 摄像机在转动时出现可见的阶梯状卡顿(MC-184359)。通过每刻钟翻转摄像机的 OnGround 标志,可以让服务器发送全精度数据。默认开启,每个电影片段每刻钟执行一次命令,由于展示实体(display entities)并非活体实体,因此不会产生副作用。此功能依赖于 MC-278440,这是一个社区发现的解决方案,因此未来版本可能会修复此问题:若希望禁用此功能,可传递 precise_rotation:false 参数。
工作原理。 电影片段是一个玩家处于旁观者模式的不可见 item_display(物品展示框)。你的路标点会成为样条曲线的控制点,Bookshelf 将它们采样为密集的折线,每一段根据其持续时间精确分配相应数量的帧。所有这些操作仅在启动时执行一次,因此无论路径包含 10 帧还是 500 帧,播放时的开销仅为每一步一个宏指令和两次 NBT 读取。
🎬 Cinemalya
🎥 A Minecraft datapack library for flying players through cinematic camera moves.
- ✨ Sweep a player anywhere along a spline, with easing, arcs and particle trails.
- 🎞️ A ready-made title card intro, and signals to hook your own logic in.
- 🧭 Works from a command block:
~ and ^ coordinates throughout.
- 🎯 Rotations sent at full precision, so the camera sweeps instead of notching.
- ⚡ The path is computed once at launch; playback just pops a frame per step.
📦 Embedded library: package it inside your datapack rather than shipping it separately.
Requires LanternLoad and Bookshelf Spline.
⚡ Quick start
execute as @p run function #cinemalya:v1/launch {with:{x:19.5,y:82.5,z:23.5,duration:60,arc_side:1,particle:"minecraft:glow"}}
Every entry point takes one with compound, so each field inside stays optional.
🔧 Entry points
#cinemalya:v1/launch
execute as <player> run function #cinemalya:v1/launch {with:{x:19.5,y:82.5,z:23.5,duration:60,arc_side:1}}
x / y / z are where the player ends up standing, not where the camera stops.
#cinemalya:v1/launch_here
Destination comes from the execution position and rotation, so relative coordinates work. NBT cannot hold a ~, which is why launch needs absolute numbers and this one exists.
execute positioned ~12 ~8 ~-4 rotated 90 20 as @a[distance=..30] run function #cinemalya:v1/launch_here {with:{duration:60,arc_side:1}}
Mind the order: positioned resolves against the command block before as swaps the executor, so the destination is fixed while each player still starts from their own feet. facing and ^ work too.
#cinemalya:v1/launch_at_entity
execute as <player> run function #cinemalya:v1/launch_at_entity {with:{target:"@e[tag=camera_anchor,limit=1]",duration:60,ease:"ease_in_out"}}
#cinemalya:v1/launch_path
Fly through explicit waypoints. Here the positions are camera positions, used literally.
execute as <player> run function #cinemalya:v1/launch_path {with:{duration:90,ease:"ease_in_out",waypoints:[{args:[-112,75,-21,-30,4]},{args:[-116,77,28,-121,16]},{args:[-72,68,20,92,-11.7]}]}}
waypoints[0] is the starting point, so three waypoints mean two segments. Give just one and the player's own position starts the path. A waypoint may be written three ways:
| Key |
Example |
|
args |
{args:[x,y,z,yaw,pitch,duration]} |
Flat, stop early at 3 or 5. Integers are fine |
pos / rot |
{pos:[0.5,90.0,0.5],rot:[0.0,20.0]} |
Explicit |
at |
{at:"~30 ~12 ~-30",rot:[135,20]} |
Relative to where the command ran, ~ or ^ |
Missing rot keeps the previous heading. The waypoints with no duration share theirs in proportion to the length of the segment arriving at them, so the camera flies at one steady speed through them; together they get the part of the total they would get as equal shares. at overrides pos. Local ^ needs an execution rotation, so add rotated when using it from a command block.
Easing. A path-level ease shapes the whole travel: it accelerates off the first waypoint, cruises through the middle ones at a steady pace, and settles onto the last. Put ease on a waypoint instead to shape only the hop arriving there:
execute as <player> run function #cinemalya:v1/launch_path {with:{waypoints:[{args:[-112,75,-21,-30,4]},{args:[-116,77,28,-121,16,55],ease:"ease_out"},{args:[-72,68,20,92,-11.7,25],ease:"ease_in"}]}}
That drifts to a near stop on the middle waypoint, holds the beat, then accelerates away.
Teleports. A waypoint with tp:true is reached by teleport: nothing is flown from the one before it. Circle a building, then cut to the inside and carry on:
execute as <player> run function #cinemalya:v1/launch_path {with:{duration:120,waypoints:[{args:[0,70,0]},{args:[10,70,10]},{args:[20,70,0]},{args:[200,64,0,90,0],tp:true,delay:20},{args:[210,64,0]}]}}
The path is cut at every teleport and each piece is sampled on its own, so no curve bends across a cut. They share duration in proportion to the segments each one flies, and an ease applies to each piece. The camera lands exactly on the tp waypoint, then holds there for its delay ticks (0 by default), time for the chunks around it to load. A path takes up to 8 pieces. The key is read by presence, so tp:false still counts as a teleport: leave it out instead. A teleport under 64 blocks would normally glide across the map on the client, so the camera's teleport_duration is cut to 0 the tick before.
Waypoint events. A waypoint with function:"<namespace>:<path>" runs it when the camera reaches the waypoint, as the player (or as the camera for gamemode:"none"), at the camera. Every waypoint also fires on_waypoint. The first waypoint fires on the first step, about one block after the starting point.
#cinemalya:v1/intro
Hold on an establishing shot, name the scene, place every player, fly them all in. Run it positioned and rotated at the shot.
execute positioned 36.29 102.97 81.36 rotated 145.55 21.76 run function #cinemalya:v1/intro {with:{title:"Warden Forest",subtitle:"by Stoupy",display_time:130,duration:50}}
target_function runs as each player and is where you teleport them to their spot; omit it and they stay put. Also takes selector, sound, title_color, subtitle_color, and every launch field.
#cinemalya:v1/stop
execute as <player> run function #cinemalya:v1/stop {with:{}}
The player is left exactly where the camera was, so you decide where they belong. restore:false leaves them in spectator too.
#cinemalya:v1/editor/start
Record a path in game instead of typing coordinates. start gives you the editor item, editor/stop takes it back.
function #cinemalya:v1/editor/start
| With the item in hand |
Does |
| Right click |
Place a keyframe at your eyes, with your rotation |
| Left click |
Remove the last keyframe |
| Sneak + right click |
Preview the path |
| Swap hands (default F) |
Make the last keyframe a teleport, or fly to it again |
| Drop it |
Open the export, with the item handed back to you |
The export shows two launch_path commands to copy into a command block: one with absolute positions, one with positions relative to its execute positioned coordinates, which start on the first keyframe, so editing them moves the whole path. Both last duration:200 ticks and move between keyframes with ease:"linear", written in the command so you edit them there (ease_in, ease_out and ease_in_out are the other choices). Every other option is written with its default value too, except particle and spline. Every editor shares the same path, up to 128 keyframes, and it is cleared when the last of them stops.
📋 Options
| Field |
Type |
Default |
Meaning |
duration |
int |
60 |
Length of the travel, in ticks |
smoothing |
int |
1 |
Ticks between frames. Higher is cheaper and softer |
delay |
int |
0 |
Ticks to hold still before moving |
ease |
string |
"linear" |
linear, ease_in, ease_out, ease_in_out |
spline |
string |
auto |
bezier (2 waypoints) or catmull_rom (more) |
arc_side |
float |
0.0 |
Sideways swing, as a fraction of half the distance |
arc_height |
float |
0.0 |
How far above the higher end the arc peaks, see below |
particle |
string |
none |
Particle trailed behind the camera |
gamemode |
string |
"restore" |
restore, keep (already spectator), none (no player) |
mode |
string |
"spectator" |
spectator, or ride to sit on the camera in your own gamemode, see ride |
body |
string |
none |
mannequin: a mannequin with your skin, armor and hands stands one block behind the camera, for everyone else to see. Looking straight down still shows its helmet and hands |
pose |
string |
"standing" |
With body: standing, crouching, swimming or fall_flying |
protect |
bool |
false |
Resistance for the whole travel, cleared at the end, so a rider takes no damage |
tags |
list |
[] |
Extra tags on the cinematic entity |
precise_rotation |
bool |
true |
See rotation precision |
yaw / pitch |
float |
target's |
Override the ending rotation |
Per entry point: launch takes x/y/z, launch_at_entity takes target, launch_path takes waypoints, launch_here takes neither. yaw/pitch do not apply to launch_path, where each waypoint carries its own rot.
Arc. arc_height:0.0 flies two-waypoint travels (launch, launch_here, launch_at_entity, or a launch_path of two waypoints) in a straight line. A value like 10 to 20 lifts the camera over the middle of a long travel, which usually looks better when the ends are far apart or at different heights. A path through three or more waypoints follows its own curve and ignores it.
Limits
Every argument that ends up bounding a loop is clamped at launch, so a typo costs you a wrong looking cinematic rather than a frozen server.
| Argument |
Bound |
What happens past it |
duration, .duration |
36000 (30 min) |
Clamped, per travel and per waypoint |
smoothing |
1 to 100 |
Clamped |
waypoints |
128 |
Refused, with a red message to the player and fail |
| Pieces (teleports + 1) |
8 |
Refused, with a red message to the player and fail |
tags |
32 |
The extras are dropped |
| Frames emitted |
600 |
The smoothing rises so the path keeps its full length |
A travel asking for more frames than the budget gets a softer smoothing instead of a shortened path, so duration:36000 still lands where you told it to. The cap keeps a launch under the max_command_sequence_length default of 65536 commands, past which Minecraft drops the rest of it and no camera appears.
📡 Signals
Add your own function to these tags. They run as and at the player, or as the camera when the path has no player.
| Tag |
When |
#cinemalya:v1/signals/on_launch |
Just before the camera takes them. Cancel parkour timers, combat tags, anything a teleport should interrupt |
#cinemalya:v1/signals/on_finish |
Once they are set down and their gamemode is back |
#cinemalya:v1/signals/on_waypoint |
Each time the camera reaches a waypoint, at the camera. #waypoint cinemalya.data is its index from 0 |
🔍 Notes
Reading the state. #entities cinemalya.data counts the cinematics playing right now, so you can gate on it (execute if score #entities cinemalya.data matches 1.. run return 1). Camera entities carry the cinemalya.cinematic tag plus whatever you passed in tags.
Riding. mode:"ride" keeps the player in their own gamemode and sits them on the camera, so they keep their hands, HUD and body, and the camera is where their eyes are. Their head stays free: nothing can turn it for them smoothly, since a forced rotation only moves in steps of one tick. Use the default spectator mode for a sweeping pan. Sneaking cannot get a rider off, the camera puts them back, but the game still prints its dismount hint. Pair it with protect:true so nothing hurts them on the way. That clears the player's own resistance effect when the travel ends.
Rotation precision. Minecraft quantises rotations to steps of 360/256 = 1.40625°, which makes a /spectate camera turn in visible notches (MC-184359). Flipping the camera's OnGround flag each tick makes the server send full precision instead. On by default, one command per cinematic per tick, no side effect since display entities are not living entities. It relies on MC-278440, a community find, so a future version could close it: pass precise_rotation:false to opt out.
How it works. A cinematic is an invisible item_display the player spectates. Your waypoints become spline control points, Bookshelf samples them into a dense polyline, and each segment picks exactly as many frames as its duration buys. All of that happens once at launch, so playback costs one macro and two NBT reads per step whether the path is 10 frames or 500.
评论 0
登录后参与评分
还没有评论,来抢沙发吧