public final class RemappingReferenceMapper extends java.lang.Object implements 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.
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getContext()
Get the current context
|
java.lang.String |
getResourceName()
Get the resource name this refmap was loaded from (if available).
|
java.lang.String |
getStatus()
Get a user-readable "status" string for this refmap for use in error
messages
|
boolean |
isDefault()
Get whether this mapper is defaulted.
|
static IReferenceMapper |
of(MixinEnvironment env,
IReferenceMapper refMap)
Wrap the specified refmap in a remapping adapter using settings in the
supplied environment
|
java.lang.String |
remap(java.lang.String className,
java.lang.String reference)
Remap a reference for the specified owning class in the current context
|
java.lang.String |
remapWithContext(java.lang.String context,
java.lang.String className,
java.lang.String reference)
Remap a reference for the specified owning class in the specified context
|
void |
setContext(java.lang.String context)
Set the current remap context, can be null
|
public boolean isDefault()
IReferenceMapperReferenceMapper.DEFAULT_MAPPER because of
classloader shenanigansisDefault in interface IReferenceMapperpublic java.lang.String getResourceName()
IReferenceMappergetResourceName in interface IReferenceMapperpublic java.lang.String getStatus()
IReferenceMappergetStatus in interface IReferenceMapperpublic java.lang.String getContext()
IReferenceMappergetContext in interface IReferenceMapperpublic void setContext(java.lang.String context)
IReferenceMappersetContext in interface IReferenceMappercontext - remap contextpublic java.lang.String remap(java.lang.String className,
java.lang.String reference)
IReferenceMapperremap in interface IReferenceMapperclassName - Owner classreference - Reference to remappublic java.lang.String remapWithContext(java.lang.String context,
java.lang.String className,
java.lang.String reference)
IReferenceMapperremapWithContext in interface IReferenceMappercontext - Remap context to useclassName - Owner classreference - Reference to remappublic static IReferenceMapper of(MixinEnvironment env, IReferenceMapper refMap)
env - environment to read configuration fromrefMap - refmap to wrap