跳到正文

DataPackPlus

作者:JZalaOz

Adds faster math commands, accessing entity variables, and other useful features for datapack developers.

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。


Logo

DataPackPlus (DP+)

A helpful Minecraft Fabric mod to improve the lives of data pack developers!

Report Bug

·

Request Feature

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.

  • /data math

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>
  • /data variable

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>
  • Ridable players

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 |

常见问题

DataPackPlus 支持哪些 Minecraft 版本?

DataPackPlus 支持 Minecraft Java 版 1.21.7,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

DataPackPlus 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:仅服务端。

评论

登录后评论和评分