【问题标题】:Minecraft Commands - Recursive FunctionsMinecraft 命令 - 递归函数
【发布时间】:2021-11-06 07:49:50
【问题描述】:

我正在制作一种激光武器,它基本上是一种在 3D 世界中重复自身的功能,每个命令都相对于前一个命令向前执行一个块。然而,我发现它非常强大,并决定通过减少武器的有效射程来削弱它。我相信这可以通过在某种程度上停止递归来实现,例如在第 101 次执行递归时停止递归将导致武器的有效范围为 100 格。

部分代码用raycast.mcfunction编写

playsound block.iron_trapdoor.open master @a
playsound block.respawn_anchor.deplete master @a
playsound entity.generic.explode master @a
playsound entity.generic.extinguish_fire master @a

particle small_flame ~ ~ ~ 0 0 0 0 100 normal @a
execute if block ~ ~ ~ air unless entity @e[distance=0.1..0.3,type=!armor_stand,type=!item_frame,type=!item,type=!player,type=!area_effect_cloud] positioned ^ ^ ^0.5 run function datapack:raycast

但是,我无法完全找到实现此目的的方法,因为我的世界中的所有变量(记分牌目标)似乎仅对实体可用。递归函数不是实体,尽管它在 3D 世界中“移动”。

任何实现我限制递归次数目标的建议和方法将不胜感激!

【问题讨论】:

    标签: minecraft


    【解决方案1】:

    为了解决这个问题,不能使用递归函数,因为它们不被视为实体。我发现通过射击隐形盔甲架可以解决问题。 召唤盔甲架

    execute at @s run summon armor_stand ~ ~ ~ {Invulnerable:1b,Tags:["melta","new_melta"]}
    

    主要功能

    execute as @e[tag=new_melta] at @s rotated as @p run teleport @s ~ ~ ~ ~ ~
    execute as @e[tag=new_melta] run tag @s remove new_melta
    execute as @e[tag=melta] at @s if block ~ ~ ~ air run tp @s ^ ^ ^1
    execute as @e[tag=melta] at @s run summon tnt
    execute as @e[tag=melta] at @s unless block ~ ~ ~ air run tag @s add crashed
    execute as @e[tag=crashed] run kill @s
    

    上面显示的代码可用于在玩家注视的地方射击盔甲架,并在其移动时召唤 tnt。这样我们就可以将激光变成一个实体。

    唯一的缺点是激光不以光速传播,而是每秒移动 20 个方块(20 刻 = 1 秒)

    【讨论】:

      猜你喜欢
      • 2019-06-07
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 2010-10-16
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      相关资源
      最近更新 更多