vred's DP Lib

数据包

· 作者 vred_

一个数据包“库”使得自定义武器的创建更加容易。

0 本站下载 0 关注 更新于 8 个月前

最新 0.1.2+mod · 1.21.1 · Fabric / Forge

一键开服(送7天)

vred's Data-Pack Library(简称 vred's DP Lib)是我制作的第一款数据包库。 本项目的主要目的是添加实用工具,以便更快、更轻松地创建自定义物品。 该工具分为以下几个部分:

  • 数据组件(Data Components)
  • 行为组件(Behaviour Components)
  • 函数标签(Function Tags)
  • 其他(Misc)

数据组件(Data Components) 这些组件定义了关于物品的信息。这将非常重要!

作为一般规则,所有 vred's DP lib 的组件都放在 "..." 部分

custom_data={vred_lib:{...}}

组件:id

字符串(string)

这个组件本身并不重要,它仅用于定义物品的 id。

示例:

give @s stick[custom_data={vred_lib:{id:"example:cool_stick"}}]

组件:weapon_id

字符串(string)

这个组件非常重要,因为它是后续组件所必需的。id 包含两个部分,其中一个是 weapon_id,即冒号后面的部分。 它需要在当前数据包中有一个以 weapon_id 命名的文件夹。至于命名空间,将从下一个组件 namespace 中获取。

示例:

give @s stick[custom_data={vred_lib:{id:"example:cooler_stick",weapon_id:cooler_stick}}]

此物品目前尚无任何功能。

组件:namespace

字符串(string)

这个组件也非常重要,因为它同样是后续组件所必需的。id 包含两个部分,其中一个是 namespace,即冒号前面的部分。 它需要在当前数据包中有一个以 namespace 命名的文件夹。

示例:

give @s stick[custom_data={vred_lib:{id:"example:very_cool_stick",weapon_id:very_cool_stick,namespace:example}}]

此物品目前尚无任何功能。

行为组件(Behaviour Components) 这些组件将在特定条件下运行函数。 它们需要特定的槽位才能工作:

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.mcfunction

give @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.mcfunction

effect 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

这会使靴子在单击潜行键时给予跳跃提升 III 效果并生成粒子特效。

组件:interaction

字符串

此组件会在玩家主手持有该物品时,在玩家前方生成一个交互实体。该交互实体可用于鼠标右键和左键点击,相关函数将按以下路径运行:

data/<namespace>/function/<weapon_id>/left_click.mcfunction
data/<namespace>/function/<weapon_id>/right_click.mcfunction

如果设置为 interaction:no_shift,则交互实体将始终存在。 如果设置为 interaction:shift,则交互实体仅在玩家按住 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.mcfunction

say left click

# data/example/function/offbrand_spear/right_click.mcfunction

say 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)

这将创建一个类似弓的自定义物品,且不需要箭矢。为了获得更好的视觉效果,建议在基础物品和弓之间使用匹配的物品模型数据(model data)。 该组件需要食物组件:minecraft:food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000} 并且需要一个基础物品:{vred_lib:{base_item:"<item_id"}}

当发射“箭”时可以运行一个函数:

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 个刻(ticks),它将在前方 5 格处召唤一个 TNT。这仅在主手中有效。

组件:scrollable

布尔值(boolean)

当从主手丢弃该物品时,它将基于 map_id 组件引用一个物品修改器(item modifier)。 这是我开发的一个全新系统,用于显示物品描述,因为每个物品修改器可以引用不同的 Lore 页面,并将 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,以便供下一个物品修改器使用。

函数标签(Function Tags) 我使用的各种函数标签。为什么不使用原版的那些?我也不知道。

#vred_lib:load

其工作方式与正常的 #minecraft:load 函数完全相同。不知道为什么我要创建它。

#vred_lib:entity

仅针对实体(不包括玩家)的 Tick 函数。

#vred_lib:entity

仅针对玩家的 Tick 函数。

其他(Misc) 包含各种杂项但有用的内容。

条件判定(Predicate):vred_lib:stuff 此条件判定包含了不应被锁定的实体。 其中包括:
  • 显示实体(Display entities);
  • 被骑乘的实体;
  • 掉落的物品;
  • 箭矢。
条件判定(Predicate):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 分数,可用于检查玩家的魔力值。

未来将通过添加更多模组来扩展兼容性,请务必发送一些建议!

tag: 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>"}

这将生成带有 <projectile_id> 的投射物。 若要更改该投射物的行为和属性,请在 tick 函数中重新定位它。它内置了一个计时器,名为 rayAge。

throw 函数将保存主手物品的副本,并减少主手中该物品的数量。

随后使用 function vred_lib:projectile/return {id:"<projectile_id>"} 作为投射物,使物品返回给所有者。

自定义粒子

你可以添加自定义粒子。这些粒子也非常基础,仅仅是会移动的炫酷物品展示。 要生成自定义粒子,首先需要在以下标签中添加数据函数:#vred_lib:particle_load

{
    "replace": false,
    "values": [
      "example:particle/load"
    ]
  }
  

# data/example/function/particle/load.mcfunction
## 甜菜根粒子,太棒了
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> 用于计算粒子的速度 (整数)。 实际速度 = (<speed> / 10 格) / 刻 最大 <speed> 值为 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}

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源