Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.?

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.

  • 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).

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

  • Author

Could you give an example of that? I'm not experienced with the reflection api..

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

ย 

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...

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.