mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-20 04:09:50 +00:00
[Fabric] Write all descriptors which were remapped, regardless of whether or not they are actually different
This commit is contained in:
1 parent
125d5e9847
commit
bb5a3c6900
4 files changed
+18
-11
No files matched your search
@@ -248,7 +248,7 @@ public abstract class ObfuscationEnvironment implements IObfuscationEnvironment
|
||||
return mapping.move(remappedOwner);
|
||||
}
|
||||
String desc = ObfuscationUtil.mapDescriptor(mapping.getDesc(), this.remapper);
|
||||
return new MappingMethod(remappedOwner, mapping.getSimpleName(), desc);
|
||||
return new MappingMethod(remappedOwner, mapping.getSimpleName(), desc != null ? desc : mapping.getDesc());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public abstract class ObfuscationEnvironment implements IObfuscationEnvironment
|
||||
String desc = method.getDesc();
|
||||
if (desc != null) {
|
||||
String newDesc = ObfuscationUtil.mapDescriptor(method.getDesc(), this.remapper);
|
||||
if (!newDesc.equals(method.getDesc())) {
|
||||
if (newDesc != null) {
|
||||
desc = newDesc;
|
||||
transformed = true;
|
||||
}
|
||||
@@ -293,7 +293,8 @@ public abstract class ObfuscationEnvironment implements IObfuscationEnvironment
|
||||
*/
|
||||
@Override
|
||||
public String remapDescriptor(String desc) {
|
||||
return ObfuscationUtil.mapDescriptor(desc, this.remapper);
|
||||
String newDesc = ObfuscationUtil.mapDescriptor(desc, this.remapper);
|
||||
return newDesc != null ? newDesc : desc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,8 @@ public abstract class RemapperAdapter implements IRemapper, IClassRemapper {
|
||||
|
||||
@Override
|
||||
public String unmapDesc(String desc) {
|
||||
return ObfuscationUtil.unmapDescriptor(desc, this);
|
||||
String newDesc = ObfuscationUtil.unmapDescriptor(desc, this);
|
||||
return newDesc != null ? newDesc : desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -220,9 +220,6 @@ public final class ReferenceMapper implements IReferenceMapper, Serializable {
|
||||
return null;
|
||||
}
|
||||
String conformedReference = reference.replaceAll("\\s", "");
|
||||
if (conformedReference.equals(newReference)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Map<String, String>> mappings = this.mappings;
|
||||
if (context != null) {
|
||||
mappings = this.data.get(context);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package org.spongepowered.asm.util;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utility methods for obfuscation tasks
|
||||
*/
|
||||
@@ -79,12 +81,18 @@ public abstract class ObfuscationUtil {
|
||||
private static String remapDescriptor(String desc, IClassRemapper remapper, boolean unmap) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder token = null;
|
||||
boolean remapped = false;
|
||||
|
||||
for (int pos = 0; pos < desc.length(); pos++) {
|
||||
char c = desc.charAt(pos);
|
||||
if (token != null) {
|
||||
if (c == ';') {
|
||||
sb.append('L').append(ObfuscationUtil.remap(token.toString(), remapper, unmap)).append(';');
|
||||
String tokenStr = token.toString();
|
||||
Optional<String> remappedStr = ObfuscationUtil.remap(tokenStr, remapper, unmap);
|
||||
if (remappedStr.isPresent()) {
|
||||
remapped = true;
|
||||
}
|
||||
sb.append('L').append(remappedStr.orElse(tokenStr)).append(';');
|
||||
token = null;
|
||||
} else {
|
||||
token.append(c);
|
||||
@@ -102,12 +110,12 @@ public abstract class ObfuscationUtil {
|
||||
throw new IllegalArgumentException("Invalid descriptor '" + desc + "', missing ';'");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return remapped ? sb.toString() : null;
|
||||
}
|
||||
|
||||
private static Object remap(String typeName, IClassRemapper remapper, boolean unmap) {
|
||||
private static Optional<String> remap(String typeName, IClassRemapper remapper, boolean unmap) {
|
||||
String result = unmap ? remapper.unmap(typeName) : remapper.map(typeName);
|
||||
return result != null ? result : typeName;
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user