DataPackPlus (DP+)
一款实用的 Minecraft Fabric 模组,旨在改善数据包开发者的工作体验!
报告 Bug
·
请求功能
项目简介
我的朋友 Nedraw 是一名数据包开发者,我们正合作进行模组和数据包的开发。为了帮助他,我制作了一个 API,使他能够更轻松地创建性能更优的数据包。
我决定将此项目开源并发布,以便帮助更多人。
以下是该模组提供的一些功能。
此命令允许你执行更复杂且速度更快的数学运算。
以下是一些使用该命令的示例:
/data math <operation> with <input_nbt> (将在聊天栏中显示结果)
/data math <operation> storage <storage_identifier>
/data math <operation> storage <storage_identifier> <nbt_subpath>
此命令允许你为实体设置和获取特定的变量。
以下是一些使用该命令的示例:
/data variable <add|set|get> <variable> (如果是 get 操作,将仅在聊天栏中显示结果)
/data variable <add|set|get> <variable> to <storage_identifier>
/data variable <add|set|get> <variable> to <storage_identifier> <nbt_subpath>
你可以让实体骑乘或离开玩家;被骑行的玩家无法强制实体离开。
使用 /data math 的示例(NBT 结构与 variable 相同)
/data modify storage minecraft:test in set value [43,35] (存储 NBT: {in:[43,35]} )
/data math add storage minecraft:test (存储 NBT: {in:[43,35],out:[78.0d]})
数学运算
对于所有算术运算,输入是一个任意大小的数字数组。如果大小超过 2,它将视为链式运算。例如,如果是一个包含 4 个输入的加法运算,它会将它们全部相加。
如果你想了解这些运算的具体含义,只需搜索它们即可。
| 运算名称 |
输入数量 |
备注 |
| add |
2 |
|
| subtract |
2 |
|
| multiply |
2 |
|
| divide |
2 |
|
| mod (取模) |
2 |
|
| negate |
1 |
|
| factorial |
1 |
|
| power (幂运算) |
2 |
|
| root (开 n 次方) |
2 |
|
| distance |
2 |
输入: [x,y,z], [x,y,z] |
| distance_squared |
2 |
输入: [x,y,z], [x,y,z] |
| rad2deg (弧度→度) |
1 |
|
| deg2rad (度→弧度) |
1 |
|
| sin |
1 |
|
| cos |
1 |
|
| tan |
1 |
|
| arcsin |
1 |
|
| arccos |
1 |
|
| arctan |
1 |
|
| arctan2 |
2 |
|
| ceil (向上取整) |
1 |
|
| round |
1 |
|
| floor (向下取整) |
1 |
|
变量类型
| 变量名 |
描述 |
类型 |
访问器 |
| motion |
实体的运动/速度 |
[double, double, double] |
Get, Set, Add |
| hunger |
实体的饥饿值/饥饿度和饱和度 |
[double (饥饿度), double (饱和度) ] |
Get, Set, Add |
| health |
实体的生命值 |
[double (0 到 20.0) ] |
Get, Set, Add |
| held_slot |
玩家选中的快捷栏槽位 |
[int (0 到 8) ] |
Get, Set, Add |
| fall_distance |
实体下落的高度,未下落时为 0 |
[double] |
Get |
| dimension |
实体所在的维度/世界(含命名空间) |
[string] |
Get |
| position |
实体的 xyz 坐标 |
[double,double,double] |
Get, Set, Add |
| angle |
实体的偏航角和俯仰角 |
[double (偏航角), double (俯仰角) ] |
Get, Set, Add |
About the project
My friend Nedraw is a datapack developer, and we're working together on modding and datapack development. To help him out, I made an api for him, so he can make datapacks easier and with better performance.
I decided to open-source and publish this so I can help other people out.
Here are the features this mod adds.
This command allows you to do more complex and faster math operations.
Here are some examples on how to use the command:
/data math <operation> with <input_nbt> (Will just show the result in chat)
/data math <operation> storage <storage_identifier>
/data math <operation> storage <storage_identifier> <nbt_subpath>
This command allows you to set and get specific variables for an entity.
Here are some examples on how to use the command:
/data variable <add|set|get> <variable> (Will just show the result in chat if get)
/data variable <add|set|get> <variable> to <storage_identifier>
/data variable <add|set|get> <variable> to <storage_identifier> <nbt_subpath>
You can have entities mount and dismount onto players; the player being ridden cannot force the entity to dismount.
Example of using /data math (the NBT schema is the same for variable)
/data modify storage minecraft:test in set value [43,35] (Storage nbt: {in:[43,35]} )
/data math add storage minecraft:test (Storage nbt: {in:[43,35],out:[78.0d]})
Math operations
For all arithmetic operations, the input is an array of numbers of any size. If the size is more than 2, it will treat it as chaining the operations, for example, if it's an add operation with 4 inputs, it will sum it all up.
If you want to know what these operations are, just search for them.
| Operation Name |
Input Size |
Notes |
| add |
2 |
|
| subtract |
2 |
|
| multiply |
2 |
|
| divide |
2 |
|
| mod (modulo) |
2 |
|
| negate |
1 |
|
| factorial |
1 |
|
| power (exponentiation) |
2 |
|
| root (nth root) |
2 |
|
| distance |
2 |
input: [x,y,z], [x,y,z] |
| distance_squared |
2 |
input: [x,y,z], [x,y,z] |
| rad2deg (radians→deg) |
1 |
|
| deg2rad (degrees→rad) |
1 |
|
| sin |
1 |
|
| cos |
1 |
|
| tan |
1 |
|
| arcsin |
1 |
|
| arccos |
1 |
|
| arctan |
1 |
|
| arctan2 |
2 |
|
| ceil (round up) |
1 |
|
| round |
1 |
|
| floor (round down) |
1 |
|
Variable Types
| Variable Name |
Description |
Type |
Accessors |
| motion |
The entity's motion/velocity |
[double, double, double] |
Get, Set, Add |
| hunger |
The entity's foodLevel/Hunger and Saturation |
[double (hunger), double (saturation) ] |
Get, Set, Add |
| health |
The entity's health |
[double (0 to 20.0) ] |
Get, Set, Add |
| held_slot |
The player's selected hotbar slot |
[int (0 to 8) ] |
Get, Set, Add |
| fall_distance |
How far the entity has fallen, 0 if they are not falling |
[double] |
Get |
| dimension |
The entity's dimension/world with namespace |
[string] |
Get |
| position |
The entity's xyz position |
[double,double,double] |
Get, Set, Add |
| angle |
The entity's yaw and pitch angle |
[double (yaw), double (pitch) ] |
Get, Set, Add |
评论 0
登录后参与评分
还没有评论,来抢沙发吧