本帖最后由 贰逼 于 2019-7-12 00:24 编辑

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


效果(共4.81MB的gif)

低头潜行,趴下;匍匐时跳跃(前提是没有方块阻挡),起身


原理
主要原理就是如果在玩家脚上1格(~ ~1 ~)有方块,则玩家会进入匍匐状态,这是1.14的新特性
  • 方块标签
“#prostrate:through” 表示完全能穿过的方块(如玫瑰丛,高草)
“#prostrate:in” 表示不能穿过,但不完整的方块(如箱子,附魔台)
  • 命令
  1. #判定趴下
  2. execute as @a[x_rotation=60..,scores={sneakTime=1..},nbt={OnGround:1b}] at @s unless block ~ ~1 ~ #prostrate:through run tag @s add prostrating
  3. #如果头顶是能穿过的方块,则不能趴下
  4. execute as @a[tag=prostrating] at @s if block ~ ~1 ~ #prostrate:through run tag @s remove prostrating

  5. #生成一个Marker,记录上一个位置
  6. execute at @a[tag=prostrating] run summon minecraft:area_effect_cloud ~ ~1 ~ {Duration:2,Tags:[prostrateMarker]}
  7. #将上一个位置的屏障替换成空气
  8. execute at @e[tag=prostrateMarker] run fill ~ ~ ~ ~ ~ ~ minecraft:air replace minecraft:barrier

  9. #如果玩家不在不完整的方块里面,则在脚上方1格处放置屏障
  10. execute at @a[tag=prostrating] unless block ~ ~ ~ #prostrate:in run setblock ~ ~1 ~ minecraft:barrier keep
  11. #若果玩家在不完整的方块里面,则在脚上方2格处放置屏障
  12. execute at @a[tag=prostrating] if block ~ ~ ~ #prostrate:in run setblock ~ ~2 ~ minecraft:barrier keep

  13. #结束匍匐状态
  14. tag @a[tag=prostrating,scores={jumpCount=1..}] remove prostrating

  15. #重置计分板
  16. scoreboard players reset @a[scores={jumpCount=1..}] jumpCount
  17. scoreboard players reset @a[scores={sneakTime=1..}] sneakTime
复制代码
可以说非常简单

(7.12更新,修复掉血bug)
  1. 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
  2. execute as @a[tag=prostrating] at @s if block ~ ~1 ~ #prostrate:through run tag @s remove prostrating
  3. execute as @a[tag=_prostrating] at @s run summon minecraft:area_effect_cloud ~ ~1 ~ {Duration:2,Tags:[_prostrateMarker]}
  4. execute as @a[tag=_prostrating] at @s run fill ~ ~1 ~ ~ ~1 ~ minecraft:glass keep
  5. execute as @e[tag=_prostrateMarker,nbt={Age:1}] at @s run fill ~ ~ ~ ~ ~ ~ minecraft:air replace minecraft:glass
  6. execute as @e[tag=_prostrateMarker,nbt={Age:1}] run tag @a[tag=_prostrating] add prostrating
  7. tag @a[tag=_prostrating] remove _prostrating
复制代码
加了几条命令控制首次放置的方块为玻璃,随后替换为屏障

你只需要将下面的数据拖入存档的datapacks文件夹,即可使用:
prostrate.zip (5.86 KB, 下载次数: 62) [groupid=546]Command Block Logic[/groupid]