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

Hey, I'm trying to track the packets received. I can't find an event for that, so I tried overwriting the NetworkManager of Minecraft#getConnection

The mod is a clientside mod. 

public void onSetup(FMLCommonSetupEvent event) {
		ObfuscationReflectionHelper.setPrivateValue(ClientPlayNetHandler.class, Minecraft.getInstance().getConnection(),
				new CustomNetworkHandler(PacketDirection.CLIENTBOUND), "field_147371_a");
	}
package me.cirex.ditzydisplay.clientchannel;

import net.minecraft.network.IPacket;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.PacketDirection;

public class CustomNetworkHandler extends NetworkManager {

	public CustomNetworkHandler(PacketDirection packetDirection) {
		super(packetDirection);
		System.out.println("test");
	}

	@Override
	public void sendPacket(IPacket<?> packetIn) {
		System.out.println("test");
		super.sendPacket(packetIn);
	}

	@Override
	public void tick() {
		super.tick();
		System.out.println("test");
	}
}

This is my code. I don't get an errror, but I don't get any sysouts either

If it's a client-only mod, you should definitely put this in the ClientSetupEvent, so you don't run the risk of strange missing class errors. There are also fields in the NetworkManager class that don't get initialized in the constructor. You may want to either scrape all the fields from the original instance of NetworkManager and copy them to your custom class or try to do something similar to the ClientPlayNetHandler.

Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!

  • Author
1 hour ago, Vinyarion said:

If it's a client-only mod, you should definitely put this in the ClientSetupEvent, so you don't run the risk of strange missing class errors. There are also fields in the NetworkManager class that don't get initialized in the constructor. You may want to either scrape all the fields from the original instance of NetworkManager and copy them to your custom class or try to do something similar to the ClientPlayNetHandler.

Oh yea, I had it in the ClientSetupEvent, I changed it for some reason. I'll try that out, will get back if I still need help :D

  • Author
On 5/7/2020 at 10:13 AM, diesieben07 said:

What are you trying to do? Messing with the network connection is almost always a bad idea.

Well, basically I'm trying to build up a connection between spigot and forge. I don't want to manipulate the packets or anything, just listen to them. 

I didn't figure it out yet, would be nice if you helped me

  • Author
2 hours ago, diesieben07 said:

Forge can connect to vanilla servers just fine. Since spigot acts as a vanilla server, no further action needs to be taken.

 

If that does not answer your question, you need to elaborate.

This doesn‘t answer my question. Basically I have a mod and if it gets specific packets its supposed to render specific models. So I want to make custom packets that the mod is listening to

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.