-
Notifications
You must be signed in to change notification settings - Fork 8
Creative Tab Modifiers
This feature allows you to edit the content of a creative tab. This inclues:
- Adding new items (at a certain position)
- Removing existing items
- Changing icon
- Adding search bar
- Change background texture
- Adding a new tab (WIP)
- Hiding a tab entirely (WIP)
An Item Stack is a game object that contains an item + its count + its NBT / Components. Tab modifiers can add these to creative tabs. This concept is explained on the Official Minecraft wiki and is used in many places such as in Loot Tables or Recipes.
To start you'll need to create a .json file in your resource pack folder in assets/[tab namespace]/polytone/creative_tab_modifiers/[tab name].json
.
For example if you want to modify minecraft:combat
you can do so with a file located in assets/minecraft/polytone/biome_effects/combat.json
Alternatively, if you want to manually specify your targets you can place this json in assets/[your pack namespace]/polytone/creative_tab_modifiers/[some name].json
(Any path will work but this is recommended to avoid overwriting Implicit defined targets).
Then you can add the targets
field to the json containing a list of valid Dimension ids as follows:
{
"targets": ["minecraft:combat", "minecraft:building_blocks"]
}
Here are all the parameters that you can include in your modifier. All fields are optional
field | explanation |
---|---|
icon |
An ItemStack. Will modify the tab icon |
can_scroll |
If tab can scroll or not |
show_title |
If tab has a title or not |
name |
A Component. Tab name |
removals |
A list of Item Predicates (see below) that will determine which items to remove |
additions |
A list of Item Additions (see below) that will determing which items to add |
targets |
A list of IDS to use for explicit targeting |
search_bar |
Boolean, Forge Only. If tab has a search bar |
search_bar_width |
Forge Only. Search bar width |
background |
Forge Only. Background texture location |
tabs_image |
Forge Only. Tabs background texture location |
before_tabs |
Forge Only. A List of creative tab IDS that should come before this tab is added |
after_tabs |
Forge Only. A List of creative tab IDS that should come after this tab position |
Here's an example of how a basic modifier could look
{
"removals": [
{
"type": "tag_match",
"tag": "swords"
}
],
"additions": [
{
"items": "minecraft:diamond",
{
"id":"minecraft:diamond_hoe",
"components":{
"minecraft:custom_name":"\"bro\""
}
}
}
],
"after_tabs": [
"minecraft:combat"
]
}
The removals
block contains a list of Item Predicate objects.
Each predicate is essentially a Tester that returns True or False when queried with an item. These are used to determine WHICH item to target (in this case remove)
Each Item Predicate has the following syntax:
field | explanation |
---|---|
type |
The type of the predicate |
[value] |
The value(s) of the predicate. Each predicate type has its own and are listed below |
Here's a list of all the types you can use:
predicate name | value(s) | explanation |
---|---|---|
or |
predicates . A list of Item Predicates objects |
Returns true if just one of its predicates is true |
and |
predicates . A list of Item Predicates objects |
Returns true if any predicate is true |
not |
predicate . A single predicate object |
Returns true if that predicate is false |
tag_match |
tag . An item tag |
Returns true if an item belongs to that tag |
items_match |
items . A list of Items |
Returns true if an item is contained in that list |
itemstack_match |
itemstack . An ItemStack (using vanilla syntax) |
Returns true if an item matches the entire itemstack, this include its nbt |
id_match |
namespace , path . Two Regular Expression strings. Only one is required |
Returns true if the item ID's namespace and path both match those regular expressions |
true |
None | Matches all items |
Here's an example defining a predicate that targets all items that do NOT contain "block" in their name:
{
"type": "not",
"predicate": {
"type": "id_match",
"path": "block"
}
}
The additions
block contains a list of Item Addition objects.
The purpose of each of these is to determine WHICH items to add and WHERE to add it to.
An Item Addition object has the following syntax:
field | explanation |
---|---|
items |
A list or single of either an Item or an Itemstack to be added to the Tab. |
before |
Optional, Boolean. Wether to add these items before or after the items targeted by predicate
|
predicate |
Optional. An Item Predicate (explained above). Determines before or after which item these items will be added |
inverse |
When true will add all registered items except what's inside the items field |
As you can see the Item Predicate object from before was reused here. Check it out above.
If predicate
is left out, the items will be added at the end of the tab.
Here's an example of some items added after the Iron Axe item
{
"items": [
"iron_shovel",
"iron_sword"
],
"before": false,
"predicate": {
"type": "items_match",
"items": [
"minecraft:iron_axe"
]
}
}
The icon
field takes a single itemstack.
Polytone lets you register custom Creative Tabs via Resource Pack.
NOTE: This section will only explain how to register them. To actually configure them properly you'll HAVE to also add a Creative Tab Modifier that actually adds items to them, otherwise they won't show up.
It's recommended to also add a name
field to their modifier to give them a proper display name.
This feature is EXPERIMENTAL and will remain so until its proven that it does not have side effects.
While I was not able to have any issues with it, the way this on the fly registration works is quite sketchy as they game doesnt usually do that. While its unlikely that these issues could be manifested its still worth using this feature with care. One known side effect is the fact that tabs WON'T uen Un-Registered once you disable a pack that adds them and WILL require game reboot.
Moreover if you have access to mods like KubeJs it is recommended to register your Creative Tabs there instead
To add new creative tabs simply add a list of comma separated creative tab names in assets/[your pack name]/polytone/creative_tabs.csv
Here's an example:
bows,
scary_items,
greg_stuff
This will register those 3 creative tabs under YOUR PACK namespace. This means that to reference them you'll need to call them with their fully classified id [your pack name]:[your creative tab name]
.
Say for example that your pack is called _my_pack_
, then the creative tab ID will be something like my_pack:scary_items
.