
vred的DP库
数据包“库”使创建自定义武器变得更加容易。
查看大图vred 的数据包库(简称 vred 的 DP Lib)是我制作的第一个数据包库。 本项目的主要范围是添加一些实用工具,让你能更快、更轻松地创建自定义物品。 这些工具分为不同部分:
- 数据组件
- 行为组件
- 函数标签
- 杂项
数据组件 这些组件定义物品的信息,非常重要!
作为通用规则,所有 vred 的 DP Lib 组件都放在 "..." 部分
custom_data={vred_lib:{...}}
组件:id
string
这个组件其实不做任何重要的事,只是定义物品的 id。
示例:
give @s stick[custom_data={vred_lib:{id:"example:cool_stick"}}]
组件:weapon_id
string
这个组件非常重要,因为后续组件需要它。id 包含 2 个部分,其中一个是 weapon_id,即 ":" 之后的部分。
它要求当前数据包中有一个以 weapon_id 命名的文件夹。至于命名空间,将从下一个组件 namespace 中获取。
示例:
give @s stick[custom_data={vred_lib:{id:"example:cooler_stick",weapon_id:cooler_stick}}]
这个物品目前还不会做任何事。
组件:namespace
string
这个组件也非常重要,因为后续组件同样需要它。id 包含 2 个部分,其中一个是 namespace,即 ":" 之前的部分。
它要求当前数据包中有一个以 namespace 命名的文件夹。
示例:
give @s stick[custom_data={vred_lib:{id:"example:very_cool_stick",weapon_id:very_cool_stick,namespace:example}}]
这个物品目前还不会做任何事。
行为组件 这些组件会在特定条件下运行函数。 它们需要配合特定槽位才能工作:
mainhand:{...} 在主手。
offhand:{...} 在副手。
head:{...} 头部槽位。
chest:{...} 胸部槽位。
legs:{...} 腿部槽位。
feet:{...} 脚部槽位。
all:{...} 以上所有槽位。
hand:{...} 任意一只手。
armor:{...} 任意盔甲槽位。
组件:on_hit_effect
boolean
这会在击中时运行一个命令。 将要运行的函数是:
data/<namespace>/function/<weapon_id>/on_hit.mcfunction
示例:
give @s bow[custom_data={vred_lib:{id:"example:fast_bow",weapon_id:fast_bow,namespace:example,hand:{on_hit_effect:true}}}]
# data/example/function/fast_bow/on_hit.mcfunctiongive @s arrow
say I hit an entity!
当击中实体时(无论是用箭还是用手),会给予玩家一支箭。
组件:entity_hit_effect
boolean
这会在受到攻击时运行一个命令。 将要运行的函数是:
data/<namespace>/function/<weapon_id>/entity_hit.mcfunction
示例:
give @s stick[custom_data={vred_lib:{id:"example:strong_shield",weapon_id:strong_shield,namespace:example,offhand:{entity_hit_effect:true}}}]
# data/example/function/strong_shield/entity_hit.mcfunction
effect give @s resistance 4 1 true
execute rotated as @s on attacker run tp @s ^ ^ ^2
当副手持有该盾牌时,受到实体攻击会将其击退 2 格。
组件:on_kill
boolean
这会在击杀实体时运行一个命令。 将要运行的函数是:
data/<namespace>/function/<weapon_id>/on_kill.mcfunction
示例:
give @s iron_sword[custom_data={vred_lib:{id:"example:bloodlust",weapon_id:bloodlust,namespace:example,mainhand:{on_kill_effect:true}}}]
# data/example/function/bloodlust/on_kill.mcfunction
effect give @s strength 10 1 true
击杀实体后,使用者会获得数秒的力量 II 效果。
组件:double_sneak_effect
boolean
这会在短时间内按下两次潜行键时运行一个命令。 命令的运行方式如下:
data/<namespace>/function/<weapon_id>/double_sneak.mcfunction
示例:
give @s stick[custom_data={vred_lib:{id:"example:very_cool_stick",weapon_id:very_cool_stick,namespace:example,hand:{double_sneak:true}}}]
# data/example/function/very_cool_stick/double_sneak.mcfunctioneffect give @s speed 2 2
这会让该木棍在快速连续按两次潜行键时给予速度 III(当物品在任意一只手时)。
组件:tap_sneak_effect
boolean
这会在潜行一次(轻按)时运行一个命令。 命令的运行方式如下:
data/<namespace>/function/<weapon_id>/tap_sneak.mcfunction
示例:
give @s diamond_boots[custom_data={vred_lib:{id:"example:jumping_boots",weapon_id:jumping_boots,namespace:example,feet:{tap_sneak:true}}}]
# data/example/function/jumping_boots/tap_sneak.mcfunction
effect give @s jump_boost 3 1
particle cloud ^ ^ ^ 0 0 0 0.2 30
这会让该靴子在轻按潜行键时给予跳跃提升并发出粒子效果。
组件:interaction
string
这个组件会在玩家主手持有该物品时,在玩家前方生成一个交互实体。该交互实体可用于右键和左键点击,函数的运行方式如下:
data/<namespace>/function/<weapon_id>/left_click.mcfunction
data/<namespace>/function/<weapon_id>/right_click.mcfunction
如果是 "interaction:no_shift",交互实体将始终存在。 如果是 "interaction:shift",交互实体只会在玩家潜行时出现。
示例:
give @s netherite_shovel[custom_data={vred_lib:{id:"example:offbrand_spear",weapon_id:offbrand_spear,interaction:no_shift}}]
# data/example/function/offbrand_spear/left_click.mcfunctionsay left click
# data/example/function/offbrand_spear/right_click.mcfunctionsay right click
组件:no_interaction_right_click
boolean
这会在按住右键时运行一个命令。它需要食物组件:minecraft:food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000}
按住右键时该函数会持续运行。
data/<namespace>/function/<weapon_id>/right_click.mcfunction
示例:(需要修改)
give @s blaze_rod[custom_data={vred_lib:{id:"example:hot_rod",weapon_id:hot_rod,namespace:example,no_interaction_right_click:1b}},food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000}]
# data/example/function/hot_rod/right_click.mcfunction
execute anchored eyes run particle flame ^ ^ ^1
execute anchored eyes run particle flame ^ ^ ^2
execute anchored eyes run particle flame ^ ^ ^3
组件:weapon_type:bow
string
这会创建一个类似弓但不需要箭的自定义物品。为了让效果看起来更好,请让基础物品和弓使用匹配的自定义模型数据。
该组件需要食物组件:minecraft:food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000}
并且需要一个基础物品:{vred_lib:{base_item:""}}
它可以在射出“箭”时运行一个函数:
data/<namespace>/function/<weapon_id>/shot.mcfunction
示例:
give @s breeze_rod[custom_data={vred_lib:{id:"example:tnt_wand",weapon_id:tnt_wand,namespace:example,weapon_type:bow,base_item:"minecraft:breeze_rod"}}]
# data/example/function/tnt_wand/shot.mcfunction
execute if score @s component.bow.timer matches 21.. run summon tnt ^ ^ ^5 {Fuse:0s}
如果这个类似弓的物品使用时间超过 21 刻,它会在前方 5 格处召唤一个 TNT。这仅在主手有效。
组件:scrollable
boolean
当从主手丢弃该物品时,它会引用一个基于 map_id 组件的物品修饰器。
这是我为显示物品描述而制作的全新系统,因为每个物品修饰器都可以引用不同的描述页面,并更改 map_id 以进入下一页。
data/<namespace>/item_modifier/page/<weapon_id>/<n>.json
示例:
give @s diamond_sword[custom_data={vred_lib:{id:"example:multitool",weapon_id:multitool,namespace:example,scrollable:1b}},map_id=1,unbreakable={}]
# data/example/item_modifier/page/multitool/1.json(json 中不能有注释)
[{function:"set_item",item:"minecraft:netherite_axe"},{function:"set_components",components:{map_id:2}}]
# data/example/item_modifier/page/multitool/2.json
[{function:"set_item",item:"minecraft:diamond_pickaxe"},{function:"set_components",components:{map_id:3}}]
# data/example/item_modifier/page/multitool/2.json
[{function:"set_item",item:"minecraft:diamond_pickaxe"},{function:"set_components",components:{map_id:3}}]
# data/example/item_modifier/page/multitool/3.json
[{function:"set_item",item:"minecraft:diamond_shovel"},{function:"set_components",components:{map_id:4}}]
# data/example/item_modifier/page/multitool/4.json
[{function:"set_item",item:"minecraft:diamond_hoe"},{function:"set_components",components:{map_id:1}}]
这个示例是一个相当简单的多用途工具,其中每个“页面”都会将多用途工具切换为不同的物品。需要提到的重要一点是,每个物品修饰器都会更改 map_id,以便下一个物品修饰器使用。
函数标签 我使用的各种函数标签。为什么不用原版的?我不知道。
#vred_lib:load
与原版 #minecraft:load 函数功能完全相同。不知道我为什么做了它。
#vred_lib:entity
仅用于实体的刻函数,不包括玩家。
#vred_lib:entity
仅用于玩家的刻函数。
杂项 包含各种杂项但实用的东西。
谓词:vred_lib:stuff
该谓词包含不应被选为目标的实体。
它包括:- 显示实体;
- 被骑乘的实体;
- 掉落的物品;
- 箭。
谓词:vred_lib:id_check
简单的 id 系统。每个玩家都会获得一个 vred_lib.id 分数。你可以使用谓词来检查玩家是否与指定的 ID(存储在计分板上的假玩家中)具有相同的 ID。
在这种情况下,该谓词只会在玩家的 vred_lib.id 分数等于假玩家(#temp)的 vred_lib.id 分数时触发。
分数:vred_lib.config
该分数将用于不同的模组兼容。模组名称以缩写形式存储。目前主要且唯一的示例是 Iron's Spells and Spellbooks。
要检查模组是否存在,请检查假玩家 #iss_compat 的 vred_lib.config 分数。
如果分数为 1,表示该模组存在。检测通过使用模组中的命令来工作。
还有一个 vred_lib.iss.mana 分数,可用于检查玩家的法力值。
未来将扩展与更多模组的兼容性,请务必发送一些建议!
标签:1slot_tag
该标签检查玩家是否至少有 1 个空闲的物品栏和快捷栏槽位。如果有,玩家将拥有该标签。
自定义弹射物
你可以添加自定义弹射物。这些弹射物非常简陋,甚至没有重力(将在未来更改)。
要添加自定义弹射物,
scoreboard players operation #test vred_lib.id = @s vred_lib.id
execute rotated as @s anchored eyes positioned ~ ~-1 ~ run function vred_lib:projectile/summon {id:"<projectile_id>"}
function vred_lib:projectile/throw {id:"<projectile_id>"}
这将生成带有 的弹射物。
要更改该弹射物的行为和数据,请在刻函数中再次选中它。它有一个内置计时器,名为 rayAge。
throw 函数会保存物品的副本并减少主手中该物品的数量。
之后使用 function vred_lib:projectile/return {id:""} 作为弹射物,使物品返回给所有者。
自定义粒子
你可以添加自定义粒子。这些粒子非常简陋,只是会移动的华丽物品显示。 要生成自定义弹射物,你首先需要在此标签中添加数据函数:#vred_lib:particle_load
{
"replace": false,
"values": [
"example:particle/load"
]
}
# data/example/function/particle/load.mcfunction
## beetroot particle, hell yeah
item replace entity @s[tag=<particle.id>] contents with beetroot
为了召唤它:
function vred_lib:particle_system/test/1 {id:<particle.id>,count:<count>,dx:<dx>,dy:<dy>,dz:<dz>,scale:<scale>,\
speed:<speed> lifetime:<lifetime>,\
owner_id:<owner_id, vred_lib.id score of the particle owner>}
<particle.id> 是粒子 id(字符串)。
<dx>、<dy>、<dz> 表示粒子生成的区域(整数)。
<speed> 用于计算粒子的速度(整数)
实际速度 =( / 10 格)/ 刻
最大为 10。
<lifetime> 粒子持续的时间(整数,任意值)。
<owner_id> 是粒子所有者的 vred_lib.id 分数(可以是 "none" 或整数)。如果是 none,则该粒子没有所有者。
回到我们的示例:
function vred_lib:particle_system/test/1 {id:<particle.id>,count:15,dx:0,dy:0,dz:0,scale:1,speed:1,lifetime:20,owner_id:none}
正在加载版本记录…
正在加载评论…
评论在新手盒子客户端中发表,这里同步展示。