实用工具

实用工具

实用工具库

Utils

版本:5

功能

  • 全局、实体与玩家函数
  • 朝面向方向运动的实体
  • 按实体存储数据
  • 常量计分板
  • 玩家计分 ID
  • 谓词
  • 物品修饰器
  • 实体标签
  • 宏函数
  • 自定义使用余数

命令

全局

为所有玩家清空聊天栏:

/function utils:global/clear_chat

隐藏侧边栏:

/function utils:global/hide_sidebar

实体

清除一个实体/生物:

/execute as @n[type=zombie] run function utils:entity/despawn

重置实体/生物/玩家的所有属性:

/execute as @n[type=zombie] run function utils:entity/reset_all_attributes

完全治疗:

/execute as @n[type=iron_golem] run function utils:entity/heal_full

玩家

为玩家清空聊天栏:

/function utils:player/clear_chat

重置经验值(点数与等级):

/function utils:player/xp/reset

获取所有经验点数:

/function utils:player/xp/get_all_points

该函数返回所有经验点数,并将其保存在计分板 utils.player.xp.total_points 中

虚空世界的随机传送:

/function utils:player/random_tp

运动

function utils:motion/calc

summon fireball ^ ^ ^.5

execute store result entity @n[type=fireball] Motion[0] double -0.00025 run scoreboard players get @s utils.motion.mx
execute store result entity @n[type=fireball] Motion[1] double -0.00025 run scoreboard players get @s utils.motion.my
execute store result entity @n[type=fireball] Motion[2] double -0.00025 run scoreboard players get @s utils.motion.mz

或者你可以使用存储与宏方法:

function utils:motion/storage {"value":"-0.00025"}

summon fireball ^ ^ ^.5

data modify entity @n[type=fireball] Motion set from storage utils:motion motion

按实体存储数据

创建数据

有两种创建或添加数据到路径的方式:set 和 append。使用 set 时,路径的绝对值将成为 data 参数;使用 append 时,路径将作为数组,并追加 data 参数。

# 绝对值
/function utils:entity/storage/set {"path":"lives","data":3}
/function utils:entity/storage/set {"path":"name","data":'"lullaby6"'}

# 数组
/function utils:entity/storage/append {"path":"deaths","data":1}
/function utils:entity/storage/append {"path":"deaths","data":2}
/function utils:entity/storage/append {"path":"deaths","data":3}

使用实体的数据运行函数

当你使用 entity/storage/function 时,实体存储中的所有数据/参数将作为宏参数传递给该函数。

/function utils:entity/storage/function {"function":"namespace:say_lives"}

say_lives.mcfunction 文件:

$say $(lives)

移除数据

# 绝对值
/function utils:entity/storage/remove/data {"path":"lives"}
/function utils:entity/storage/remove/data {"path":"name"}

# 数组
/function utils:entity/storage/remove/first {"path":"deaths"}
/function utils:entity/storage/remove/index {"path":"deaths","index":1}

常量

存在从 0 到 1000 的常量。

你可以通过运行此命令检查并获取常量值:

/scoreboard players get <number> utils.const

使用示例:

/scoreboard players get 1 utils.const

玩家计分 ID

获取玩家计分 ID:

/scoreboard players get @s utils.player.id

谓词

  • can/see_sky
  • has/effect/<effect_name>(speed、regeneration……)
  • has/passenger
  • in/biome/<biome_name>
  • in/structure/<structure_name>(village、desert_pyramid、trial_chambers……)
  • in/dimension/<dimension_name>(overworld、the_nether、the_end)
  • in/light/<level>(0、5、10、15、0-5、5-10……)
  • is/raining
  • is/thundering
  • is/baby
  • is/falling
  • is/flying
  • is/ground
  • is/on_fire
  • is/riding
  • is/sneaking
  • is/sprinting
  • is/swimming
  • random/<chance> <0.1(10%)、0.5(50%)……>

示例:

/execute as @s if predicate utils:is/on_fire run say I am on fire D:

物品修饰器

  • count
    • count/add/<number>
    • count/remove/<number>
    • count/set/<number>
  • enchantment_glint_override/<boolean>
  • max_stack_size/<number>
  • rarity/<rarity_name>
  • remove_component/<item_component_name>(use_cooldown、enchantments、max_stack_size……)
  • repair_cost/<number>
  • tooltip/<tooltip_name>/<show | hide>
  • use_cooldown/<time>(1s、2s、1m、1h……)
  • damage
    • damage/add/0.<number>
    • damage/set/0.<number>
  • clear_bundle
  • clear_container
  • death_protection
  • enchant_randomly_compatible
  • enchant_randomly
  • furnace_smelt
  • glider
  • hide_additional_tooltip
  • hide_tooltip
  • non_consumable
  • one_use
  • remove_container_loot
  • repair
  • unbrekeable

示例:

/execute if items entity @s weapon.mainhand minecraft:raw_iron run item modify entity @s weapon.mainhand utils:furnace_smelt

实体标签

  • all_boats
  • animals
  • aquatics_animals
  • aquatics_real_animals
  • aquatics
  • arthropods
  • boats_with_chest
  • boats
  • bosses
  • cows
  • end
  • fishs
  • flyers_hostiles
  • flyers
  • horses
  • hostiles
  • humanoids
  • illagers
  • monsters
  • nether
  • neutrals
  • passives
  • piglins
  • proyectiles
  • real_animals
  • rideables_animals
  • rideables
  • slimes
  • spiders
  • tameables
  • undead
  • villagers_hostiles
  • villagers
  • zombiess
  • team_player

示例:

/effect give @e[type=#utils:team_player] glowing 1 0

许可证

MIT

🎁 服务器托管

搭建自己的服务器可能是一个非常漫长、繁琐且昂贵的过程。

但借助 BisectHosting,你只需点击几下即可拥有自己的服务器!凭借他们的 24/7 支持和快速响应时间,任何问题都不会阻挡你! 感兴趣?那我们为你准备了一个优惠!

https://bisecthosting.com/lullaby

服务器托管