aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-05-04 17:27:53 +0200
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-05-04 17:27:53 +0200
commite054e77358c4ca1cd5f794274740c3200aed9940 (patch)
tree124ff569d7f1c48ef7c3cee7b055b69942e1cc0a /src/main
parent95cda6817234c2d6fc127922e3a332ac0850274b (diff)
downloadGT5-Unofficial-e054e77358c4ca1cd5f794274740c3200aed9940.tar.gz
GT5-Unofficial-e054e77358c4ca1cd5f794274740c3200aed9940.tar.bz2
GT5-Unofficial-e054e77358c4ca1cd5f794274740c3200aed9940.zip
added ConfigOption for TC patch
+added DeObfs instruction +code cleanup Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: d28147d803a8f97cf0d8ef07870f4e28691d7212
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/bartimaeusnek/ASM/BWCore.java5
-rw-r--r--src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java57
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java6
3 files changed, 26 insertions, 42 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java
index 031ff30512..b32537378c 100644
--- a/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java
+++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java
@@ -60,13 +60,16 @@ public class BWCore extends DummyModContainer {
public void preInit(FMLPreInitializationEvent event) {
shouldTransform[0] = Loader.isModLoaded("ExtraUtilities") && ConfigHandler.enabledPatches[0];
shouldTransform[1] = Loader.isModLoaded("ExtraUtilities") && ConfigHandler.enabledPatches[1];
- BWCore.BWCORE_LOG.info("Extra Utilities found? " + shouldTransform[0]);
+ shouldTransform[3] = Loader.isModLoaded("Thaumcraft") && ConfigHandler.enabledPatches[3];
+ BWCore.BWCORE_LOG.info("Extra Utilities found and ASM Patch enabled? " + shouldTransform[0]);
+ BWCore.BWCORE_LOG.info("Thaumcraft found and ASM Patch enabled? " + shouldTransform[3]);
}
@Override
public List<ArtifactVersion> getDependants() {
List<ArtifactVersion> ret = new ArrayList<ArtifactVersion>();
ret.add(new DefaultArtifactVersion("ExtraUtilities", true));
+ ret.add(new DefaultArtifactVersion("Thaumcraft", true));
ret.add(new DefaultArtifactVersion(BartWorksCrossmod.MOD_ID, true));
return ret;
}
diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java
index ce5ab6da40..1f2d6f942c 100644
--- a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java
+++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java
@@ -48,30 +48,13 @@ public class BWCoreTransformer implements IClassTransformer {
"net.minecraft.client.renderer.RenderGlobal",
"thaumcraft.common.tiles.TileWandPedestal",
};
- public static boolean obfs = false;
+ static boolean obfs;
- public static boolean[] shouldTransform = new boolean[CLASSESBEEINGTRANSFORMED.length];
-
-// public void checkForMods() {
-// //hacky way to detect if the mods are loaded
-// try{
-// Class.forName("com.rwtema.extrautils.core.Tuple");
-// shouldTransform[0] = true;
-// shouldTransform[1] = true;
-// }catch (ClassNotFoundException e){
-// BWCore.BWCORE_LOG.info("Extra Utilities not found!");
-// shouldTransform[0] = false;
-// shouldTransform[1] = false;
-// }
-// try{
-// Class.forName("micdoodle8.mods.galacticraft.core.Constants");
-// shouldTransform[2] = true;
-// }catch (ClassNotFoundException e){
-// BWCore.BWCORE_LOG.info("micdoodle Core not found!");
-// shouldTransform[2] = false;
-// }
-// }
+ public static boolean[] shouldTransform = new boolean[BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length];
+ /**
+ * Made by DarkShaddow44
+ */
private static MethodNode transformThaumcraftWandPedestal(MethodNode method) {
InsnList nu = new InsnList();
for (int j = 0; j < method.instructions.size(); j++) {
@@ -83,8 +66,8 @@ public class BWCoreTransformer implements IClassTransformer {
AbstractInsnNode beginning = method.instructions.get(j - 7);
LabelNode label = new LabelNode();
nu.insertBefore(beginning, new VarInsnNode(ALOAD, 0));
- nu.insertBefore(beginning, new FieldInsnNode(GETFIELD, "thaumcraft/common/tiles/TileWandPedestal", "field_145850_b" /*"worldObj"*/, "Lnet/minecraft/world/World;"));
- nu.insertBefore(beginning, new FieldInsnNode(GETFIELD, "net/minecraft/world/World", "field_72995_K" /*"isRemote"*/, "Z"));
+ nu.insertBefore(beginning, new FieldInsnNode(GETFIELD, "thaumcraft/common/tiles/TileWandPedestal", obfs ? "field_145850_b" : "worldObj", "Lnet/minecraft/world/World;"));
+ nu.insertBefore(beginning, new FieldInsnNode(GETFIELD, "net/minecraft/world/World", obfs ? "field_72995_K" : "isRemote", "Z"));
nu.insertBefore(beginning, new JumpInsnNode(IFNE, label));
nu.add(new InsnNode(POP));
nu.add(label);
@@ -98,19 +81,19 @@ public class BWCoreTransformer implements IClassTransformer {
public static byte[] transform(int id, byte[] basicClass) {
if (!BWCoreTransformer.shouldTransform[id]) {
- BWCore.BWCORE_LOG.info("Patch: " + DESCRIPTIONFORCONFIG[id] + " is disabled, will not patch!");
+ BWCore.BWCORE_LOG.info("Patch: " + BWCoreTransformer.DESCRIPTIONFORCONFIG[id] + " is disabled, will not patch!");
return basicClass;
}
if (id < BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length) {
- BWCore.BWCORE_LOG.info(DESCRIPTIONFORCONFIG[id]);
+ BWCore.BWCORE_LOG.info(BWCoreTransformer.DESCRIPTIONFORCONFIG[id]);
ClassReader classReader = new ClassReader(basicClass);
ClassNode classNode = new ClassNode();
classReader.accept(classNode, ClassReader.SKIP_FRAMES);
List<MethodNode> methods = classNode.methods;
switch (id) {
case 0: {
- BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
String name_deObfs = "canDoRainSnowIce";
String dsc_deObfs = "(Lnet/minecraft/world/chunk/Chunk;)Z";
@@ -138,7 +121,7 @@ public class BWCoreTransformer implements IClassTransformer {
break;
}
case 1: {
- BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
String name_deObfs = "getPossibleCreatures";
String name_src = "func_73155_a";
String name_Obfs = "a";
@@ -168,7 +151,7 @@ public class BWCoreTransformer implements IClassTransformer {
String dsc_universal = "(F)V";
String field_deObfs = "locationSunPng";
String field_src = "field_110928_i";
- BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
for (int i = 0; i < methods.size(); i++) {
MethodNode toPatch = methods.get(i);
if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_universal)) {
@@ -183,7 +166,7 @@ public class BWCoreTransformer implements IClassTransformer {
String nameFieldToPatch;
for (int j = 0; j < toPatch.instructions.size(); j++) {
- if (toPatch.instructions.get(j) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j)).getOpcode() == GETSTATIC && !(nameFieldToPatch = ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j)).name, field_deObfs, field_src)).isEmpty()) {
+ if (toPatch.instructions.get(j) instanceof FieldInsnNode && toPatch.instructions.get(j).getOpcode() == GETSTATIC && !(nameFieldToPatch = ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j)).name, field_deObfs, field_src)).isEmpty()) {
boolean useSrc = nameFieldToPatch.equals(field_src);
if (useSrc)
BWCore.BWCORE_LOG.info("Found either Optifine or Fastcraft... this patch was annoying to make compatible to them...");
@@ -208,9 +191,9 @@ public class BWCoreTransformer implements IClassTransformer {
} else {
if (j < toPatch.instructions.size() - 2) {
- if (toPatch.instructions.get(j + 2) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j + 2)).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 2)).name, field_deObfs, field_src).isEmpty())
+ if (toPatch.instructions.get(j + 2) instanceof FieldInsnNode && toPatch.instructions.get(j + 2).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 2)).name, field_deObfs, field_src).isEmpty())
continue;
- if (toPatch.instructions.get(j + 1) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j + 1)).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 1)).name, field_deObfs, field_src).isEmpty())
+ if (toPatch.instructions.get(j + 1) instanceof FieldInsnNode && toPatch.instructions.get(j + 1).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 1)).name, field_deObfs, field_src).isEmpty())
continue;
}
nu.add(toPatch.instructions.get(j));
@@ -223,7 +206,7 @@ public class BWCoreTransformer implements IClassTransformer {
break;
}
case 3: {
- BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.info("Could find: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
String name_deObfs = "updateEntity";
String name_src = "func_145845_h";
String name_Obfs = "h";
@@ -232,16 +215,14 @@ public class BWCoreTransformer implements IClassTransformer {
for (int i = 0; i < methods.size(); i++) {
if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_universal, dsc_universal)) {
BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!");
- MethodNode toPatch = methods.get(i);
- toPatch = transformThaumcraftWandPedestal(toPatch);
- methods.set(i, toPatch);
+ methods.set(i, BWCoreTransformer.transformThaumcraftWandPedestal(methods.get(i)));
break;
}
}
break;
}
default: {
- BWCore.BWCORE_LOG.info("Could not find: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.info("Could not find: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
return basicClass;
}
}
@@ -251,7 +232,7 @@ public class BWCoreTransformer implements IClassTransformer {
classNode.accept(classWriter);
byte[] ret = classWriter.toByteArray();
if (Arrays.hashCode(basicClass) == Arrays.hashCode(ret))
- BWCore.BWCORE_LOG.warn("Could not patch: " + CLASSESBEEINGTRANSFORMED[id]);
+ BWCore.BWCORE_LOG.warn("Could not patch: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[id]);
return ret;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java
index 669417a345..92aeef9c3f 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java
@@ -69,8 +69,8 @@ public class ConfigHandler {
for (int i = 0; i < BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length; i++) {
BWCoreTransformer.shouldTransform[i] = ConfigHandler.c.get("ASM fixes", BWCoreTransformer.DESCRIPTIONFORCONFIG[i] + " in class: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[i], true).getBoolean(true);
}
- enabledPatches = new boolean[BWCoreTransformer.shouldTransform.length];
- enabledPatches = Arrays.copyOf(BWCoreTransformer.shouldTransform,BWCoreTransformer.shouldTransform.length);
+ ConfigHandler.enabledPatches = new boolean[BWCoreTransformer.shouldTransform.length];
+ ConfigHandler.enabledPatches = Arrays.copyOf(BWCoreTransformer.shouldTransform,BWCoreTransformer.shouldTransform.length);
ConfigHandler.ross128BID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64);
ConfigHandler.ross128BAID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128ba", -63, "The Dim ID for Ross128ba (Ross128b's Moon)").getInt(-63);
@@ -83,7 +83,7 @@ public class ConfigHandler {
ConfigHandler.c.save();
}
- public static void setUpComments() {
+ private static void setUpComments() {
ConfigHandler.c.addCustomCategoryComment("ASM fixes", "Disable ASM fixes here.");
ConfigHandler.c.addCustomCategoryComment("Multiblocks", "Multliblock Options can be set here.");
ConfigHandler.c.addCustomCategoryComment("Singleblocks", "Singleblock Options can be set here.");