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 revision
Previous revision
Next revisionBoth sides next revision
tutorial:tags [2022/04/29 09:47] solidblocktutorial:tags [2022/05/25 08:11] – [1.16.5 and below (Requires Fabric API)] 1.17 uses TagRegistry solidblock
Line 18: Line 18:
 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. 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.+Vanilla tag objects can be found in class ''<yarn class_3481>'' and ''<yarn class_3489>''. To register tag objects in your mod, see the following.
  
 === 1.18.2 and above === === 1.18.2 and above ===
-<code java> +<yarncode java>
- +
-import net.minecraft.block.Block; +
-import net.minecraft.tag.TagKey; +
-import net.minecraft.util.Identifier; +
-import net.minecraft.util.registry.Registry; +
 public class ModBlockTags { public class ModBlockTags {
-  public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(Registry.BLOCK_KEY, new Identifier("tutorial", "example_ores"));+  public static final TagKey<class_2248> EXAMPLE_ORES = TagKey.of(class_2378.field_25105, new class_2960("tutorial", "example_ores"));
 } }
-</code>+</yarncode>
  
  
 ==== 1.18.1 and below (Requires Fabric API) ==== ==== 1.18.1 and below (Requires Fabric API) ====
-<code java> +<yarncode java>
-import net.fabricmc.fabric.api.tag.TagFactory; +
-import net.minecraft.block.Block; +
-import net.minecraft.tag.Tag; +
-import net.minecraft.util.Identifier; +
 public class ModBlockTags { public class ModBlockTags {
-  public static final Tag<Block> EXAMPLE_ORES = TagFactory.BLOCK.create(new Identifier("tutorial", "example_ores"));+  public static final Tag<class_2248> EXAMPLE_ORES = TagFactory.BLOCK.create(new class_2960("tutorial", "example_ores"));
 } }
-</code> +</yarncode>
- +
-==== 1.16.5 and below (Requires Fabric API) ==== +
-<code java>+
  
 +==== 1.17 and below, not including 1.17.1 (Requires Fabric API) ====
 +<yarncode java>
 public class ModBlockTags { public class ModBlockTags {
-  public static final Tag<Block> EXAMPLE_ORES = TagRegistry.block(new Identifier("tutorial", "example_ores"));+  public static final Tag<class_2248> EXAMPLE_ORES = TagRegistry.block(new class_2960("tutorial", "example_ores"));
 } }
-</code>+</yarncode>
  
 ===== Common Tags vs Mod Tags ===== ===== Common Tags vs Mod Tags =====
tutorial/tags.txt · Last modified: 2024/01/05 13:53 by cph101