Jump to content

Recommended Posts

Posted

I'm attempting to remove the instructions from BlockDynamicLiquid which cause a third water source to appear between two existing sources. However, I cannot get the program to run.

 

This is the class I've written:

 

package com.xydre.minecraft.aqua.asm;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;

import net.minecraft.launchwrapper.IClassTransformer;

public class FiniteTweak implements IClassTransformer {
    public static Logger logger = LogManager.getLogger("Aqua");

@Override
public byte[] transform(String name, String transformedName,
		byte[] basicClass) {
	if (transformedName.equals("net.minecraft.block.BlockDynamicLiquid"))
        {
            return patchFiniteTweak(basicClass);
        }

        return basicClass;
}

private byte[] patchFiniteTweak(byte[] basicClass) {
	ClassNode classNode = new ClassNode();
        ClassReader classReader = new ClassReader(basicClass);
        classReader.accept(classNode, 0);

        String methodName = "func_149674_a";
        String deobfMethodName = "updateTick";
        
        MethodNode targetMethod = null;
        for (MethodNode methodNode : classNode.methods) {
            if (methodName.equals(methodNode.name) || deobfMethodName.equals(methodNode.name)) {
            	targetMethod = methodNode;
            	break;
            }
        }

        for (int i=72; i<82; i++) {
        	logger.info(i);
        	targetMethod.instructions.remove(targetMethod.instructions.get(i));
        }
        
        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
        classNode.accept(writer);
        
	return writer.toByteArray();
}

}

 

And this is the output:

 

[17:21:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker
[17:21:38] [main/INFO] [FML]: Forge Mod Loader version 7.10.85.1230 for Minecraft 1.7.10 loading
[17:21:38] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_40, running on Linux:amd64:3.11.4-031104-generic, installed at /usr/lib/jvm/java-8-oracle/jre
[17:21:38] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[17:21:38] [main/INFO] [FML]: Found a command line coremod : com.xydre.minecraft.aqua.Aqua
[17:21:38] [main/WARN] [FML]: The coremod com.xydre.minecraft.aqua.Aqua does not have a MCVersion annotation, it may cause issues with this version of Minecraft
[17:21:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[17:21:38] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[17:21:39] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[17:21:39] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[17:21:39] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[17:21:39] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker
[17:21:40] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker
[17:21:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker
[17:21:40] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[17:21:40] [main/INFO]: Setting user: Player512
[17:21:41] [main/INFO] [Aqua]: 72
[17:21:41] [main/INFO] [Aqua]: 73
[17:21:41] [main/INFO] [Aqua]: 74
[17:21:41] [main/INFO] [Aqua]: 75
[17:21:41] [main/INFO] [Aqua]: 76
[17:21:41] [main/INFO] [Aqua]: 77
[17:21:41] [main/INFO] [Aqua]: 78
[17:21:41] [main/INFO] [Aqua]: 79
[17:21:41] [main/INFO] [Aqua]: 80
[17:21:41] [main/INFO] [Aqua]: 81
[17:21:41] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_40]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_40]
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:?]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/BlockDynamicLiquid
at net.minecraft.block.Block.registerBlocks(Block.java:249) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 6 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.block.BlockDynamicLiquid
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_40]
at net.minecraft.block.Block.registerBlocks(Block.java:249) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at org.objectweb.asm.Frame.merge(Frame.java:1397) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.Frame.merge(Frame.java:1374) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1475) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:834) ~[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 com.xydre.minecraft.aqua.asm.FiniteTweak.patchFiniteTweak(FiniteTweak.java:48) ~[bin/:?]
at com.xydre.minecraft.aqua.asm.FiniteTweak.transform(FiniteTweak.java:20) ~[bin/:?]
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_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_40]
at net.minecraft.block.Block.registerBlocks(Block.java:249) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 6 more

 

Any help would be much appreciated!

Posted

Might help if you didn't increment through the array.  As you remove each instruction, the total count reduces, and your next increment skips over an item.

 

Also, magic numbers like 72 and 82 are a bad idea in general.

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.