Posted August 30, 201411 yr Is it possible to overwrite the standard packet handler from Minecraft? So I can alter the way the client handles stuff like health changes etc.?
August 30, 201411 yr A new topic wasn't needed, but what are you trying to do? You originally wanted to know whether onLivingHurt event would work on Multiplayer, it will if you use it correctly, what do you want to do? If you're only altering player's health amount, you can do it easily by changing player's health server-side, as Minecraft uses DataWatcher for updating entities' health to client, which is not the same as the ordinary way using packets.
August 30, 201411 yr Author I'm creating a mod that is completely client side so modding the server side is not an option. I'm not altering the players health, I'm acting based on the current (nothing with the player itself).
August 31, 201411 yr Hi Yes I think there is a way; use ASM + Reflection to edit the vanilla handler for the packet you're interested in. Apart from that, I don't know of any way to intercept packets before vanilla gets hold of them for processing. -TGG
August 31, 201411 yr Author Could you give an example of that? I'm not experienced with the reflection api..
August 31, 201411 yr Could you give an example of that? I'm not experienced with the reflection api.. Unfortunately, I'm not experienced with it either, never had to use it This tutorial will probably help http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571568-tutorial-1-6-2-changing-vanilla-without-editing It's for 1.6.2, I imagine the concepts are the same but you may need to do some more research to adapt it to 1.7. And to learn some bytecode, which will either be really interesting or a major headache depending on your reaction to something like this: 0: iconst_2 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 11: iload_2 12: iload_1 13: if_icmpge 31 I used to code in assembly so it looks like fun to me, but you might not agree -TGG
August 31, 201411 yr Don't intercept packets. Why do you think you need to? Also: Client-only mods still need to worry about servers. SP uses a Server as well. He wants to get notified of health changes client-side. I don't know if there is a way to get notified from the DataWatcher without coremods, I've never used it. I'm sure things other than health would need some vanilla packet handling which I'm not aware of whether it is possible or not. And the fact that SP uses a server doesn't make "logically" client-only mods in need to interact with it, it is client-side only...
August 31, 201411 yr since it's client only, can't he just have some sort of "old hp" variable that updates all the time, and when the update happens just do a check of "is new hp != old hp ? setHealthWithMessage(hp,"Health Changed") : setHealth(hp);" or would a simple alteration of one variable clog up the client's processing? Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
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.