版本1.14,借助趴下的特性,利用潜行和起跳事件,再加上方块标签实现自由匍匐
效果(共4.81MB的gif)



低头潜行,趴下;匍匐时跳跃(前提是没有方块阻挡),起身
原理
主要原理就是如果在玩家脚上1格(~ ~1 ~)有方块,则玩家会进入匍匐状态,这是1.14的新特性
- 方块标签
“#prostrate:in” 表示不能穿过,但不完整的方块(如箱子,附魔台)
- 命令
- #判定趴下
- execute as @a[x_rotation=60..,scores={sneakTime=1..},nbt={OnGround:1b}] at @s unless block ~ ~1 ~ #prostrate:through run tag @s add prostrating
- #如果头顶是能穿过的方块,则不能趴下
- execute as @a[tag=prostrating] at @s if block ~ ~1 ~ #prostrate:through run tag @s remove prostrating
- #生成一个Marker,记录上一个位置
- execute at @a[tag=prostrating] run summon minecraft:area_effect_cloud ~ ~1 ~ {Duration:2,Tags:[prostrateMarker]}
- #将上一个位置的屏障替换成空气
- execute at @e[tag=prostrateMarker] run fill ~ ~ ~ ~ ~ ~ minecraft:air replace minecraft:barrier
- #如果玩家不在不完整的方块里面,则在脚上方1格处放置屏障
- execute at @a[tag=prostrating] unless block ~ ~ ~ #prostrate:in run setblock ~ ~1 ~ minecraft:barrier keep
- #若果玩家在不完整的方块里面,则在脚上方2格处放置屏障
- execute at @a[tag=prostrating] if block ~ ~ ~ #prostrate:in run setblock ~ ~2 ~ minecraft:barrier keep
- #结束匍匐状态
- tag @a[tag=prostrating,scores={jumpCount=1..}] remove prostrating
- #重置计分板
- scoreboard players reset @a[scores={jumpCount=1..}] jumpCount
- scoreboard players reset @a[scores={sneakTime=1..}] sneakTime
(7.12更新,修复掉血bug)
- execute as @a[x_rotation=60..,scores={sneakTime=1..},nbt={OnGround:1b},tag=!prostrating] at @s unless block ~ ~1 ~ #prostrate:through run tag @s add _prostrating
- execute as @a[tag=prostrating] at @s if block ~ ~1 ~ #prostrate:through run tag @s remove prostrating
- execute as @a[tag=_prostrating] at @s run summon minecraft:area_effect_cloud ~ ~1 ~ {Duration:2,Tags:[_prostrateMarker]}
- execute as @a[tag=_prostrating] at @s run fill ~ ~1 ~ ~ ~1 ~ minecraft:glass keep
- execute as @e[tag=_prostrateMarker,nbt={Age:1}] at @s run fill ~ ~ ~ ~ ~ ~ minecraft:air replace minecraft:glass
- execute as @e[tag=_prostrateMarker,nbt={Age:1}] run tag @a[tag=_prostrating] add prostrating
- tag @a[tag=_prostrating] remove _prostrating
你只需要将下面的数据拖入存档的datapacks文件夹,即可使用:
prostrate.zip
(5.86 KB, 下载次数: 62)
