Changes

2,228 bytes added ,  22:18, 18 April 2023
m
Line 29: Line 29:  
Tags for all registries are automatically sent from the server to any remote clients on login and reload. <code><nowiki>Block</nowiki></code>s, <code><nowiki>Item</nowiki></code>s, <code><nowiki>EntityType</nowiki></code>s, <code><nowiki>Fluid</nowiki></code>s, and <code><nowiki>GameEvent</nowiki></code>s are special cased as they have <code><nowiki>Holder</nowiki></code>s allowing for available tags to be accessible through the object itself.
 
Tags for all registries are automatically sent from the server to any remote clients on login and reload. <code><nowiki>Block</nowiki></code>s, <code><nowiki>Item</nowiki></code>s, <code><nowiki>EntityType</nowiki></code>s, <code><nowiki>Fluid</nowiki></code>s, and <code><nowiki>GameEvent</nowiki></code>s are special cased as they have <code><nowiki>Holder</nowiki></code>s allowing for available tags to be accessible through the object itself.
   −
Tags wrappers can be created using <code><nowiki>TagKey#create</nowiki></code> where the registry the tag should belong to and the tag name are supplied. Some vanilla defined helpers are also available to create wrappers via <code><nowiki>*Tags#create</nowiki></code> where <code><nowiki>*</nowiki></code> refers to the name of the registry object.
+
Tags wrappers can be created using <code><nowiki>TagKey#create</nowiki></code> where the registry the tag should belong to and the tag name are supplied. Some vanilla defined helpers are also available to create wrappers via <code><nowiki>*Tags#create</nowiki></code> where <code><nowiki>*</nowiki></code> refers to the name of the registry object. Forge wrapped registries can create a tag using <code><nowiki>ITagManager</nowiki></code> via <code><nowiki>IForgeRegistry#tags</nowiki></code>. <code><nowiki>TagKey</nowiki></code>s can then be obtained via <code><nowiki>ITagManager#createTagKey</nowiki></code>.
   −
Forge wrapped registry objects can grab their associated holder using <code><nowiki>IForgeRegistry#getHolder</nowiki></code> while non-Forge registry objects use either <code><nowiki>Registry#getHolder</nowiki></code> or <code><nowiki>Registry#getHolderOrThrow</nowiki></code>. They then can compare if the registry object has a tag using <code><nowiki>Holder#is</nowiki></code>. Tag-holding registry objects contain a method called <code><nowiki>#is</nowiki></code> in either their registry object or state-aware class to check whether the object belongs to a certain tag.
+
Forge wrapped registry objects can grab their associated holder using <code><nowiki>IForgeRegistry#getHolder</nowiki></code>. Additionally, other streamlined operations can be performed using <code><nowiki>ITagManager</nowiki></code>. Non-Forge registry objects use either <code><nowiki>Registry#getHolder</nowiki></code> or <code><nowiki>Registry#getHolderOrThrow</nowiki></code> to get the current holder.
 +
 
 +
They then can compare if the registry object has a tag using <code><nowiki>Holder#is</nowiki></code>. Tag-holding registry objects contain a method called <code><nowiki>#is</nowiki></code> in either their registry object or state-aware class to check whether the object belongs to a certain tag.
    
As an example:  
 
As an example:  
Line 37: Line 39:  
public static final TagKey<Item> myItemTag = ItemTags.create(new ResourceLocation("mymod", "myitemgroup"));
 
public static final TagKey<Item> myItemTag = ItemTags.create(new ResourceLocation("mymod", "myitemgroup"));
   −
public static final TagKey<Potion> myPotionTag = TagKey.create(Registry.POTION, new ResourceLocation("mymod", "mypotiongroup"));
+
public static final TagKey<Potion> myPotionTag = ForgeRegistries.POTIONS.tags().createTagKey(new ResourceLocation("mymod", "mypotiongroup"));
    
public static final TagKey<VillagerType> myVillagerTypeTag = TagKey.create(Registry.VILLAGER_TYPE, new ResourceLocation("mymod", "myvillagertypegroup"));
 
public static final TagKey<VillagerType> myVillagerTypeTag = TagKey.create(Registry.VILLAGER_TYPE, new ResourceLocation("mymod", "myvillagertypegroup"));
Line 44: Line 46:  
boolean isInItemGroup = stack.is(myItemTag);
 
boolean isInItemGroup = stack.is(myItemTag);
   −
// In some method where potionName is a ResourceLocation
+
// In some method where potion is a Potion
boolean isInPotionGroup = ForgeRegistries.POTIONS.getHolder(potionName).map(holder -> holder.is(myPotionTag)).orElse(false);
+
boolean isInPotionGroup = ForgeRegistries.POTIONS.tags().getTag(myPotionTag).contains(potion);
    
// In some method where villagerTypeKey is a ResourceKey<VillagerType>
 
// In some method where villagerTypeKey is a ResourceKey<VillagerType>
Line 641: Line 643:  
|-
 
|-
 
| <code>forge:milk</code> || None || Milk
 
| <code>forge:milk</code> || None || Milk
 +
|}
 +
 +
==== Entity Types ====
 +
 +
{| class="wikitable"
 +
|-
 +
! Name !! Super Tag(s) !! Contains
 +
|-
 +
| <code>forge:bosses</code> || None || Mobs that are designed as bosses (boss bar appears and difficult to fight)
 
|}
 
|}
    
[[Category:Resources and Data]]
 
[[Category:Resources and Data]]
 +
 +
=== Community Tags ===
 +
 +
This is a list of all tags in the Forge namespace that are not part of Forge but agreed on by the modding community as the standard.
 +
 +
==== Blocks ====
 +
 +
{| class="wikitable"
 +
|-
 +
! Name !! Super Tag(s) !! Contains
 +
|-
 +
| <code>forge:relocation_not_supported</code> || None || Immovable blocks [''from modded sources other than Pistons'']
 +
|-
 +
| <code>forge:storage_blocks/honeycombs</code> || <code>forge:storage_blocks</code> || Honeycomb blocks
 +
|-
 +
| <code>forge:storage_blocks/wax</code> || <code>forge:storage_blocks</code> || Wax blocks
 +
|}
 +
 +
==== Items ====
 +
 +
{| class="wikitable"
 +
|-
 +
! Name !! Super Tag(s) !! Contains
 +
|-
 +
| <code>forge:buckets/honey</code> || None || Buckets holding honey fluids
 +
|-
 +
| <code>forge:concrete</code> || None || Concrete
 +
|-
 +
| <code>forge:concrete_powder</code> || None || Concrete Powder
 +
|-
 +
| <code>forge:honeycombs</code> || None || Honeycombs
 +
|-
 +
| <code>forge:honey_bottles</code> || None || Honey bottles
 +
|-
 +
| <code>forge:glazed_terracotta</code> || None || Glazed Terracotta
 +
|-
 +
| <code>forge:pollen</code> || None || Pollen
 +
|-
 +
| <code>forge:shulker_boxes</code> || None || Shulker Boxes
 +
|-
 +
| <code>forge:storage_blocks/honeycombs</code> || <code>forge:storage_blocks</code> || Honeycomb blocks
 +
|-
 +
| <code>forge:storage_blocks/wax</code> || <code>forge:storage_blocks</code> || Wax blocks
 +
|-
 +
| <code>forge:wax</code> || None || Wax
 +
|}
 +
 +
==== Fluids ====
 +
 +
{| class="wikitable"
 +
|-
 +
! Name !! Super Tag(s) !! Contains
 +
|-
 +
| <code>forge:honey</code> || None || Honey
 +
|}
 +
 +
==== Entity Types ====
 +
 +
{| class="wikitable"
 +
|-
 +
! Name !! Super Tag(s) !! Contains
 +
|-
 +
| <code>forge:slimes</code> || None || Slime-like mobs
 +
|}
2

edits