
简介
Robot's Datapack Tools 是一个可以集成到你自己项目中的库。它添加了多种工具,使数据包的创建更加轻松,例如仅使用一条命令即可添加方块。这几乎完全通过 宏 实现,并且通过使用尽可能少的计时函数,使数据包非常高效。
自定义功能
方块
自定义方块以 标记实体 作为主实体,并使用六个 物品显示实体 来渲染方块,确保每个侧面都有正确的光照。这些物品显示实体不会进行计时(ticking),因此这对性能非常友好。如果你想对自定义方块运行函数,请使用标签 rdt.block.<id>.marker 来访问该方块的主标记实体。
如果你不理解如何添加自定义方块,请查看底部的示例或加入 Discord 服务器。
命令
function block:add {...}
此命令用于注册新方块。请在你的数据包 load 函数中运行此函数。需要以下标签:
| 标签 |
类型 |
描述 |
id |
字符串 |
方块的唯一 ID。(允许的字符包括:-, +, ., _, A-Z, a-z, 以及 0-9) |
block |
字符串 |
任意 Minecraft 方块。确保该方块破碎时会掉落自身。此方块将定义硬度、粒子效果和破碎声音。 |
model |
字符串 |
物品模型,来自 assets/<namespace>/items 文件夹 |
type |
字符串 |
放置时方块的朝向方式: 1. default:无特定朝向 2. facing:面向玩家 3. facing_horizontal:面向玩家,但不朝上或朝下 4. column:根据放置的方块侧面决定朝向 |
loot_table |
字符串 |
战利品表,当方块被破坏时掉落 |
config |
复合类型 |
配置标签列表。如果不需要配置,请留空 |
function block:add {config:{...}}
在 config 复合类型中,你可以指定以下设置。这些设置不是必须的。
| 标签 |
描述 |
子标签 |
类型 |
描述 |
interactable |
召唤一个 交互实体 |
1. attack 2. interact 3. break_on_attack 4. response |
1.字符串 2.字符串 3.空 4.空 |
1. 左键点击时运行的函数 2. 右键点击时运行的函数 3. 如果希望方块在左键点击时破碎,请添加此标签 4. 交互实体将具有 response:1b 标签 |
function |
要运行的函数 |
1. place 2. break 3. tick |
1.字符串 2.字符串 3.字符串 |
1. 放置时运行的函数 2. 破碎时运行的函数 3. 每次计时循环运行的函数 |
place_sound |
放置方块时播放的声音。如果不包含此标签,则播放 block.stone.place |
1. sound 2. pitch |
1.字符串 2.浮点数 |
1. 要播放的声音 ID 2. 音调,范围从 0.0 到 2.0 |
item |
如果在 loot_table 标签中指定的战利品表 没有 自动掉落自定义物品,请创建一个额外的战利品表来掉落自定义物品,并将其放在此处。 |
- |
字符串 |
- |
function block:list
列出所有已添加的自定义方块。
function block:remove {id:...}
用于移除自定义方块。id 应设置为添加方块时使用的唯一 ID。此命令不会从你的世界中移除自定义方块,这需要手动完成!
function block:edit/... {...}
使用此函数可以更改 已放置方块 的特定功能。这 不会 编辑该类型的所有现有自定义方块。确保在运行此函数时,它是在 主实体 上运行的。命令可以是以下之一:
function block:edit/... |
描述 |
标签 |
类型 |
描述 |
model |
更改此特定方块的模型 |
model |
字符串 |
物品模型,来自 assets/<namespace>/items 文件夹 |
attack |
更改左键点击方块时运行的攻击函数 |
function |
字符串 |
要运行的函数 |
interact |
更改右键点击方块时运行的交互函数 |
function |
字符串 |
要运行的函数 |
自定义物品
为了能够放置这些自定义方块,你需要一个自定义物品。自定义物品必须满足以下条件:
- 物品必须是
item_frame 或 glow_item_frame,
- 物品必须具有包含
{id:"minecraft:item_frame",Tags:["rdt.block","id"]} 的 entity_data 组件,其中 "id" 是你想要放置的自定义方块的唯一 ID
- 建议物品还具有包含
{Silent:1b,Fixed:1b,Invisible:1b,Invulnerable:1b} 的 entity_data 组件
entity_data 中不允许有其他数据。物品 可以 包含其他组件,例如 item_name 或 item_model。
示例
在此示例中,我们将添加一个外观类似橡木木板但可以旋转的自定义方块。在这种情况下,我们有一个名为 custom 的额外数据包,其中包含一个自定义战利品表和加载函数。
在加载函数中,我们添加以下命令来注册该方块:
function block:add {id:"rotate_oak_planks",block:"oak_planks",model:"minecraft:oak_planks",type:"facing_horizontal",loot_table:"custom:blocks/rotate_oak_planks",config:{place_sound:{sound:"minecraft:block.wood.place",pitch:0.8f}}}
然后,我们可以使用以下命令给自己物品以放置该自定义方块:
give @p glow_item_frame[entity_data={id:"minecraft:glow_item_frame",Fixed:1b,Invisible:1b,Silent:1b,Invulnerable:1b,Tags:["rdt.block","rotate_oak_planks"]},item_model="oak_planks",item_name="Rotatable Oak Planks"]
如果我们想将最近的自定义方块模型更改为深色橡木木板,可以使用以下命令:
execute as @n[tag=rdt.block.rotate_oak_planks.marker] run function block:edit/model {model:"dark_oak_planks"}
作物
自定义作物使用 物品展示框 作为主要实体和 交互实体。如果你想对自定义作物运行函数,请使用标签 rdt.crop.<id>.display 来访问该方块的主要物品展示框。
如果你不理解如何添加自定义方块,请查看底部的示例或加入 Discord 服务器。
自定义作物在其非激活状态下使用绊线作为基础方块。此功能本身已在 Minecraft 中不再使用,因此移除其纹理应该没有问题。
命令
function crop:add {...}
此命令用于注册新作物。在你的数据包的 load 函数中运行此函数。需要以下标签:
| 标签 |
类型 |
描述 |
id |
字符串 |
作物的唯一 ID。(允许的字符包括:-, +, ., _, A-Z, a-z, 以及 0-9) |
stages |
整数 |
作物应有的阶段数量 |
model |
字符串数组 |
物品模型,来自 assets/<namespace>/items 文件夹。每个阶段需要一个模型。 |
hitbox |
浮点数数组 |
每阶段交互实体的高度。最小高度为 0.22f |
loot_table |
包含两个字符串的数组 |
两个 战利品表,当作物被破坏时掉落。第一个战利品表在作物未完全成熟时掉落,第二个战利品表在作物完全成熟时掉落。 |
function crop:list
列出所有已添加的自定义作物。
function crop:remove {id:...}
用于移除自定义作物。id 应设置为添加作物时使用的唯一 ID。此命令不会从你的世界中移除自定义作物,必须手动完成!
自定义物品
为了能够放置这些自定义作物,你需要一个自定义物品。自定义物品必须满足以下条件:
- 物品必须具有
custom_data 组件,其中包含 {rdt:"crop",id:"id"},且 "id" 为你想要放置的自定义作物的唯一 ID
- 物品默认可消耗,或具有
consumable 组件。如果你不想让物品可食用,请在 consumable 组件中添加设置 {consume_seconds:999999}。
- 物品可以包含其他组件,如
item_name 或 item_model,并且你可以在 custom_data 组件中添加更多数据
示例
在此示例中,我们将添加一个具有 4 个阶段的自定义作物,从红色地毯生长到红色混凝土。在这种情况下,我们有一个名为 custom 的额外数据包,其中包含两个自定义战利品表和一个加载函数。
在加载函数中,我们添加以下命令来注册该作物:
function crop:add {id:"red_crop",stages:4,model:["minecraft:red_carpet","minecraft:crimson_trapdoor","minecraft:crimson_slab","minecraft:red_concrete"],hitbox:[0.2d,0.2d,0.5d,1.0d],loot_table:["custom:blocks/red_crop_not_grown","custom:blocks/red_crop_grown"]}
然后,我们可以使用以下命令给自己物品以放置该自定义作物:
give @p red_dye[minecraft:custom_data={rdt:"crop",id:"red_crop"},minecraft:consumable={consume_seconds:999999},item_name="Red Crop Seeds"]
使用方法
要整合此数据包,请下载最新版本,解压并将所有 命名空间 复制到你的数据包中。确保在 load.json 文件中提及函数 rdt:load,并在 tick.json 文件中提及函数 rdt:tick。建议在这些函数之前提及你自己的加载和 tick 函数。如果需要更多帮助,请加入 Discord 服务器 或观看此视频:如何将 Robot's Datapack Tools 整合到你的项目中
在从此数据包运行函数时,不建议在 rdt 命名空间下运行函数。
如果你有建议或想报告错误,请在 Discord 服务器 的 ?︱ideas 和 ?bugs 频道中分别创建带有标签 Robot's Datapack Tools 的帖子。
许可证
Robot's Datapack Tools © 2025 by GoldenRobot II 采用 CC BY 4.0 许可。你可以自由分享和改编材料,但需要提供 适当的署名。

About
Robot's Datapack Tools is a library that can be intergrated into your own project. It adds multiple tools that make datapack creation easier, such as adding blocks with only one command. This is almost entirely done using macros, and the datapack is made very efficient by using as little ticking functions as possible.
Custom Features
Blocks
The custom blocks use a marker as main entity and six item displays to render the block with correct lighting on each side. These item display don't tick, and therefore this is still very lag friendly. If you want to run functions on a custom block, use the tag rdt.block.<id>.marker to access the main marker of the block.
If you don't understand how to add custom blocks, check out the example at the bottom or join the discord server.
Commands
function block:add {...}
This command is used to register new blocks. Run this function within the load function of your datapack. The following tags are required:
| tag |
type |
description |
id |
string |
unique id of the block. (Allowed characters include: -, +, ., _, A-Z, a-z, and 0-9) |
block |
string |
Any minecraft block. Make sure this block drops itself when broken. This block will define hardness, particles and breaking sound. |
model |
string |
item model from the assets/<namespace>/items folder |
type |
string |
how to orientate the block when placed: 1. default: no orientation 2. facing: face towards player 3. facing_horizontal: face towards player, but not up or down 4. column: face depending on the side of the block it's placed on |
loot_table |
string |
loot table that drops when the block is broken |
config |
compound |
list of config tags. Leave empty if no config is needed |
function block:add {config:{...}}
Within the config compound you can specify the following settings. They are not required.
| tag |
description |
sub-tags |
type |
description |
interactable |
summons an interaction entity |
1. attack 2. interact 3. break_on_attack 4. response |
1.string 2.string 3.empty 4.empty |
1. function to run when left-clicked 2. function to run when right-clicked 3. add this tag if the block should break when left-clicked 4. the interaction will have the response:1b tag |
function |
functions to run |
1. place 2. break 3. tick |
1.string 2.string 3.string |
1. function that runs when placed 2. function that runs when broken 3. function that runs every tick |
place_sound |
sound to play when the block is placed. If this tag is not included, it will play block.stone.place |
1. sound 2. pitch |
1.string 2.float |
1. sound id to play 2. pitch, ranging from 0.0 to 2.0 |
item |
If the loot table specified in the loot_table tag doesn't drop the custom item by itself, create an additional loot table that drops the custom item and put it here. |
- |
string |
- |
function block:list
Lists all the custom blocks that have been added.
function block:remove {id:...}
Used to remove a custom block. id should be set to the unique id used when adding the block. This command will not remove the custom blocks from your world, that has to be done manually!
function block:edit/... {...}
Using this function you can change specific features of a placed block. This doesn't edit all existing custom blocks of that type. Make sure when running this function it runs on the main entity. The command can be one of the following:
function block:edit/... |
description |
tags |
type |
description |
model |
changes the model of this specific block |
model |
string |
item model from the assets/<namespace>/items folder |
attack |
changes the attack function that runs when left-clicking the block |
function |
string |
the function to run |
interact |
changes the interact function that runs when right-clicking the block |
function |
string |
the function to run |
Custom Item
To be able to place these custom blocks, you will need a custom item. The custom item has to meet the following criteria:
- The item must be an
item_frame or a glow_item_frame,
- The item must have an
entity_data component containing {id:"minecraft:item_frame",Tags:["rdt.block","id"]} with "id" being the unique id of the custom block you want to place
- It is recommended that the item also has the
entity_data component containing {Silent:1b,Fixed:1b,Invisible:1b,Invulnerable:1b}
- Any other data in
entity_data is not allowed. The item can contain other components, such as item_name or item_model.
Example
In this example we will add a custom block that looks like oak planks but can be rotated. In this case we have an extra data pack named custom, containing a custom loot table and a load function.
In the load function, we add the following command to register the block:
function block:add {id:"rotate_oak_planks",block:"oak_planks",model:"minecraft:oak_planks",type:"facing_horizontal",loot_table:"custom:blocks/rotate_oak_planks",config:{place_sound:{sound:"minecraft:block.wood.place",pitch:0.8f}}}
Then, we can give ourselfs the item to place the custom block using the following command:
give @p glow_item_frame[entity_data={id:"minecraft:glow_item_frame",Fixed:1b,Invisible:1b,Silent:1b,Invulnerable:1b,Tags:["rdt.block","rotate_oak_planks"]},item_model="oak_planks",item_name="Rotatable Oak Planks"]
If we would want to change the model of the closest custom block to dark oak planks we can use the following command:
execute as @n[tag=rdt.block.rotate_oak_planks.marker] run function block:edit/model {model:"dark_oak_planks"}
Crops
The custom crops use an item display as main entity and an interaction. If you want to run functions on a custom crop, use the tag rdt.crop.<id>.display to access the main item display of the block.
If you don't understand how to add custom blocks, check out the example at the bottom or join the discord server.
Custom crops use a tripwire in its deactivated state as a base block. This feature itself is no longer used in Minecraft, so removing its texture shouldn't be a problem.
Commands
function crop:add {...}
This command is used to register new crops. Run this function within the load function of your datapack. The following tags are required:
| tag |
type |
description |
id |
string |
unique id of the crop. (Allowed characters include: -, +, ., _, A-Z, a-z, and 0-9) |
stages |
int |
amount of stages the crop should have |
model |
array of strings |
item model from the assets/<namespace>/items folder. One model per stage is required. |
hitbox |
array of floats |
height of the interaction entity per stage. Minimum height of 0.22f |
loot_table |
array with 2 strings |
Two loot tables that drop when the crop is broken. The first loot table drops if the crop is not fully grown, the second loot table drops if the crop is fully grown. |
function crop:list
Lists all the custom crop that have been added.
function crop:remove {id:...}
Used to remove a custom crop. id should be set to the unique id used when adding the crop. This command will not remove the custom crops from your world, that has to be done manually!
Custom Item
To be able to place these custom crops, you will need a custom item. The custom item has to meet the following criteria:
- The item must have a
custom_data component containing {rdt:"crop",id:"id"} with "id" being the unique id of the custom crop you want to place
- The item must be consumable by default, or have the
consumable component. If you don't want the item to be edible, add the setting {consume_seconds:999999} in the consumable component.
- The item can contain other components, such as
item_name or item_model, and you can add more data in the custom_data component
Example
In this example we will add a custom crop with 4 stages, growing from a red carpet to red concrete. In this case we have an extra data pack named custom, containing two custom loot tables and a load function.
In the load function, we add the following command to register the block:
function crop:add {id:"red_crop",stages:4,model:["minecraft:red_carpet","minecraft:crimson_trapdoor","minecraft:crimson_slab","minecraft:red_concrete"],hitbox:[0.2d,0.2d,0.5d,1.0d],loot_table:["custom:blocks/red_crop_not_grown","custom:blocks/red_crop_grown"]}
Then, we can give ourselfs the item to place the custom crop using the following command:
give @p red_dye[minecraft:custom_data={rdt:"crop",id:"red_crop"},minecraft:consumable={consume_seconds:999999},item_name="Red Crop Seeds"]
Usage
To intergrate this datapack, download the latest version, unzip it and copy all the namespaces over into your own datapack. Make sure to mention the function rdt:load in the load.json file, and mention the function rdt:tick in the tick.json file. It is recommended to mention these functions before your own load and tick functions. If you need more help, join the discord server or watch this video: How to intergrate Robot's Datapack Tools
When running functions from this datapack it is not recommended to run functions under the rdt namespace.
If you have suggestions or want to report bugs, create a post with the tag Robot's Datapack Tools in the discord server, in the channels ?︱ideas and ?bugs respectively.
License
Robot's Datapack Tools © 2025 by GoldenRobot II is licensed under CC BY 4.0. You are free to share and adapt the material, but you are required to provide appropriate credit.
评论 0
登录后参与评分
还没有评论,来抢沙发吧