Architectury API (Fabric/Forge/NeoForge)

Architectury API (Fabric/Forge/NeoForge)

158M Downloads

Optional Tags

MaxNeedsSnacks opened this issue ยท 1 comments

commented

Low-priority, but a nice QOL feature that's unfortunately lacking from vanilla.

Currently, you need to use something like ItemTags.bind(String) to use tags statically, which:

  1. requires an AW because bind is private by default
  2. means the tag needs to exist (though it can be empty), otherwise you'll soft crash during server join

Forge fixes this problem by adding IOptionalNamedTag, which is great because it allows you to statically define tags that may or may not exist at runtime / when connecting to servers, and even gives you a way to supply default values if that tag doesn't exist when resolving it.

I think Architectury would benefit from a similar sort of approach, especially since using static tags might discourage people from using uncached calls like ItemTags.getAllTags().getTag(ResourceLocation) (whose exact runtime complexity I still need to profile)

commented

Fabric also has optional tags via its TagRegistry, so you could possibly bridge the common API to Forge's optional tags and Fabric's tag registry.