User Tools

Site Tools


tutorial:tags

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tutorial:tags [2022/04/29 09:35] – [1.18.1 and below (Requires Fabric API)] solidblocktutorial:tags [2022/04/29 09:47] solidblock
Line 14: Line 14:
 The ''"replace"'' tag determines whether the mod will remove all other items in the tag that are not mentioned in this file. It is not recommended to set this to true, as it may break compatibility with other mods. ''blocks'' in the file path can also be ''items'' or ''fluids''. You should separate words with underscores, and tags should be plural. The ''"replace"'' tag determines whether the mod will remove all other items in the tag that are not mentioned in this file. It is not recommended to set this to true, as it may break compatibility with other mods. ''blocks'' in the file path can also be ''items'' or ''fluids''. You should separate words with underscores, and tags should be plural.
  
-For some cases, you might want to have tags checked on code, which will require you to register them:+===== Using tags in code =====
  
-==== 1.18.2 and above ====+For some cases, you might want to have tags as registered objects on code. For example, methods like ''Block#isIn'' require these tag parameters. Besides, the Fabric registries like ''FlammableBlockRegistry'', ''FuelRegistry'' and ''CompostingChanceRegistry'' also accept block tags or item tags. 
 + 
 +Vanilla tag objects can be found in class ''BlockTags'' and ''ItemTags''. To register tag objects in your mod, see the following. 
 + 
 +=== 1.18.2 and above ===
 <code java> <code java>
  
Line 24: Line 28:
 import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
  
-public class BlockTags {+public class ModBlockTags {
   public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(Registry.BLOCK_KEY, new Identifier("tutorial", "example_ores"));   public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(Registry.BLOCK_KEY, new Identifier("tutorial", "example_ores"));
 } }
Line 37: Line 41:
 import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
  
-public class BlockTags {+public class ModBlockTags {
   public static final Tag<Block> EXAMPLE_ORES = TagFactory.BLOCK.create(new Identifier("tutorial", "example_ores"));   public static final Tag<Block> EXAMPLE_ORES = TagFactory.BLOCK.create(new Identifier("tutorial", "example_ores"));
 } }
Line 45: Line 49:
 <code java> <code java>
  
-public class BlockTags {+public class ModBlockTags {
   public static final Tag<Block> EXAMPLE_ORES = TagRegistry.block(new Identifier("tutorial", "example_ores"));   public static final Tag<Block> EXAMPLE_ORES = TagRegistry.block(new Identifier("tutorial", "example_ores"));
 } }
Line 51: Line 55:
  
 ===== Common Tags vs Mod Tags ===== ===== Common Tags vs Mod Tags =====
-If your tag applies ONLY to items in your mod, and no other mod is likely to have similar items, or you specifically want to only include your mod's items in that tag, then use ''yourmodid:yourtaghere'', with the example above. However, if your mod adds items which other mods also add, you can+If your tag applies ONLY to items in your mod, and no other mod is likely to have similar items, or you specifically want to only include your mod's items in that tag, then use ''yourmodid:yourtaghere'', with the example above. However, if your mod adds items which other mods also add, you can:
  
 ======= Creating New Common Tags ======= ======= Creating New Common Tags =======
 Common tags should be named with the syntax ''c:yourtaghere'', with ''c'' standing for common. When making the file, use the file path ''src/main/resources/data/c/tags/'' and then ''blocks'', ''items'' or ''fluids'' You should separate words with underscores, and tags should be plural. Common tags should be named with the syntax ''c:yourtaghere'', with ''c'' standing for common. When making the file, use the file path ''src/main/resources/data/c/tags/'' and then ''blocks'', ''items'' or ''fluids'' You should separate words with underscores, and tags should be plural.
  
-======= Existing Common Tags =======+====== Existing Common Tags ======
 This section was [[https://github.com/fabric-community/fabric-convention-tags|automatically generated using a script]]. See the end of this page for the list of mods used. If your item fits into one of these tags, then you should add it to that tag instead of defining your own. If you want your mod's recipes to be compatible with other mods, replace the item in the recipe with ''#c:tagname''. This section was [[https://github.com/fabric-community/fabric-convention-tags|automatically generated using a script]]. See the end of this page for the list of mods used. If your item fits into one of these tags, then you should add it to that tag instead of defining your own. If you want your mod's recipes to be compatible with other mods, replace the item in the recipe with ''#c:tagname''.
  
tutorial/tags.txt · Last modified: 2024/01/05 13:53 by cph101