Posted July 16, 201510 yr ava.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) [idea_rt.jar:?] Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/Block at net.minecraft.init.Bootstrap.register(Bootstrap.java:551) ~[bootstrap.class:?] at net.minecraft.client.Minecraft.<init>(Minecraft.java:315) ~[Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) ~[Main.class:?] ... 13 more Caused by: java.lang.ClassNotFoundException: net.minecraft.block.Block at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51] at net.minecraft.init.Bootstrap.register(Bootstrap.java:551) ~[bootstrap.class:?] at net.minecraft.client.Minecraft.<init>(Minecraft.java:315) ~[Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) ~[Main.class:?] ... 13 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer io.github.anon10w1z.craftPP.coremod.CppClassTransformer@3aa078fd from coremod CppFMLLoadingPlugin at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:234) ~[forgeSrc-1.8-11.14.1.1371.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51] at net.minecraft.init.Bootstrap.register(Bootstrap.java:551) ~[bootstrap.class:?] at net.minecraft.client.Minecraft.<init>(Minecraft.java:315) ~[Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) ~[Main.class:?] ... 13 more Caused by: java.lang.NullPointerException at org.objectweb.asm.Item.set(Item.java:230) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.ClassWriter.newMethodItem(ClassWriter.java:1404) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.MethodWriter.visitMethodInsn(MethodWriter.java:888) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:133) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:816) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:726) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:412) ~[asm-debug-all-5.0.3.jar:5.0.3] at io.github.anon10w1z.craftPP.coremod.CppClassTransformer.transformBlock(CppClassTransformer.java:37) ~[CraftPlusPlus/:?] at io.github.anon10w1z.craftPP.coremod.CppClassTransformer.transform(CppClassTransformer.java:18) ~[CraftPlusPlus/:?] at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:230) ~[forgeSrc-1.8-11.14.1.1371.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51] at net.minecraft.init.Bootstrap.register(Bootstrap.java:551) ~[bootstrap.class:?] at net.minecraft.client.Minecraft.<init>(Minecraft.java:315) ~[Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) ~[Main.class:?] ... 13 more My code: package io.github.anon10w1z.craftPP.coremod; import net.minecraft.block.state.IBlockState; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; public class CppClassTransformer implements IClassTransformer { @Override public byte[] transform(String className, String string, byte[] bytes) { if (className.equals("atr")) return transformBlock(bytes, true); if (className.equals("net.minecraft.block.Block")) return transformBlock(bytes, false); return bytes; } private byte[] transformBlock(byte[] bytes, boolean obfuscated) { String targetMethodName = obfuscated ? "func_176213_c" : "onBlockAdded"; ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); for (MethodNode methodNode : classNode.methods) { if (methodNode.name.equals(targetMethodName)) { methodNode.instructions.clear(); InsnList injectionList = new InsnList(); injectionList.add(new VarInsnNode(Opcodes.ALOAD, 0)); injectionList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "io/github/anon10w1z/craftPP/CppClassTransformer", "onBlockAdded", methodNode.signature)); methodNode.instructions.add(injectionList); } } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); classNode.accept(writer); return writer.toByteArray(); } public static void onBlockAdded(World world, IBlockState blockState, BlockPos blockPos) { System.out.println(world + "\n" + blockState + "\n" + blockPos); } } I am trying to make dirt and clay fall like sand. If possible, is there a way to change the subclass of a vanilla class, e.g. make BlockDirt subclass BlockFalling? Maker of the Craft++ mod.
July 16, 201510 yr Caused by: java.lang.NullPointerException at org.objectweb.asm.Item.set(Item.java:230) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.ClassWriter.newMethodItem(ClassWriter.java:1404) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.MethodWriter.visitMethodInsn(MethodWriter.java:888) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:133) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:816) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:726) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:412) ~[asm-debug-all-5.0.3.jar:5.0.3] at io.github.anon10w1z.craftPP.coremod.CppClassTransformer.transformBlock(CppClassTransformer.java:37) ~[CraftPlusPlus/:?] Show line 37 in CppClassTransformer. There's something null on that line which is causing the error. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
July 16, 201510 yr Author Caused by: java.lang.NullPointerException at org.objectweb.asm.Item.set(Item.java:230) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.ClassWriter.newMethodItem(ClassWriter.java:1404) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.MethodWriter.visitMethodInsn(MethodWriter.java:888) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:133) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:816) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:726) ~[asm-debug-all-5.0.3.jar:5.0.3] at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:412) ~[asm-debug-all-5.0.3.jar:5.0.3] at io.github.anon10w1z.craftPP.coremod.CppClassTransformer.transformBlock(CppClassTransformer.java:37) ~[CraftPlusPlus/:?] Show line 37 in CppClassTransformer. There's something null on that line which is causing the error. The actual error is that the Block class is not loaded. Maker of the Craft++ mod.
July 16, 201510 yr Author - Why are you completely clearing the method? - You are missing a return opcode. I'm overriding the whole method functionality, and the method doesn't return a value. EDIT: Now it doesn't crash, but how can I pass the parameters from the vanilla method to my delegate method? EDIT2: It turns out it didn't find the method in the first place. When I fixed that issue it crashed. Maker of the Craft++ mod.
July 16, 201510 yr Author I'm overriding the whole method functionalityonBlockAdded does nothing. By clearing the instruction list anyways you destroy any hooks that another coremod might have put there.and the method doesn't return a value.In bytecode there is always a return instruction. how can I pass the parameters from the vanilla method to my delegate method? Loading the values on the stack before calling your method. You should really dig deeper in understanding how bytecode works before making a coremod. Thanks for the advice, I'll do my googling. But why is it still crashing? Maker of the Craft++ mod.
July 16, 201510 yr Author Scratch that, now the method is found but not run. public class CppClassTransformer implements IClassTransformer { @Override public byte[] transform(String className, String string, byte[] bytes) { if (className.equals("atr")) return transformBlock(bytes, true); if (className.equals("net.minecraft.block.Block")) return transformBlock(bytes, false); return bytes; } private byte[] transformBlock(byte[] bytes, boolean obfuscated) { String targetMethodName = obfuscated ? "func_176213_c" : "onBlockAdded"; ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); for (MethodNode methodNode : classNode.methods) { if (methodNode.name.equals(targetMethodName)) { System.out.println("Found method!"); InsnList injectionList = new InsnList(); injectionList.add(new VarInsnNode(Opcodes.ALOAD, 1)); injectionList.add(new VarInsnNode(Opcodes.ALOAD, 2)); injectionList.add(new VarInsnNode(Opcodes.ALOAD, 3)); injectionList.add(new VarInsnNode(Opcodes.ALOAD, 0)); injectionList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "io/github/anon10w1z/craftPP/CppClassTransformer", "onBlockAdded", "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/block/Block;)V")); methodNode.instructions.add(injectionList); } } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); classNode.accept(writer); return writer.toByteArray(); } @SuppressWarnings("unused") public static void onBlockAdded(World world, BlockPos blockPos, IBlockState blockState, Block block) { if (CppConfigHandler.additionalFallingBlocks.contains(block)) world.scheduleUpdate(blockPos, block, block.tickRate(world)); System.out.println("Hai"); } } "Found method!" is printed but "Hai" is not when the block is placed. EDIT: Forgot the return. Testing with it now EDIT2: No dice. Maker of the Craft++ mod.
July 17, 201510 yr Careful with using ASM. Too much of it and you turn into a mere husk, housing something dark and evil. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
July 17, 201510 yr Author Careful with using ASM. Too much of it and you turn into a mere husk, housing something dark and evil. It's not that much, plus there isn't any alternative, as far as I know. Maker of the Craft++ mod.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.