Posted May 6, 20205 yr 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
May 6, 20205 yr 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!
May 7, 20205 yr 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
May 9, 20205 yr 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
May 9, 20205 yr 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.