mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-26 20:53:06 +00:00
Write soft targets to the refmap and remap them at runtime
This commit is contained in:
1 parent
a5e797faed
commit
ebdaf69e29
6 files changed
+48
-5
No files matched your search
@@ -318,7 +318,7 @@ class AnnotatedMixin {
|
||||
if (this.targets.contains(type)) {
|
||||
continue;
|
||||
}
|
||||
this.targets.add(type);
|
||||
this.addTarget(type);
|
||||
if (primaryTarget == null) {
|
||||
primaryTarget = type;
|
||||
}
|
||||
@@ -343,7 +343,7 @@ class AnnotatedMixin {
|
||||
this.mixins.printMessage(Kind.ERROR, "Mixin target " + privateTarget + " is public and must be specified in value", this);
|
||||
return null;
|
||||
}
|
||||
this.targets.add(type);
|
||||
this.addSoftTarget(type, privateTarget);
|
||||
if (primaryTarget == null) {
|
||||
primaryTarget = type;
|
||||
}
|
||||
@@ -358,7 +358,20 @@ class AnnotatedMixin {
|
||||
|
||||
return primaryTarget;
|
||||
}
|
||||
|
||||
private void addSoftTarget(TypeHandle type, String reference) {
|
||||
ObfuscationData<String> obfClassData = this.mixins.getObfClass(type);
|
||||
if (!obfClassData.isEmpty()) {
|
||||
this.mixins.addClassMapping(this.classRef, reference, obfClassData);
|
||||
}
|
||||
|
||||
this.addTarget(type);
|
||||
}
|
||||
|
||||
private void addTarget(TypeHandle type) {
|
||||
this.targets.add(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.mixin.getSimpleName().toString();
|
||||
|
||||
@@ -396,6 +396,13 @@ class AnnotatedMixins implements Messager, ITokenProvider, IOptionProvider, ITyp
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an obfuscation mapping for a class
|
||||
*/
|
||||
public ObfuscationData<String> getObfClass(TypeHandle type) {
|
||||
return this.getObfClass(type.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an obfuscation mapping for a class
|
||||
*/
|
||||
@@ -446,6 +453,15 @@ class AnnotatedMixins implements Messager, ITokenProvider, IOptionProvider, ITyp
|
||||
}
|
||||
}
|
||||
|
||||
void addClassMapping(String className, String reference, ObfuscationData<String> obfClassData) {
|
||||
for (TargetObfuscationEnvironment targetEnv : this.targetEnvironments) {
|
||||
String remapped = obfClassData.get(targetEnv.getType());
|
||||
if (remapped != null) {
|
||||
targetEnv.addMapping(className, reference, remapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reference mapper
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user