Tags
Minecraft uses tags to group items, blocks, fluids, and entity types together for various game mechanics. Tags are essentially collections of game elements that share common characteristics or purposes. They're used extensively throughout the game for:
- Recipes (using item tags)
- Game mechanics (climbable blocks, mineable requirements)
- Mod compatibility
- World generation
- and more!
You can easily view an item/block's tags by holding it and using /kubejs hand. If advanced tooltips are enabled, it will also show an item's tags when hovered over. A list of minecraft's tags can be viewed here.
Adding Tags
Note
You do not have to manually define the tags themselves anywhere, using any of the following functions below will also register the tag.
Tagging in Server Events
Item tags
These tags are primarily used in recipes, and can also be used to influence how a item behaves when it is dropped, equipped, or used.
ServerEvents.tags('item', event => {
event.add('forge:cobblestone', 'minecraft:diamond_ore') //(1)
event.remove('forge:cobblestone', 'minecraft:mossy_cobblestone') //(2)
event.removeAllTagsFrom('minecraft:stick') //(3)
event.removeAll('forge:ingots/copper') //(4)
event.add('mymodpack:completely_new_tag', 'minecraft:clay_ball') //(5)
event.add('mymodpack:stones', '#forge:stone') //(6)
event.add('minecraft:stone_pressure_plates', [
'minecraft:stone_pressure_plate',
'minecraft:polished_blackstone_pressure_plate'
]) //(7)
event.add('mymodpack:stone_redstone_activators', [
'#minecraft:stone_buttons',
'#minecraft:stone_pressure_plates',
'minecraft:lever'
]) //(8)
})
- Add to Tag: Adds
minecraft:diamond_oreto the#forge:cobblestonetag. - Remove from Tag: Removes
minecraft:mossy_cobblestonefrom the#forge:cobblestonetag. - Remove All Tags: Clears all tags associated with
minecraft:stick. - Remove All Entries: Clears all items from the
#forge:ingots/coppertag. - Create New Tag: Creates a new tag
#mymodpack:completely_new_tagand addsminecraft:clay_ballto it. New tags can use any namespace. - Tag Nesting: Adds the
forge:stonetag as a child of the#mymodpack:stonestag. - Array of Entries: Adds
minecraft:stone_pressure_plateandminecraft:polished_blackstone_pressure_plateto the new tag#minecraft:stone_pressure_plates. - Array of Entries and Tags: Adds the
#minecraft:stone_buttonsand#minecraft:stone_pressure_platestags as children and addsminecraft:leverto the#mymodpack:stone_redstone_activatorstag.
Block tags
Block tags influnce what a behaviors a block has, as well as seeing use in world generation.
ServerEvents.tags('block', event => {
event.add('minecraft:climbable', 'minecraft:tall_grass') //(1)
event.add('minecraft:moss_replaceable', 'minecraft:bedrock') //(2)
event.add('minecraft:jungle_logs', '#mushroom_grow_block') //(3)
})
- Adds tall grass to the climbable tag. This does make it climbable!
- Adds bedrock to the
minecraft:moss_replaceabletag, making it replacable with moss blocks when a nearby moss block has bone meal applied to it. - Adds the
jungle_logsblock tag as a child of thec:stonestag.
Tagging During Startup
You can also add tags when said items/blocks are being registered.
StartupEvents.registry('block', event => {
event.create('example_block')
.tagBlock('minecraft:mineable/pickaxe')
.tagBlock('minecraft:needs_iron_tool')
.tagBlock('my_namespace:my_custom_tag')
})
StartupEvents.registry('item', event => {
event.create('custom_item')
.tagItem('forge:ingots')
.tagItem('my_namespace:special_items')
})
Using tags in recipes
Warning
Recipes use item tags, not block or fluid tags. Even if items representing those are blocks, like minecraft:cobblestone, it still uses an item tag for recipes.
Tags can be used in most places where items are supported, with the hash sign. Tags can't be used as a recipe output.