1414import net .minecraft .registry .RegistryKey ;
1515import net .minecraft .registry .RegistryOps ;
1616import net .minecraft .registry .RegistryOps .RegistryInfoLookup ;
17+ import net .minecraft .registry .tag .TagKey ;
18+ import net .minecraft .resource .ResourceManager ;
19+ import net .minecraft .util .Identifier ;
1720
1821public class LimlibRegistryHooks {
1922
@@ -23,6 +26,8 @@ public class LimlibRegistryHooks {
2326 @ Internal
2427 public static final Map <RegistryKey <? extends Registry <?>>, Set <LimlibJsonRegistryHook <?>>> REGISTRY_JSON_HOOKS = Maps
2528 .newHashMap ();
29+ @ Internal
30+ public static final Map <TagKey <?>, Set <LimlibJsonTagHook <?>>> TAG_JSON_HOOKS = Maps .newHashMap ();
2631
2732 public static <O , T extends Registry <O >> void hook (RegistryKey <T > key , LimlibRegistryHook <O > hook ) {
2833 Set <LimlibRegistryHook <?>> hooks = REGISTRY_HOOKS .computeIfAbsent (key , k -> Sets .newHashSet ());
@@ -34,6 +39,16 @@ public static <O, T extends Registry<O>> void hook(RegistryKey<T> key, LimlibJso
3439 hooks .add (hook );
3540 }
3641
42+ public static <O , T extends Registry <O >> void hook (RegistryKey <T > key , Identifier tag , LimlibJsonTagHook <O > hook ) {
43+ Set <LimlibJsonTagHook <?>> hooks = TAG_JSON_HOOKS .computeIfAbsent (TagKey .of (key , tag ), k -> Sets .newHashSet ());
44+ hooks .add (hook );
45+ }
46+
47+ public static <O > void hook (TagKey <O > key , LimlibJsonTagHook <O > hook ) {
48+ Set <LimlibJsonTagHook <?>> hooks = TAG_JSON_HOOKS .computeIfAbsent (key , k -> Sets .newHashSet ());
49+ hooks .add (hook );
50+ }
51+
3752 @ FunctionalInterface
3853 public interface LimlibRegistryHook <O > {
3954
@@ -61,4 +76,17 @@ void register(RegistryInfoLookup infoLookup, RegistryKey<? extends Registry<O>>
6176
6277 }
6378
79+ @ FunctionalInterface
80+ public interface LimlibJsonTagHook <O > {
81+
82+ /**
83+ * @param ResourceManager The resource manager.
84+ * @param tag The tag being hooked into.
85+ * @param jsonElement The jsonElement to modify before being read by a
86+ * CODEC.
87+ */
88+ void register (ResourceManager manager , TagKey <O > tag , JsonElement jsonElement );
89+
90+ }
91+
6492}
0 commit comments