此数据包作为许多 Qrazy 数据包的库,并为像我这样的数据包开发者提供一些实用的工具。
附魔驱动的多槽位物品
是否曾想过仅用一个物品就能创建全身盔甲套装或双手武器?这个数据包让这一切变得简单。通过使用附魔标签,你可以让单个物品占据多个槽位,并具备多种不同的自定义功能。
盔甲套装和双手武器是绑定到附魔而非物品的。这意味着当将盔甲套装或双手武器附魔应用到任何给定物品时,其效果都是一样的(尽管对于盔甲套装来说,物品必须能够装备在腿部槽位才能正常工作)。
盔甲套装
首先,创建一个新的附魔。为了让盔甲套装正常运行,你需要遵循以下一些准则:
- 该附魔必须在每一刻运行一次函数
qrazy:armor_set/master/tick。
- 该附魔必须仅使用
legs(腿部)槽位。盔甲套装仅设计用于腿部槽位,使用其他槽位可能会导致不可预测的后果。
除此之外,你可以随意自定义该附魔。它可以拥有任何描述、任何支持的物品、任何其他效果等,只要符合上述准则即可。
创建好附魔后,你需要决定它应该替换哪些槽位。盔甲套装物品始终位于腿部槽位,并且可以替换头部、胸部和/或脚部槽位。要让盔甲套装替换某个槽位,请将其添加到对应的附魔标签中。
头部槽位: #qrazy:armor_set/replaces_slot/head (data/qrazy/tags/enchantment/armor_set/replaces_slot/head.json)
胸部槽位: #qrazy:armor_set/replaces_slot/chest (data/qrazy/tags/enchantment/armor_set/replaces_slot/chest.json)
脚部槽位: #qrazy:armor_set/replaces_slot/feet (data/qrazy/tags/enchantment/armor_set/replaces_slot/feet.json)
? 正在建设中 ?
对于你可以复制并粘贴到自己的数据包中并按需修改的文件,请下载包含在 1.1.0 及以上版本下载中的文件 qrazy_templates.zip。
其他实用工具
此数据包还添加了一些简单的实用工具,以简化开发者的工作。
根据 UUID 查找实体
运行 function qrazy:get_uuid {input: [array UUID], command: "(command to execute)"} 以查找由整数数组表示的 UUID 的所有者,因为它们通常存储在 NBT 中(例如怪物的 Owner 标签)。command 参数指定由函数找到的实体执行的命令。
示例
/function qrazy:get_uuid {input: [0, 1, 2, 3], command: "say hi"}
获取实体的名称
运行 /function qrazy:get_entity_name {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} 以将命令执行者的名称作为文本组件存储在指定的输出路径中。
示例
/function qrazy:get_entity_name {output_path: "storage qrazy:foo bar.baz"}
存储 qrazy:foo 中的输出:
{
bar: {
baz: (执行者的名称,以文本组件形式)
}
}
获取实体的类型
运行 /function qrazy:get_entity_id {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} 以将命令执行者的实体类型作为字符串存储在指定的输出路径中。
示例
/execute as @n[type=pig] run function qrazy:get_entity_id {output_path: "storage qrazy:foo bar.baz"}
存储 qrazy:foo 中的输出:
{
bar: {
baz: "minecraft:pig"
}
}
获取实体的字符串 UUID
运行 /function qrazy:get_string_uuid {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} 以将命令执行者的十六进制 UUID 作为字符串存储在指定的输出路径中。(重要提示:对于玩家,此函数返回的是玩家的用户名。无法避免这种情况。)
示例
/function qrazy:get_string_uuid {output_path: "storage qrazy:foo bar.baz"}
存储 qrazy:foo 中的输出:
{
bar: {
baz: (执行者的十六进制 UUID 或用户名)
}
}
获取命令执行的位置
运行 function qrazy:store_position/(nbt|scoreboard) {output_path: "(block <sourcePos>|entity <source>|storage <source>)", output_score: "(scoreboard owner) (scoreboard prefix)"} 以获取命令执行时的方块位置。如果你使用 NBT 函数,位置将存储在 (output_path)_(x|y|z) 中;如果使用记分板函数,则存储在 (scoreboard owner) (scoreboard prefix).(x|y|z) 中。
示例:NBT
/execute positioned 1.1 2.2 3.3 run function qrazy:store_position/nbt {output_path: "storage qrazy:foo bar.baz"}
输出至存储 qrazy:foo:
{
bar: {
baz_x: 1.1d,
baz_y: 2.2d,
baz_z: 3.3d
}
}
示例:记分板
/execute positioned 1.1 2.2 3.3 run function qrazy:store_position/scoreboard {output_score: "@s qrazy.foo"}
输出记分板分数:
qrazy.foo.x = 1
qrazy.foo.y = 2
qrazy.foo.z = 3
将整数颜色转换为十六进制代码
运行 function qrazy:integer_color_to_hex {integer_color: (integer color), output_path: "(block <sourcePos>|entity <source>|storage <source>)"} 以获取整数颜色的十六进制代码。输出的十六进制代码将存储在 (output_path)_(r16|r1|g16|g1|b16|b1) 中,其中每个值都是 0 到 F 之间的单字符字符串。
示例
/function qrazy:integer_color_to_hex {integer_color: 11259375, output_path: "storage qrazy:foo bar.baz"}
输出至存储 qrazy:foo:
{
bar: {
baz_r16: "A",
baz_r1: "B",
baz_g16: "C",
baz_g1: "D",
baz_b16: "E",
baz_b1: "F",
}
}
对任意物品施加指定数量的耐久度伤害
运行 function qrazy:damage_item_not_normalized {item_damage: (耐久度点数), slot_path: "(方块 <位置>|实体 <目标>) <槽位>"} 以向物品施加特定数量的耐久度伤害。与原版物品修饰符使用的系统不同,此处的耐久度不会进行归一化处理。
示例
/function qrazy:damage_item_not_normalized {item_damage: 5, slot_path: "entity @s weapon.mainhand"}
无视物品最大耐久度,使你的主手物品耐久值减少 5。
将 NBT 存储为文本组件
运行 function qrazy:nbt_to_text {source: "(block|entity|storage)", block: "(<x> <y> <z>)", entity: "(<source>)", storage: "(<storage>)", nbt: "(<sourcePath>)", output_path: "(block <sourcePos>|entity <source>|storage <source>)"} 可将输入内容转换为文本并存储到输出中。(注意:即使这些参数不会同时使用,但为了函数正常运行,block、entity 和 storage 参数都必须存在。)
示例
/function qrazy:nbt_to_text {source: "storage", block: "", entity: "", storage: "qrazy:foo", nbt: "map", output_path: "storage qrazy:bar map_text"}
来自存储 qrazy:foo 的输入:
{
map: {
some: "data",
here: true
}
}
存储输出 `qrazy:bar`:
{
map_text: '{"some":"data","here":1b}'
}
在槽位之间复制特定物品组件(1.21.5+)
运行 function qrazy:copy_component {source_item_path: "(block <pos>|entity <targets>) <slot>", target_item_path: "(block <pos>|entity <targets>) <slot>", component: "(<component id>)"} 以将指定的 component 从 source_item_path 复制到 target_item_path。component 参数也必须以 minecraft: 为前缀。(注意:给定的组件必须在源物品的 NBT 数据中指定,因此例如从未附魔的钻石剑复制 minecraft:attribute_modifiers 组件将不起作用。)
示例
/function qrazy:copy_component {source_item_path: "entity @s weapon.mainhand", target_item_path: "entity @s weapon.offhand", component: "minecraft:enchantments"}
将执行者主手物品上的所有附魔复制到其副手物品上。
This data pack serves as a library for many Qrazy data packs and provides some helpful utils for data pack developers such as myself.
Enchantment-driven multi-slot items
Ever want to create a full-body armor set or a two-handed weapon in just one item? This pack makes it easy. Using enchantment tags, you can make a single item take up more than one slot with several different customizable functions.
Armor sets and two-handers are tied to enchantments, not to items. This means that an armor set or two-hander enchantment will function the same way when applied to any given item (although items do have to be equippable on the legs for armor sets to work).
Armor sets
To get started, create a new enchantment. For the armor set to function properly, you need to follow a couple guidelines:
- The enchantment must run the function
qrazy:armor_set/master/tick once per tick.
- The enchantment must only use the slot
legs. Armor sets are only designed to use the legs slot, and using any other slot may have unpredictable consequences.
Beyond that, you can customize the enchantment all you want. It can have any description, any supported items, any other effects, etc., as long as you comply with the guidelines above.
After you've created your enchantment, you need to decide which slots it should replace. Armor set items always go in the legs slot, and they can replace the head, chest, and/or feet slots. To make an armor set replace a slot, add it to the corresponding enchantment tag.
For the head slot: #qrazy:armor_set/replaces_slot/head (data/qrazy/tags/enchantment/armor_set/replaces_slot/head.json)
For the chest slot: #qrazy:armor_set/replaces_slot/chest (data/qrazy/tags/enchantment/armor_set/replaces_slot/chest.json)
For the feet slot: #qrazy:armor_set/replaces_slot/feet (data/qrazy/tags/enchantment/armor_set/replaces_slot/feet.json)
? UNDER CONSTRUCTION ?
For files you can copy and paste into your own data pack and modify to your liking, download the file qrazy_templates.zip included in the downloads for versions 1.1.0 and above.
Other utils
This pack also adds a few simple utils to make developers' lives easier.
Find an entity from its UUID
Run function qrazy:get_uuid {input: [array UUID], command: "(command to execute)"} to find the owner of a UUID represented as an integer array, as they are often stored in NBT (such as a mob's Owner tag). The command argument specifies the command to be executed by the entity found by the function.
Example
/function qrazy:get_uuid {input: [0, 1, 2, 3], command: "say hi"}
Get the name of an entity
Run /function qrazy:get_entity_name {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} to store the name of the command executor as a text component in the specified output path.
Example
/function qrazy:get_entity_name {output_path: "storage qrazy:foo bar.baz"}
Output in storage qrazy:foo:
{
bar: {
baz: (the executor's name in text component form)
}
}
Get the type of an entity
Run /function qrazy:get_entity_id {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} to store the entity type of the command executor as a string in the specified output path.
Example
/execute as @n[type=pig] run function qrazy:get_entity_id {output_path: "storage qrazy:foo bar.baz"}
Output in storage qrazy:foo:
{
bar: {
baz: "minecraft:pig"
}
}
Get the string UUID of an entity
Run /function qrazy:get_string_uuid {output_path: "(block <sourcePos>|entity <source>|storage <source>)"} to store the hexadecimal UUID of the command executor as a string in the specified output path. (Important note: For players, this function instead returns the player's username. There is no way around this.)
Example
/function qrazy:get_string_uuid {output_path: "storage qrazy:foo bar.baz"}
Output in storage qrazy:foo:
{
bar: {
baz: (the executor's hex UUID or username)
}
}
Get the position of a command's execution
Run function qrazy:store_position/(nbt|scoreboard) {output_path: "(block <sourcePos>|entity <source>|storage <source>)", output_score: "(scoreboard owner) (scoreboard prefix)"} to get the block position at which a command is being executed. The position is stored in (output_path)_(x|y|z) if you use the NBT function, and in (scoreboard owner) (scoreboard prefix).(x|y|z) if you use the scoreboard function.
Example: NBT
/execute positioned 1.1 2.2 3.3 run function qrazy:store_position/nbt {output_path: "storage qrazy:foo bar.baz"}
Output in storage qrazy:foo:
{
bar: {
baz_x: 1.1d,
baz_y: 2.2d,
baz_z: 3.3d
}
}
Example: Scoreboard
/execute positioned 1.1 2.2 3.3 run function qrazy:store_position/scoreboard {output_score: "@s qrazy.foo"}
Output scores:
qrazy.foo.x = 1
qrazy.foo.y = 2
qrazy.foo.z = 3
Convert integer color to hex code
Run function qrazy:integer_color_to_hex {integer_color: (integer color), output_path: "(block <sourcePos>|entity <source>|storage <source>)"} to get the hex code of an integer color. The output hex code is stored in (output_path)_(r16|r1|g16|g1|b16|b1), where each value is a single-character string from 0 to F.
Example
/function qrazy:integer_color_to_hex {integer_color: 11259375, output_path: "storage qrazy:foo bar.baz"}
Output in storage qrazy:foo:
{
bar: {
baz_r16: "A",
baz_r1: "B",
baz_g16: "C",
baz_g1: "D",
baz_b16: "E",
baz_b1: "F",
}
}
Apply specific numbers of durability damage to any item
Run function qrazy:damage_item_not_normalized {item_damage: (number of durability points), slot_path: "(block <pos>|entity <targets>) <slot>"} to apply a specific amount of durability damage to an item. Unlike the system used in vanilla item modifiers, the durability is not normalized.
Example
/function qrazy:damage_item_not_normalized {item_damage: 5, slot_path: "entity @s weapon.mainhand"}
Decreases the durability of your mainhand item by 5, regardless of its maximum durability.
Store NBT as a text component
Run function qrazy:nbt_to_text {source: "(block|entity|storage)", block: "(<x> <y> <z>)", entity: "(<source>)", storage: "(<storage>)", nbt: "(<sourcePath>)", output_path: "(block <sourcePos>|entity <source>|storage <source>)"} to convert the contents of the input into text and store it in the output. (Note: The block, entity, and storage arguments must all be present for the function to run, even though they are not used at the same time.)
Example
/function qrazy:nbt_to_text {source: "storage", block: "", entity: "", storage: "qrazy:foo", nbt: "map", output_path: "storage qrazy:bar map_text"}
Input from storage qrazy:foo:
{
map: {
some: "data",
here: true
}
}
Output in storage qrazy:bar:
{
map_text: '{"some":"data","here":1b}'
}
Copy a specific item component between slots (1.21.5+)
Run function qrazy:copy_component {source_item_path: "(block <pos>|entity <targets>) <slot>", target_item_path: "(block <pos>|entity <targets>) <slot>", component: "(<component id>)"} to copy the specified component from the source_item_path to the target_item_path. The component argument must also be prefixed with minecraft:. (Note: The given component must be specified in the source item's NBT data, so for example copying the minecraft:attribute_modifiers component from an unmodified diamond sword will not work.)
Example
/function qrazy:copy_component {source_item_path: "entity @s weapon.mainhand", target_item_path: "entity @s weapon.offhand", component: "minecraft:enchantments"}
Copies all enchantments from the executor's mainhand item to their offhand item.
评论 0
登录后参与评分
还没有评论,来抢沙发吧