Everything posted by CrushedPixel
-
Clone Minecraftforge to build own version
I'm not sure if this is the right place to ask, but I need to do an urgent hotfix for Minecraftforge and therefore I want to clone the Github repo and build my own version. I've tried this before, however with no success. Can someone give me a brief introduction? I have good knowledge of git and I use Eclipse. @diesieben: If you read this, would be cool for you to come online in Skype if you wanna help me. Thanks in advance, CrushedPixel
-
Client Side: Test if OP on a Server
Lol I guess I'll run a simple command then that doesn't affect the world (e.g. /testfor @a[r=1]) and check if it denies permission.
-
Health Boost Not Regenning
You should have a look whether you are cancelling any Regeneration Effects somewhere. Also, you might be applying the Health Boost effect for a very short time and / or over and over again. The key is to apply the effect only once when it's necessary and remove it later.
-
Client Side: Test if OP on a Server
Is there a simple way to test whether mc.thePlayer is OP on a multiplayer server? Client side, I don't want to mod the Server.
-
[SOLVED] Client Side Mod: Teleport Player on Server
I guess this can be locked as "Solved" then - many thanks!
-
[SOLVED] Client Side Mod: Teleport Player on Server
Hmm, I think I'll just require OP for the mod then. Would be overdone, especially because when flying over a larger distance chunks might not get rendered etc.
-
[SOLVED] Client Side Mod: Teleport Player on Server
I've already done that in the Replay Mod. How can I add this custom entity to the world the client receives?
-
[SOLVED] Client Side Mod: Teleport Player on Server
I'm pretty sure it doesn't, as F5 showed the player. How to actually move the camera? Any tutorial links?
-
[SOLVED] Client Side Mod: Teleport Player on Server
I've recreated the Camera Studio Mod for 1.8 using Forge, and the only part that's missing is the initial Teleport and/or Goto. How might this work in Camera Studio for MC 1.7, since it does NOT require OP there?
-
[SOLVED] Client Side Mod: Teleport Player on Server
Is there a way to teleport a player over a rather large distance (> 100 blocks) while he is on a server? calling mc.thePlayer.moveToBlockPosAndAngles and similar methods just result in the server teleporting the player back. I need it for a waypoints system I'm creating - Server side mods are not an option. If necessary, OP can be a requirement.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
As the aim of this mod is to simplify mapmaking/command block creations, that would be kinda counterproductive. A quick showcase on the finished mod btw if anyone's interested:
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Without modding the server, that wouldn't be possible though.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Trust me, I would've done that if I could have, however the Minecraft class calls the NetHandlerLoginClient, which then instantiates the NetHandlerPlayClient. In order to do the desired manipulation, I would have had to extend the NetHandlerPlayClient, but there was no point where I could replace the default PlayClient with my custom one. So I had to use the dirty Bytecode Manipulation way.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
What exactly do you mean? All of the Forge+ASM tutorials I found used this technique.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
I've switched my code to use ASM now - it works perfectly fine! For everyone reading this thread, who is interested in how I solved my problem: private byte[] patchClass(String name, byte[] bytes, boolean obfuscated) throws NotFoundException, CannotCompileException, IOException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException { String methodName = obfuscated ? "func_147274_a" : "handleTabComplete"; String nhpc = "net/minecraft/client/network/NetHandlerPlayClient"; String gc = obfuscated ? "field_147299_f" : "gameController"; String mc = "net/minecraft/client/Minecraft"; String cs = obfuscated ? "field_71462_r" : "currentScreen"; String gs = "net/minecraft/client/gui/GuiScreen"; String desc = "(Lnet/minecraft/network/play/server/S3APacketTabComplete;)V"; ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); int i = 0; Iterator<MethodNode> methods = classNode.methods.iterator(); while(methods.hasNext()) { MethodNode m = methods.next(); int fdiv_index = -1; if(m.name.equals(methodName) && m.desc.equals(desc)) { int ix = 0; for(ix = 0; ix<m.instructions.size(); ix++) { AbstractInsnNode node = m.instructions.get(ix); if(node instanceof InsnNode) { if(((InsnNode)node).getOpcode() == Opcodes.RETURN) { break; } } } LabelNode ln = new LabelNode(new Label()); InsnList toInject = new InsnList(); //mv.visitVarInsn(ALOAD, 0); toInject.add(new VarInsnNode(Opcodes.ALOAD, 0)); //mv.visitFieldInsn(GETFIELD, "net/minecraft/client/network/NetHandlerPlayClient", "gameController", "Lnet/minecraft/client/Minecraft;"); toInject.add(new FieldInsnNode(Opcodes.GETFIELD, nhpc, gc, "L"+mc+";")); //mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", "currentScreen", "Lnet/minecraft/client/gui/GuiScreen;"); toInject.add(new FieldInsnNode(Opcodes.GETFIELD, mc, cs, "L"+gs+";")); //mv.visitTypeInsn(INSTANCEOF, "net/minecraft/client/gui/GuiChat"); toInject.add(new TypeInsnNode(Opcodes.INSTANCEOF, "eu/crushedpixel/commandsyntax/gui/GuiSyntaxCommandBlock")); Label skipLabel = new Label(); //mv.visitJumpInsn(IFEQ, l3); toInject.add(new JumpInsnNode(Opcodes.IFEQ, ln)); //mv.visitVarInsn(ALOAD, 0); toInject.add(new VarInsnNode(Opcodes.ALOAD, 0)); //mv.visitFieldInsn(GETFIELD, "net/minecraft/client/network/NetHandlerPlayClient", "gameController", "Lnet/minecraft/client/Minecraft;"); toInject.add(new FieldInsnNode(Opcodes.GETFIELD, nhpc, gc, "L"+mc+";")); //mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", "currentScreen", "Lnet/minecraft/client/gui/GuiScreen;"); toInject.add(new FieldInsnNode(Opcodes.GETFIELD, mc, cs, "L"+gs+";")); //mv.visitTypeInsn(CHECKCAST, "net/minecraft/client/gui/GuiChat"); toInject.add(new TypeInsnNode(Opcodes.CHECKCAST, "eu/crushedpixel/commandsyntax/gui/GuiSyntaxCommandBlock")); //mv.visitVarInsn(ASTORE, 3); toInject.add(new VarInsnNode(Opcodes.ASTORE, 3)); //mv.visitVarInsn(ALOAD, 3); toInject.add(new VarInsnNode(Opcodes.ALOAD, 3)); //mv.visitVarInsn(ALOAD, 2); toInject.add(new VarInsnNode(Opcodes.ALOAD, 2)); //mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/gui/GuiChat", "onAutocompleteResponse", "([Ljava/lang/String;)V", false); toInject.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "eu/crushedpixel/commandsyntax/gui/GuiSyntaxCommandBlock", "onAutocompleteResponse", "([Ljava/lang/String;)V", false)); toInject.add(ln); m.instructions.insert(m.instructions.get(ix-1), toInject); } i++; } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(writer); return writer.toByteArray(); } I am very fond of the great support I received here in the Forums - excellent work <3 This thread is Solved.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Thank you very much, I'll switch to ASM then, even if it appears to be a lot more complicated. I am very much pleased with your patience in answering all of my questions.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Thanks a lot. I've fixed my code and now use $1 (which is the placeholder for the first passed parameter in the method) instead of paramiy. However, it now gives me a CannotCompileException: Apparently the class eu.crushedpixel.commandsyntax.gui.GuiSyntaxCommandBlock isn't loaded yet. Is there any way to make the Class Loader load this particular class before the Bytecode Manipulation happens? EDIT: Calling ClassLoader.getSystemClassLoader().loadClass("eu.crushedpixel.commandsyntax.gui.GuiSyntaxCommandBlock"); Simply throws java.lang.ClassNotFoundException: eu.crushedpixel.commandsyntax.gui.GuiSyntaxCommandBlock
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Okay, I've also added the /lib folder with the javassist.jar. Thanks a lot, I'll be back tomorrow evening (I assume we're in the same timezone) and accessible here again.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
https://github.com/CrushedPixel/CommandSyntaxMod Here you go. Thanks a lot for your engagement, it means a lot for me! Also thanks for your excellent MCPNames class!
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
To save the bytecode, I've modified the method to look like this: @Override public byte[] transform(String name, String transformedName, byte[] basicClass) { try { if(name.equals("cee")) { basicClass = patchClass(name, basicClass, true); } else if(name.equals("net.minecraft.client.network.NetHandlerPlayClient")) { basicClass = patchClass(name, basicClass, false); } } catch(Exception e) { e.printStackTrace(); } try { File f = new File("/Users/**********/classes"); f.mkdirs(); File f2 = new File(f, name.replace(".", "_")+".class"); f2.createNewFile(); FileOutputStream fos = new FileOutputStream(f2); fos.write(basicClass); fos.close(); } catch(Exception e) { System.out.println("ERROR WHILE WRITING "+name); e.printStackTrace(); } return basicClass; } However, neither files called cee.class nor NetHandlerPlayClient.class appear in the classes directory This means the mistake happens earlier.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Thanks for the hint. Apparently the NetHandlerPlayClient.class is entirely missing (which explains the NoClassDefFoundError) - I wonder where it went lost.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
I am convinced that not the way HOW I modify the Bytecode (Javassist and the inserted Lines of Code) but rather the stuff around the injection leads to the exceptions. The reason for this is that the code works perfectly fine when I'm in Eclipse, but after compilation with Gradle (which is correct as well since the core mod later prints out my debug messages), it won't work. Maybe the NetHandlerPlayClient class can't be found because it doesn't get deobfuscated after compilation? Thanks in advance for suggestions.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
That's correct, and in this case it IS right, since the code works when not compiled using Gradle. Could line 174 of the Stack Trace (on pastebin) be the critical point? [18:35:19] [server thread/INFO] [FML]: [server thread] Server side modded connection established [18:35:19] [Netty Local Client IO #0/ERROR] [FML]: There was a critical exception handling a packet on channel FML java.lang.ClassCastException: net.minecraft.client.network.NetHandlerLoginClient cannot be cast to net.minecraft.network.play.INetHandlerPlayClient at net.minecraftforge.fml.common.network.FMLNetworkEvent$ClientConnectedToServerEvent.<init>(FMLNetworkEvent.java:36) ~[FMLNetworkEvent$ClientConnectedToServerEvent.class:?]
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
Thanks for your reply. I've replaced the insertAt() with cm.insertAfter(toAdd); The code still works in the IDE, but after compiling the same problem occurs.
-
[SOLVED | SWITCHED TO ASM] Javassist not working with ModClassLoader
I've created a Mod which adds Autocomplete to Command Blocks. I'm requesting the Autocomplete Packets from the Server, but to forward them to the Command Block GUI I have to add 3 lines of code to the NetHandlerPlayClient. Extending the NetHandlerPlayClient is not an option as it gets called by the Minecraft class whose methods I can't simply override. So I've inserted some lines of code into the Bytecode of NetHandlerPlayClient.class using Javassist: http://pastebin.com/qURdbJSy When running the Mod in Eclipse (using the modified run configuration which points to my PluginLoader class), everything works fine. The Mod does exactly what it should. After compiling the mod with Gradle however, I can't connect to a server (neither internal nor SMP) - the following exception is thrown: http://pastebin.com/aJM4gxgH Any hints? I think the problem might be that the class is for some reason obfuscated when loaded after I manipulated its Bytecode. Thanks in advance, CrushedPixel
IPS spam blocked by CleanTalk.