# TagEventJS This event is fired when a tag collection is loaded, to modify it with script. You can add and remove tags for items, blocks, fluids and entity types. This goes into server scripts.
Tags are per item/block/fluid/entity type and as such cannot be added based on things like NBT data!
##### Parent class [EventJS](https://mods.latvian.dev/books/kubejs-legacy/page/eventjs) ##### Can be cancelled No #### Variables and FunctionsName | Type | Info |
type | [String](https://mods.latvian.dev/books/kubejs-legacy/page/string) | Tag collection type. |
get([String](https://mods.latvian.dev/books/kubejs-legacy/page/string) tag) | TagWrapper | Returns specific tag container which you can use to add or remove objects to. tag parameter can be something like 'forge:ingots/copper'. If tag doesn't exist, it will create a new one. |
add([String](https://mods.latvian.dev/books/kubejs-legacy/page/string) tag, [String](https://mods.latvian.dev/books/kubejs-legacy/page/string)\[\]/Regex ids) | TagWrapper | Shortcut method for event.get(tag).add(ids). |
remove([String](https://mods.latvian.dev/books/kubejs-legacy/page/string) tag, [String](https://mods.latvian.dev/books/kubejs-legacy/page/string)\[\]/Regex ids) | TagWrapper | Shortcut method for event.get(tag).remove(ids). |
removeAll([String](https://mods.latvian.dev/books/kubejs-legacy/page/string) tag) | TagWrapper | Shortcut method for event.get(tag).removeAll(). |
removeAllTagsFrom(String\[\] ids) | void | Removes all tags from object |
Name | Type | Info |
add([String](https://mods.latvian.dev/books/kubejs-legacy/page/string)\[\]/Regex ids) | TagWrapper (itself) | Adds an object to this tag. If string starts with # then it will add all objects from the second tag. It can be either single string, regex (/regex/flags) or array of either. |
remove([String](https://mods.latvian.dev/books/kubejs-legacy/page/string)\[\]/Regex ids) | TagWrapper (itself) | Removes an object from tag, works the same as add(). |
removeAll() | TagWrapper (itself) | Removes all entries from tag. |
getObjectIds() | Collection<ResourceLocation> | Returns a list of all entries in a tag. Will resolve any sub-tags. |
Recipes use item tags, not block or fluid tags, even if items representing those are blocks. Like `minecraft:cobblestone` even if it's a block, it will still be an item tag for recipes.
`tags.blocks` and `tags.fluids` are for adding tags to block and fluid types, they work the same way. You can find existing block and fluid tags if you look at a block with F3 mode enabled, on side. These are mostly only used for technical reasons, and like mentioned above, if its for recipes/inventory, you will want to use `tags.items` even for blocks.