Class RuntimeEnumExtender
java.lang.Object
net.neoforged.fml.common.asm.enumextension.RuntimeEnumExtender
- All Implemented Interfaces:
ILaunchPluginService
Transforms enums implementing
IExtensibleEnum to add additional entries loaded from files provided by mods-
Nested Class Summary
Nested classes/interfaces inherited from interface cpw.mods.modlauncher.serviceapi.ILaunchPluginService
ILaunchPluginService.ComputeFlags, ILaunchPluginService.ITransformerLoader, ILaunchPluginService.Phase -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final Typeprivate static final intprivate static final Typeprivate static final Typeprivate static final Stringprivate static final intprivate static final Stringprivate static final Typeprivate static final Typeprivate static final Typeprivate static final Typeprivate static final EnumSet<ILaunchPluginService.Phase> private static final Typeprivate static final Typeprivate static Map<String, List<EnumPrototype>> private static final Typeprivate static final EnumSet<ILaunchPluginService.Phase> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendValuesArray(Type classType, ListGeneratorAdapter generator, List<org.objectweb.asm.tree.FieldNode> enumEntries) private static voidbuildExtensionInfo(org.objectweb.asm.tree.ClassNode classNode, Type classType, ListGeneratorAdapter generator, org.objectweb.asm.tree.FieldNode infoField, int vanillaCount, int moddedCount) private static voidclearMethod(org.objectweb.asm.tree.MethodNode mth) private static List<org.objectweb.asm.tree.FieldNode> createEnumEntries(Type classType, ListGeneratorAdapter generator, Set<String> ctors, int idParamIdx, int nameParamIdx, int vanillaEntryCount, List<EnumPrototype> prototypes) private static org.objectweb.asm.tree.FieldNodefindField(org.objectweb.asm.tree.ClassNode classNode, Predicate<org.objectweb.asm.tree.FieldNode> predicate) static org.objectweb.asm.tree.AbstractInsnNodefindFirstInstructionBefore(org.objectweb.asm.tree.MethodNode method, int opCode, int startIndex) Finds the first instruction with matching opcode before the given index in reverse searchstatic org.objectweb.asm.tree.MethodInsnNodefindFirstStaticMethodCall(org.objectweb.asm.tree.MethodNode method, String owner, String name, String descriptor) Finds the first static method call in the given method matching the given owner, name and descriptorprivate static org.objectweb.asm.tree.MethodNodefindMethod(org.objectweb.asm.tree.ClassNode classNode, Predicate<org.objectweb.asm.tree.MethodNode> predicate) private static org.objectweb.asm.tree.AbstractInsnNodefindValuesArrayCreation(Type classType, org.objectweb.asm.tree.MethodNode clinit) private static org.objectweb.asm.tree.FieldInsnNodefindValuesArrayStore(Type classType, org.objectweb.asm.tree.ClassNode classNode, org.objectweb.asm.tree.MethodNode mth, String owner) private static intgetParameterIndexFromAnnotation(org.objectweb.asm.tree.ClassNode classNode, Type annoType) private static intgetVanillaEntryCount(org.objectweb.asm.tree.ClassNode classNode, Type classType) handlesClass(Type classType, boolean isEmpty) If this plugin wants to receive theClassNodeintoILaunchPluginService.processClass(cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase, org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type)private static booleanisAllowedConstructor(org.objectweb.asm.tree.MethodNode mth) private static voidloadConstructorParams(ListGeneratorAdapter generator, int idParamIdx, int nameParamIdx, int ordinal, EnumPrototype proto) static voidloadEnumPrototypes(Map<IModInfo, Path> paths) name()The name of this plugin.booleanprocessClass(ILaunchPluginService.Phase phase, org.objectweb.asm.tree.ClassNode classNode, Type classType) Each class loaded is offered to the plugin for processing.private static voidreturnValuesToExtender(Type classType, ListGeneratorAdapter generator, List<EnumPrototype> protos, List<org.objectweb.asm.tree.FieldNode> entries) private static Optional<org.objectweb.asm.tree.MethodNode> tryFindMethod(org.objectweb.asm.tree.ClassNode classNode, Predicate<org.objectweb.asm.tree.MethodNode> predicate) static StringvalidateNameParameter(String fieldName, String owningMod) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cpw.mods.modlauncher.serviceapi.ILaunchPluginService
addResources, customAuditConsumer, getExtension, handlesClass, initializeLaunch, offerResource, processClass, processClassWithFlags
-
Field Details
-
YAY
-
NAY
-
MARKER_IFACE
-
INDEXED_ANNOTATION
-
NAMED_ANNOTATION
-
RESERVED_ANNOTATION
-
ENUM_PROXY
-
NET_CHECK
-
EXT_INFO
-
EXT_INFO_GETTER_DESC
-
EXT_INFO_CTOR_DESC
-
NETWORKED_ANNOTATION
-
EXTENDER
-
ARRAYS
-
ENUM_FLAGS
private static final int ENUM_FLAGS- See Also:
-
ARRAY_FLAGS
private static final int ARRAY_FLAGS- See Also:
-
EXT_INFO_FLAGS
private static final int EXT_INFO_FLAGS- See Also:
-
prototypes
-
-
Constructor Details
-
RuntimeEnumExtender
public RuntimeEnumExtender()
-
-
Method Details
-
name
Description copied from interface:ILaunchPluginServiceThe name of this plugin. Must be unique. Multiple plugins by the same name will result in a hard exit. Launcher and other systems will rely on this name to find services provided by this plugin, so it should be stable.- Specified by:
namein interfaceILaunchPluginService- Returns:
- the name of the plugin
-
handlesClass
Description copied from interface:ILaunchPluginServiceIf this plugin wants to receive theClassNodeintoILaunchPluginService.processClass(cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase, org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type)- Specified by:
handlesClassin interfaceILaunchPluginService- Parameters:
classType- the class to considerisEmpty- if the class is empty at present (indicates no backing file found)- Returns:
- the set of Phases the plugin wishes to be called back with
-
processClass
public boolean processClass(ILaunchPluginService.Phase phase, org.objectweb.asm.tree.ClassNode classNode, Type classType) Description copied from interface:ILaunchPluginServiceEach class loaded is offered to the plugin for processing. Ordering between plugins is not known. One ofILaunchPluginService.processClass(Phase, ClassNode, Type),ILaunchPluginService.processClass(Phase, ClassNode, Type, String)orILaunchPluginService.processClassWithFlags(Phase, ClassNode, Type, String)must be implemented.- Specified by:
processClassin interfaceILaunchPluginService- Parameters:
phase- The phase of the supplied class nodeclassNode- the classnode to processclassType- the name of the class- Returns:
- true if the classNode needs rewriting using COMPUTE_FRAMES or false if it needs no NO_REWRITE
-
findFirstStaticMethodCall
public static org.objectweb.asm.tree.MethodInsnNode findFirstStaticMethodCall(org.objectweb.asm.tree.MethodNode method, String owner, String name, String descriptor) Finds the first static method call in the given method matching the given owner, name and descriptor- Parameters:
method- the method to search inowner- the method call's owner to search forname- the method call's namedescriptor- the method call's descriptor- Returns:
- the found method call node, null if none matched after the given index
-
findFirstInstructionBefore
public static org.objectweb.asm.tree.AbstractInsnNode findFirstInstructionBefore(org.objectweb.asm.tree.MethodNode method, int opCode, int startIndex) Finds the first instruction with matching opcode before the given index in reverse search- Parameters:
method- the method to search inopCode- the opcode to search forstartIndex- the index at which to start searching (inclusive)- Returns:
- the found instruction node or null if none matched before the given startIndex
-
tryFindMethod
-
findMethod
private static org.objectweb.asm.tree.MethodNode findMethod(org.objectweb.asm.tree.ClassNode classNode, Predicate<org.objectweb.asm.tree.MethodNode> predicate) -
findField
private static org.objectweb.asm.tree.FieldNode findField(org.objectweb.asm.tree.ClassNode classNode, Predicate<org.objectweb.asm.tree.FieldNode> predicate) -
clearMethod
private static void clearMethod(org.objectweb.asm.tree.MethodNode mth) -
getVanillaEntryCount
-
getParameterIndexFromAnnotation
private static int getParameterIndexFromAnnotation(org.objectweb.asm.tree.ClassNode classNode, Type annoType) -
isAllowedConstructor
private static boolean isAllowedConstructor(org.objectweb.asm.tree.MethodNode mth) -
findValuesArrayCreation
private static org.objectweb.asm.tree.AbstractInsnNode findValuesArrayCreation(Type classType, org.objectweb.asm.tree.MethodNode clinit) -
findValuesArrayStore
-
createEnumEntries
private static List<org.objectweb.asm.tree.FieldNode> createEnumEntries(Type classType, ListGeneratorAdapter generator, Set<String> ctors, int idParamIdx, int nameParamIdx, int vanillaEntryCount, List<EnumPrototype> prototypes) -
loadConstructorParams
private static void loadConstructorParams(ListGeneratorAdapter generator, int idParamIdx, int nameParamIdx, int ordinal, EnumPrototype proto) -
buildExtensionInfo
private static void buildExtensionInfo(org.objectweb.asm.tree.ClassNode classNode, Type classType, ListGeneratorAdapter generator, org.objectweb.asm.tree.FieldNode infoField, int vanillaCount, int moddedCount) -
returnValuesToExtender
private static void returnValuesToExtender(Type classType, ListGeneratorAdapter generator, List<EnumPrototype> protos, List<org.objectweb.asm.tree.FieldNode> entries) -
appendValuesArray
private static void appendValuesArray(Type classType, ListGeneratorAdapter generator, List<org.objectweb.asm.tree.FieldNode> enumEntries) -
loadEnumPrototypes
-
validateNameParameter
-