Skip to content

Commit

Permalink
Yay, obfuscation
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Mar 3, 2019
1 parent 82adedd commit a3538cd
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/main/java/io/github/cadiboo/nocubes/tempcore/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,7 @@ public static void redirect_shouldSideBeRendered(final ClassNode classNode) {
// IRETURN

instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new FieldInsnNode(
GETFIELD,
"net/minecraft/block/state/BlockStateContainer$StateImplementation",
"block",
"Lnet/minecraft/block/Block;"
));
instructions.insertBefore(ALOAD_0, BlockStateContainer$StateImplementation_block());
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 1));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 2));
Expand All @@ -198,6 +193,15 @@ public static void redirect_shouldSideBeRendered(final ClassNode classNode) {

}

private static AbstractInsnNode BlockStateContainer$StateImplementation_block() {
return new FieldInsnNode(
GETFIELD,
"net/minecraft/block/state/BlockStateContainer$StateImplementation",
ObfuscationHelper.remapFieldName("net/minecraft/block/state/BlockStateContainer$StateImplementation", "block"),
"Lnet/minecraft/block/Block;"
);
}

public static void redirect_addCollisionBoxToList(final ClassNode classNode) {

LOGGER.info("Starting injecting into addCollisionBoxToList");
Expand Down Expand Up @@ -252,12 +256,7 @@ public static void redirect_addCollisionBoxToList(final ClassNode classNode) {
// RETURN

instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new FieldInsnNode(
GETFIELD,
"net/minecraft/block/state/BlockStateContainer$StateImplementation",
"block",
"Lnet/minecraft/block/Block;"
));
instructions.insertBefore(ALOAD_0, BlockStateContainer$StateImplementation_block());
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 1));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 2));
Expand Down Expand Up @@ -322,12 +321,7 @@ public static void redirect_getCollisionBoundingBox(final ClassNode classNode) {
// ARETURN

instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new FieldInsnNode(
GETFIELD,
"net/minecraft/block/state/BlockStateContainer$StateImplementation",
"block",
"Lnet/minecraft/block/Block;"
));
instructions.insertBefore(ALOAD_0, BlockStateContainer$StateImplementation_block());
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 0));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 1));
instructions.insertBefore(ALOAD_0, new VarInsnNode(ALOAD, 2));
Expand All @@ -343,16 +337,19 @@ public static void redirect_getCollisionBoundingBox(final ClassNode classNode) {

}

//Coppied from 1.13 ObfuscationReflectionHelper

// Copied from ObfuscationReflectionHelper
private static class ObfuscationHelper {

private static String remapMethodName(String internalClassName, String methodName, String desc) {
private static String remapMethodName(final String internalClassName, final String methodName, final String desc) {
final String remappedName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(internalClassName, methodName, desc);
LOGGER.info("remapped name " + methodName + " to " + remappedName);
return remappedName;
}

private static String remapFieldName(final String internalClassName, final String fieldName) {
return FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fieldName, null);
}

}

}

0 comments on commit a3538cd

Please sign in to comment.