Class ObjectHolderRegistry


  • public class ObjectHolderRegistry
    extends java.lang.Object
    Internal registry for tracking ObjectHolder references
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.logging.log4j.Logger LOGGER  
      private static org.objectweb.asm.Type MOD  
      private static org.objectweb.asm.Type OBJECT_HOLDER  
      private static java.util.Set<java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>>> objectHolders  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addHandler​(java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>> ref)
      Exposed to allow modders to register their own notification handlers.
      static void applyObjectHolders()  
      static void applyObjectHolders​(java.util.function.Predicate<ResourceLocation> filter)  
      static void findObjectHolders()  
      static boolean removeHandler​(java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>> ref)
      Removed the specified handler from the notification list.
      private static void scanClassForFields​(java.util.Map<org.objectweb.asm.Type,​java.lang.String> classModIds, org.objectweb.asm.Type targetClass, java.lang.String value, java.lang.Class<?> clazz, boolean extractFromExistingValues)  
      private static void scanTarget​(java.util.Map<org.objectweb.asm.Type,​java.lang.String> classModIds, java.util.Map<org.objectweb.asm.Type,​java.lang.Class<?>> classCache, org.objectweb.asm.Type type, java.lang.String annotationTarget, java.lang.String value, boolean isClass, boolean extractFromValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.apache.logging.log4j.Logger LOGGER
      • objectHolders

        private static final java.util.Set<java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>>> objectHolders
      • OBJECT_HOLDER

        private static final org.objectweb.asm.Type OBJECT_HOLDER
      • MOD

        private static final org.objectweb.asm.Type MOD
    • Constructor Detail

      • ObjectHolderRegistry

        public ObjectHolderRegistry()
    • Method Detail

      • addHandler

        public static void addHandler​(java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>> ref)
        Exposed to allow modders to register their own notification handlers. This runnable will be called after a registry snapshot has been injected and finalized. The internal list is backed by a HashSet so it is HIGHLY recommended you implement a proper equals and hashCode function to de-duplicate callers here. The default @ObjectHolder implementation uses the hashCode/equals for the field the annotation is on.
      • removeHandler

        public static boolean removeHandler​(java.util.function.Consumer<java.util.function.Predicate<ResourceLocation>> ref)
        Removed the specified handler from the notification list. The internal list is backed by a hash set, and so proper hashCode and equals operations are required for success. The default @ObjectHolder implementation uses the hashCode/equals for the field the annotation is on.
        Returns:
        true if handler was matched and removed.
      • findObjectHolders

        public static void findObjectHolders()
      • scanTarget

        private static void scanTarget​(java.util.Map<org.objectweb.asm.Type,​java.lang.String> classModIds,
                                       java.util.Map<org.objectweb.asm.Type,​java.lang.Class<?>> classCache,
                                       org.objectweb.asm.Type type,
                                       @Nullable
                                       java.lang.String annotationTarget,
                                       java.lang.String value,
                                       boolean isClass,
                                       boolean extractFromValue)
      • scanClassForFields

        private static void scanClassForFields​(java.util.Map<org.objectweb.asm.Type,​java.lang.String> classModIds,
                                               org.objectweb.asm.Type targetClass,
                                               java.lang.String value,
                                               java.lang.Class<?> clazz,
                                               boolean extractFromExistingValues)
      • applyObjectHolders

        public static void applyObjectHolders()
      • applyObjectHolders

        public static void applyObjectHolders​(java.util.function.Predicate<ResourceLocation> filter)