mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 08:02:13 +00:00
Temp fix for downstream SRGs not remapping members, fixes #99
This commit is contained in:
1 parent
d8e07fcb27
commit
54fa0f4e76
5 files changed
+125
-9
No files matched your search
@@ -41,9 +41,9 @@ import joptsimple.internal.Strings;
|
||||
*/
|
||||
public class SrgContainer {
|
||||
|
||||
private final BiMap<String, String> classMap = HashBiMap.create();
|
||||
private final BiMap<String, String> fieldMap = HashBiMap.create();
|
||||
private final BiMap<String, String> packageMap = HashBiMap.create();
|
||||
private final BiMap<String, String> classMap = HashBiMap.create();
|
||||
private final BiMap<SrgField, SrgField> fieldMap = HashBiMap.create();
|
||||
private final BiMap<SrgMethod, SrgMethod> methodMap = HashBiMap.create();
|
||||
|
||||
public void readSrg(File srg) throws IOException {
|
||||
@@ -60,7 +60,7 @@ public class SrgContainer {
|
||||
} else if (type.equals("CL")) {
|
||||
this.classMap.forcePut(args[0], args[1]);
|
||||
} else if (type.equals("FD")) {
|
||||
this.fieldMap.forcePut(args[0], args[1]);
|
||||
this.fieldMap.forcePut(new SrgField(args[0]), new SrgField(args[1]));
|
||||
} else if (type.equals("MD")) {
|
||||
this.methodMap.forcePut(new SrgMethod(args[0], args[1]), new SrgMethod(args[2], args[3]));
|
||||
} else {
|
||||
@@ -73,7 +73,7 @@ public class SrgContainer {
|
||||
return this.methodMap.get(methodName);
|
||||
}
|
||||
|
||||
public String getFieldMapping(String fieldName) {
|
||||
public SrgField getFieldMapping(SrgField fieldName) {
|
||||
return this.fieldMap.get(fieldName);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.obfuscation;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public final class SrgField {
|
||||
|
||||
private final String mapping;
|
||||
|
||||
public SrgField(String mapping) {
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (this.mapping == null) {
|
||||
return null;
|
||||
}
|
||||
int pos = this.mapping.lastIndexOf('/');
|
||||
return pos > -1 ? this.mapping.substring(pos + 1) : this.mapping;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
if (this.mapping == null) {
|
||||
return null;
|
||||
}
|
||||
int pos = this.mapping.lastIndexOf('/');
|
||||
return pos > -1 ? this.mapping.substring(0, pos) : null;
|
||||
}
|
||||
|
||||
public String getMapping() {
|
||||
return this.mapping;
|
||||
}
|
||||
|
||||
public SrgField move(String newOwner) {
|
||||
return new SrgField((newOwner != null ? newOwner + "/" : "") + this.getName());
|
||||
}
|
||||
|
||||
public SrgField copy() {
|
||||
return new SrgField(this.mapping);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.mapping);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof SrgField) {
|
||||
return Objects.equal(this.mapping, ((SrgField)obj).mapping);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.mapping;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,6 +60,14 @@ public final class SrgMethod {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
public SrgMethod move(String newOwner) {
|
||||
return new SrgMethod((newOwner != null ? newOwner + "/" : "") + this.getSimpleName(), this.desc);
|
||||
}
|
||||
|
||||
public SrgMethod copy() {
|
||||
return new SrgMethod(this.name, this.desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.name, this.desc);
|
||||
|
||||
Reference in new issue
Block a user