-
Notifications
You must be signed in to change notification settings - Fork 45
Listing‐Based Manager
Here you will see about modifying/creating the JSON files of the listings used in the mod, such as crafting_tab_listing.json, creative_tab_listing.json or even stonecutting_groups.json
The listings for this mod are generally made to facilitate the addition of resources to interfaces, which clearly do not affect the server-side directly, through resource packs, without the need to modify something as simple as that in code, allowing mods to make their own changes to the Legacy4J interface.
If the listing is in a tab, its icon can be either a GUI sprite or an item, being mandatory if you want to add a tab. And if it's an item, it can have a nbt (or components in versions after 1.20.4), formatted as in the game commands.
--> (*explanation) = JSON Entry Note
- Sprite Icon Examples
"legacy:icon/transport",
"type": "sprite", --> (it's not needed in this case, as this is the default value)
"value": "legacy:icon/transport",
- Item Icon Examples
"type": "item",
"value": {
"item": "white_banner",
"nbt": {BlockEntityTag:{Patterns:[{Pattern: "cr", Color:15}]}}
},
"type": "item",
"value": {
"item": "potion",
"components": {"minecraft:potion_contents":{"potion": "minecraft:night_vision"}}
},
"type": "item",
"value": {
"item": "potion",
"nbt": {"Potion": "minecraft:long_night_vision"}}
}.
Basically, this uses item listing when adding/modifying Legacy Creative Interface tabs, which is its main function. It's defined by the JSON file named "creative_tab_listing.json" in the assets directory of the desired namespace.
As usual, I will use a JSON file as an example, in this case part of legacy:creative_tab_listing.json to make it easier to understand.
- Example
{
{
"id": "legacy:building_blocks" --> (a resource location used as a identifier)
"name": {"translate": "legacy.container.tab.building_blocks"}
"icon": "legacy:icon/structures",
"listing": [
"minecraft:stone", "minecraft:deepslate", "minecraft:basalt", "minecraft:blackstone", "minecraft:grass_block", "minecraft:dirt_path", "minecraft:dirt", "minecraft:cobblestone", "minecraft:cobbled_deepslate", "minecraft:smooth_stone"
] --> (its value is an array of item ids, which can contain an nbt as well as the icon if it is an object that has the id in the "item" key and the nbt in the "nbt" key, you can see this in the rest of the file)
}
}
As you can see, the "name"
value is the text component that the Creative Interface displays when this tab is selected
Before we proceed, it's essential to understand the principle of the posterior listings, which are the recipe info filters.
Basically, they're used to select the recipes, either by an id of a specific recipe, like ´"black_stained_glass_pane_from_glass_pane"`, or by an item or block tag (if directly referencing to its type) that references all recipes that the result matches this tag, if it starts with "#".
- Examples
"legacy:enchanted_golden_apple",
"#minecraft:candles",
"type": "id", --> (it's not needed in this case, as this is the default value)
"value": "legacy:enchanted_golden_apple",
"type": "item_tag", --> (also, it's not needed, as you can simply use a string starting with #)
"value": "minecraft:candles"
"type": "block_tag",
"value": "minecraft:mineable/pickaxe"
"type": "item_id",
"value": "minecraft:suspicious_stew" --> (selects the first recipe found with this item as a result)
"type": "item_id",
"value": {"id": "minecraft:suspicious_stew", "onlyFirstMatch: false} --> (selects all the recipes found with this item as a result)
Basically, this uses recipe info filters listing when adding/modifying Crafting Interface tabs, which is its main function. It's defined by the JSON file named "crafting_tab_listing.json" in the assets directory of the desired namespace.
The Crafting Tabs, unlike Creative's, have groups for each listing, which the name is only used as a identifier, and you can use the defined name to add recipe info filters to specific groups in the default file, without copying it all, through from other namespaces.
As usual, I will use a JSON file as an example, in this case part of legacy:crafting_tab_listing.json to make it easier to understand.
- Example
{
"id": "transport", --> (a resource location, used as a identifier)
"icon": "legacy:icon/transport",
"name": {"translate": legacy.container.tab.transport"},
"listing": [
{"group": "rail", "recipes": ["rail","powered_rail","detector_rail","activator_rail"]},
"minecart","chest_minecart","furnace_minecart","tnt_minecart","hopper_minecart",
{"group": "boat", "recipes": ["oak_boat","birch_boat","spruce_boat","jungle_boat","acacia_boat","dark_oak_boat","mangrove_boat","pale_oak_boar","bamboo_raft","cherry_boat"]},
{"group": "chest_boat", "recipes":
["oak_chest_boat","birch_chest_boat","spruce_chest_boat","jungle_chest_boat","acacia_chest_boat","dark_oak_chest_boat","mangrove_chest_boat","pale_oak_chest_boat","bamboo_chest_raft","cherry_chest_boat"]}
] --> (its value can be either an object or an array with objects, where the group of recipes is defined by the value of the "group" key, and the recipes by "recipes", this can be seen in the rest of the file)
}
As you can see, the key "name"
value is the text component that the Crafting Interface displays when this tab is selected
The only difference between this and the Crafting Tab Listing is that instead of recipe info values, this one uses banner pattern ids.
The most simplistic of all, it's defined by the JSON file namespace:stonecutting_groups.json and only presents groups of recipe info filters, which work as in the Crafting Tab Listing.
It only presents groups as a array. Another difference is that as there are no tabs, recipes will not be repeated between groups to make the view more compact.
You can use the default file legacy:stonecutting_groups.json as an example