NBTRecipes
一个用于添加使用 NBT 数据的配方的极简插件。
描述
本插件旨在简化自定义配方的创建,无需编写任何代码或触碰数据包。
你可以为配方处理的项目附加通用数据(数量、名称、背景故事)以及 NBT 标签。
其格式与数据包中使用的格式非常相似。
用法
你可以将配方放置在插件文件夹内的 recipes 文件夹中。
如果你希望将配方组织在子文件夹中,这也是允许的,插件会在 recipes 文件夹的所有子文件夹中搜索配方。
插件会自动加载子文件夹中的所有配方,并将其相对路径添加到配方命名空间键中。
要创建配方,只需创建一个扩展名为 .json 的文本文件并将其放入 recipes 文件夹中。
使用你喜欢的文本编辑器编辑该文件,并按照以下示例中的格式在其中放置配方。
配置
你可以在配置文件中更改配方的命名空间以及插件的所有消息。
命名空间只能包含以下字符:a-z、0-9、_、-、/。
命令
/nbtrecipes reload - 重新加载配方和配置文件。
/nbtrecipes list - 列出此插件添加的所有配方。
示例
插件组件的示例及更详细的说明。
Item(物品)
这是一个代表配方中物品的对象,它可以用作原料或结果。大多数字段是可选的,事实上,唯一必需的是 material(材质)。
当仅定义 material 字段,且选择项中的其他物品不需要任何元数据(名称、背景故事、NBT)时,配方中的物品将通过材质进行匹配。
有关更多详细信息,请参阅下面的示例。
Discover Trigger(发现触发器)
配方触发器可以通过拾取物品使任何配方对玩家可见(可发现)。
字段 discover 是可选的,如果未指定,配方默认将被发现并可见。
有关更多详细信息,请参阅下面的示例。
Shaped Recipe(形状配方)
形状配方适用于工作台和背包合成。
点击此处展开/折叠 JSON 示例。
{
"type": "crafting_shaped",
// 合成图案。数组必须包含以下元素之一:
// - 两个双字符元素,反映背包合成网格。
// - 三个三字符元素,反映工作台网格。
"pattern": [
" D",
" D ",
"S "
],
// 图案的关键字映射。
"key": {
"S": [
// 可以为一个原料指定多个物品选项。
// 如果物品附加了元数据(名称/背景故事/NBT),所有选项都将作为精确匹配。
{ "material": "stick" },
{ "material": "blaze_rod" }
],
//
"D": { "material": "diamond" }
},
// 配方结果。
"result": {
"material": "diamond_sword",
"amount": 1,
"name": "Diagonally Crafted Diamond Sword",
"lore": [
"As the name suggests..."
],
"nbt": "{CustomModelData: 2}"
},
// 配方发现触发器。可选。
"discover": {
// 在玩家“发现”此配方之前需要拾取的物品。
"items": [
{ "material": "diamond" }
]
}
}
字段 discover 是可选的。
Shapeless Recipe(无形状配方)
无形状配方适用于工作台和背包合成。
点击此处展开/折叠 JSON 示例。
{
"type": "crafting_shapeless",
// 合成原料。
"ingredients": [
// 可以为一个原料指定多个物品选项。
// 如果物品附加了元数据(名称/背景故事/NBT),所有选项都将作为精确匹配。
[
{ "material": "oak_log" },
{ "material": "spruce_log" },
{ "material": "birch_log" },
{ "material": "jungle_log" },
{ "material": "acacia_log" },
{ "material": "dark_oak_log" },
{ "material": "mangrove_log" },
{ "material": "cherry_log" }
],
{ "material": "flint_and_steel" }
],
// 配方结果。
"result": { "material": "charcoal" },
// 配方发现触发器。可选。
"discover": {
// 在玩家“发现”此配方之前需要拾取的物品。
"items": [
{ "material": "oak_log" },
{ "material": "spruce_log" },
{ "material": "birch_log" },
{ "material": "jungle_log" },
{ "material": "acacia_log" },
{ "material": "dark_oak_log" },
{ "material": "mangrove_log" },
{ "material": "cherry_log" }
]
}
}
字段 discover 是可选的。
Smelting Recipes(熔炼配方)
熔炼配方可以应用于普通熔炉、高炉、烟熏炉或营火。
点击此处展开/折叠 JSON 示例。
{
// 配方类型。对于熔炉类配方,可以使用以下之一:[SMELTING, BLASTING, SMOKING, CAMPFIRE_COOKING]
"type": "smelting",
// 熔炉输入。
"input": [
// 可以为一个原料指定多个物品选项。
// 如果物品附带了元数据(名称/描述/NBT),所有选项都将被精确匹配。
{ "material": "diamond_helmet" },
{ "material": "diamond_chestplate" },
{ "material": "diamond_leggings" },
{ "material": "diamond_boots" }
],
// 配方结果。
"result": { "material": "diamond" },
// 玩家获取熔炼结果后获得的经验值。可选。
"experience": 0.7,
// 烹饪此配方所需的时间。以刻为单位。可选。
"cooking_time": 200,
// 配方发现触发条件。可选。
"discover": {
// 在玩家“发现”此配方之前需要拾取的物品。
"items": [
{ "material": "diamond_helmet" },
{ "material": "diamond_chestplate" },
{ "material": "diamond_leggings" },
{ "material": "diamond_boots" }
]
}
}
所有熔炉类配方类型遵循相同的结构。
smelting - 普通熔炉的配方。
blasting - 高炉的配方。
smoking - 烟熏炉的配方。
campfire_cooking - 营火的配方。
字段 experience、cooking_time 和 discover 是可选的。
锻造台配方 (Smithing Recipe)
锻造台配方适用于锻造台。
点击此处展开/折叠 JSON 示例。
{
"type": "smithing",
// 基础物品,你可以将其视为可以应用升级的物品。可以指定多个物品选项。
"base": { "material": "iron_pickaxe" },
// 模板物品,你可以将其视为应用于基础物品的升级。可以指定多个物品选项。
// 此字段仅在运行 1.20 或更高版本时有效。
"template": { "material": "air" },
// 附加物品。对于原版配方,通常是装饰图案材料。可以指定多个物品选项。
"addition": { "material": "diamond" },
// 配方结果。不支持元数据,因为它直接从基础物品复制。
"result": { "material": "diamond_pickaxe" },
// 配方发现触发条件。可选。
"discover": {
// 在玩家“发现”此配方之前需要拾取的物品。
"items": [
{ "material": "iron_pickaxe" }
]
}
}
结果物品的元数据(名称、描述、NBT)不受支持,因为它们直接从基础物品复制。
字段 discover 是可选的。
贡献
要为此仓库做出贡献,只需 Fork 该仓库,进行修改或添加代码,然后提交 Pull Request。
如果你发现错误或 Bug,可以在 这里 提交 Issue。
许可证
NBTRecipes 根据“BSD 3-Clause License”发布。你可以在 这里 找到副本。
NBTRecipes
A very simple plugin to add recipes that use NBT data.
Description
Plugin designed to simplify creation of custom recipes, without the need writing any code or touching datapacks.
You can attach common data (amount, name, lore) as well as NBT tags to items processed by the recipes.
Format is very similar to the one used by datapacks.
Usage
You can place your recipes inside the recipes folder in the plugin folder.
If you want to organize your recipes in subfolders you can do it, the plugin will search for recipes in every subfolder of the recipes folder.
The plugin will automatically load all the recipes in the subfolders and add their relative path to the recipe namespaced key.
To create a recipe just create a text file with the .json extension and put it in the recipes folder.
Edit the file with your favorite text editor and put the recipe in it as shown in the examples below.
Config
In the config you can change the namespace of your recipes and all the messages of the plugin.
The namespace can only contain the following characters: a-z, 0-9, _, -, /.
Commands
/nbtrecipes reload - Reloads the recipes and the config file.
nbtr.command Permission needed to use the command.
/nbtrecipes list - Lists all the recipes added by this plugin.
nbtr.command Permission needed to use the command.
Examples
Examples and more detailed description of plugin components.
Item
This is an object that represents an item in the recipes, it can be used as an ingredient or as a result. Majority of fields are optional, in fact, the only one needed is the material.
When only material field is defined, and no other items within the choice requires any metadata (name, lore, nbt), items in the recipe are matched by material.
See below examples for more details.
Discover Trigger
Recipe trigger can make any recipe to be discoverable by players, by picking up an item.
Field discover is optional and if not specified, recipe will be discovered and visible by default.
See below examples for more details.
Shaped Recipe
Shaped recipe applies to crafting table and inventory crafting.
Click here to expand/collapse JSON example.
{
"type": "crafting_shaped",
// Crafting pattern. Array must consist of either:
// - two, two-character elements reflecting an inventory crafting grid.
// - three, three-character elements reflecting a crafting table grid.
"pattern": [
" D",
" D ",
"S "
],
// Key to the pattern.
"key": {
"S": [
// Multiple item choices can be specified for one ingredient.
// In case metadata (name/lore/nbt) is attached to an item, all choices are matched as EXACT.
{ "material": "stick" },
{ "material": "blaze_rod" }
],
//
"D": { "material": "diamond" }
},
// Recipe result.
"result": {
"material": "diamond_sword",
"amount": 1,
"name": "Diagonally Crafted Diamond Sword",
"lore": [
"As the name suggests..."
],
"nbt": "{CustomModelData: 2}"
},
// Recipe discover trigger. Optional.
"discover": {
// Items to be picked-up before this recipe is "discovered" by the player.
"items": [
{ "material": "diamond" }
]
}
}
Field discover is optional.
Shapeless Recipe
Shapeless recipe applies to crafting table and inventory crafting.
Click here to expand/collapse JSON example.
{
"type": "crafting_shapeless",
// Crafting ingredients.
"ingredients": [
// Multiple item choices can be specified for one ingredient.
// In case metadata (name/lore/nbt) is attached to an item, all choices are matched as EXACT.
[
{ "material": "oak_log" },
{ "material": "spruce_log" },
{ "material": "birch_log" },
{ "material": "jungle_log" },
{ "material": "acacia_log" },
{ "material": "dark_oak_log" },
{ "material": "mangrove_log" },
{ "material": "cherry_log" }
],
{ "material": "flint_and_steel" }
],
// Recipe result.
"result": { "material": "charcoal" },
// Recipe discover trigger. Optional.
"discover": {
// Items to be picked-up before this recipe is "discovered" by the player.
"items": [
{ "material": "oak_log" },
{ "material": "spruce_log" },
{ "material": "birch_log" },
{ "material": "jungle_log" },
{ "material": "acacia_log" },
{ "material": "dark_oak_log" },
{ "material": "mangrove_log" },
{ "material": "cherry_log" }
]
}
}
Field discover is optional.
Smelting Recipes
Smelting recipes can be applied to regular furnace, blast furnace, smoker or campfire.
Click here to expand/collapse JSON example.
{
// Recipe type. For furnace recipes you can use one of: [SMELTING, BLASTING, SMOKING, CAMPFIRE_COOKING]
"type": "smelting",
// Furnace input.
"input": [
// Multiple item choices can be specified for one ingredient.
// In case metadata (name/lore/nbt) is attached to an item, all choices are matched as EXACT.
{ "material": "diamond_helmet" },
{ "material": "diamond_chestplate" },
{ "material": "diamond_leggings" },
{ "material": "diamond_boots" }
],
// Recipe result.
"result": { "material": "diamond" },
// Experience to award player after taking smelting result. Optional.
"experience": 0.7,
// Time it takes to cook this recipe. Measured in ticks. Optional.
"cooking_time": 200,
// Recipe discover trigger. Optional.
"discover": {
// Items to be picked-up before this recipe is "discovered" by the player.
"items": [
{ "material": "diamond_helmet" },
{ "material": "diamond_chestplate" },
{ "material": "diamond_leggings" },
{ "material": "diamond_boots" }
]
}
}
All furnace recipe types follow the same schema.
smelting - recipe for regular furnace.
blasting - recipe for blast furnace.
smoking - recipe for smoker.
campfire_cooking - recipe for campfire.
Fields experience, cooking_time and discover are optional.
Smithing Recipe
Smithing recipe applies to smithing table.
Click here to expand/collapse JSON example.
{
"type": "smithing",
// Base item, you can think of it as an item which upgrades (could) be applied to. More than one item choice can be specified.
"base": { "material": "iron_pickaxe" },
// Template item, you can think of it as an upgrade which is applied to the base item. More than one item choice can be specified.
// This field works only when running 1.20 or higher.
"template": { "material": "air" },
// Addition item. For vanilla recipes, it's usually a trim material. More than one item choice can be specified.
"addition": { "material": "diamond" },
// Recipe result. Metadata is not supported as it's copied directly from the base item.
"result": { "material": "diamond_pickaxe" },
// Recipe discover trigger. Optional.
"discover": {
// Items to be picked-up before this recipe is "discovered" by the player.
"items": [
{ "material": "iron_pickaxe" }
]
}
}
Metadata (name, lore, nbt) is not supported for result items, as it's copied directly from the base item.
Field discover is optional.
Contributing
To contribute to this repository just fork this repository make your changes or add your code and make a pull request.
If you find an error or a bug you can open an issue here.
License
NBTRecipes is released under "The 3-Clause BSD License". You can find a copy here.es/blob/master/LICENSE).
评论 0
登录后参与评分
还没有评论,来抢沙发吧