Class RemappingReferenceMapper
- All Implemented Interfaces:
IReferenceMapper
Before now, refMaps in deobfCompile dependencies had to be disabled because the obfuscated mappings were no use in a development environment. However there existed no "mcp-to-different-version-of-mcp" mappings to use instead.
This class leverages the fact that mappings are provided into the environment by GradleStart and consumes SRG mappings in the imported refMaps and converts them on-the-fly using srg-to-mcp mappings. This allows refMaps to be normalised to the current MCP environment.
Note that this class takes a naïve approach to remapping on the basis that searge names are unique and can thus be remapped with a straightforward dumb string replacement. Whilst the input environment and mappings are customisable via the appropriate environment vars, this fact should be taken into account if a different mapping environment is to be used.
All lookups are straightforward string replacements using all values in the map, this basically means this is probably pretty slow, but I don't care because the number of mappings processed is usually pretty small (few hundred at most) and this is only used in dev where we don't actually care about speed. Some performance is gained (approx 10ms per lookup) by caching the transformed descriptors.
-
Method Summary
Modifier and TypeMethodDescriptionGet the current contextGet the resource name this refmap was loaded from (if available).Get a user-readable "status" string for this refmap for use in error messagesbooleanGet whether this mapper is defaulted.static IReferenceMapperof(MixinEnvironment env, IReferenceMapper refMap)Wrap the specified refmap in a remapping adapter using settings in the supplied environmentRemap a reference for the specified owning class in the current contextremapWithContext(String context, String className, String reference)Remap a reference for the specified owning class in the specified contextvoidsetContext(String context)Set the current remap context, can be null
-
Method Details
-
isDefault
public boolean isDefault()Description copied from interface:IReferenceMapperGet whether this mapper is defaulted. Use this flag rather than reference comparison toReferenceMapper.DEFAULT_MAPPERbecause of classloader shenanigans- Specified by:
isDefaultin interfaceIReferenceMapper- Returns:
- true if this mapper is a defaulted mapper
-
getResourceName
Description copied from interface:IReferenceMapperGet the resource name this refmap was loaded from (if available).- Specified by:
getResourceNamein interfaceIReferenceMapper- Returns:
- name of the resource
-
getStatus
Description copied from interface:IReferenceMapperGet a user-readable "status" string for this refmap for use in error messages- Specified by:
getStatusin interfaceIReferenceMapper- Returns:
- status message
-
getContext
Description copied from interface:IReferenceMapperGet the current context- Specified by:
getContextin interfaceIReferenceMapper- Returns:
- current context key, can be null
-
setContext
Description copied from interface:IReferenceMapperSet the current remap context, can be null- Specified by:
setContextin interfaceIReferenceMapper- Parameters:
context- remap context
-
remap
Description copied from interface:IReferenceMapperRemap a reference for the specified owning class in the current context- Specified by:
remapin interfaceIReferenceMapper- Parameters:
className- Owner classreference- Reference to remap- Returns:
- remapped reference, returns original reference if not remapped
-
remapWithContext
Description copied from interface:IReferenceMapperRemap a reference for the specified owning class in the specified context- Specified by:
remapWithContextin interfaceIReferenceMapper- Parameters:
context- Remap context to useclassName- Owner classreference- Reference to remap- Returns:
- remapped reference, returns original reference if not remapped
-
of
Wrap the specified refmap in a remapping adapter using settings in the supplied environment- Parameters:
env- environment to read configuration fromrefMap- refmap to wrap- Returns:
- wrapped refmap or original refmap is srg data is not available
-