Posted August 8, 201510 yr Hey everyone, I'm trying to get a server to send a packet to a client using the 250'th packet. When the packet is reached the client starts music from the url given in the packet. I'm having trouble coding the part where the client handles the packet. I'm trying to use the registerMessage method however to no avail. This is my code: package org.midnightas.novarp; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = NovaMod.MODID, version = NovaMod.VERSION) public class NovaMod { public static final String MODID = "novamod"; public static final String VERSION = "1.0"; public static SimpleNetworkWrapper wrapper; @EventHandler public void init(FMLPreInitializationEvent event) { wrapper = NetworkRegistry.INSTANCE.newSimpleChannel("novachannel"); wrapper.registerMessage(PacketNovaHandler.class, PacketNova.class, 0, Side.CLIENT); } } ( I do have the PacketNovaHandler class and the PacketNova class (they do not have syntax errors) ) I receive this message at the registerMessage method: The method registerMessage(Class<? extends IMessageHandler<REQ,REPLY>>, Class<REQ>, int, Side) in the type SimpleNetworkWrapper is not applicable for the arguments (Class<PacketNovaHandler>, Class<PacketNova>, int, Side) I didn't know there were more generics here ;( How would I fix that?
August 8, 201510 yr registerMessage of SimpleNetworkWrapper is designed for IMessages. You are not supposed to use 250th packet (which I am assuming you do, from you post) - it's old vanilla technique http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with http://www.minecraftforge.net/forum/index.php/topic,20135.0.html 1.7.10 is no longer supported by forge, you are on your own.
August 9, 201510 yr Author If that is so, how would I get Forge and Bukkit to communicate? (PS. I already saw those 2 tutorials, I'm doing this off of diesiebens one. Here are the codes (They are in 2 different files): // Packet package org.midnightas.novarp; import io.netty.buffer.ByteBuf; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class PacketNova implements IMessage { @Override public void fromBytes(ByteBuf bb) { } @Override public void toBytes(ByteBuf bb) { } } // Packet Handler package org.midnightas.novarp; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class PacketNovaHandler<REQ extends IMessage, REPLY extends IMessage> implements IMessageHandler<REQ, REPLY> { @Override public REPLY onMessage(REQ req, MessageContext c) { return null; } } If I change this line: public class PacketNovaHandler<REQ extends IMessage, REPLY extends IMessage> implements IMessageHandler<REQ, REPLY> { to this: public class PacketNovaHandler<REQ, REPLY> implements IMessageHandler<REQ, REPLY> { I get this error on both REQ and REPLY next to IMessageHandler: Bound mismatch: The type (REQ/REPLY) is not a valid substitute for the bounded parameter <(REQ/REPLY) extends IMessage> of the type IMessageHandler<REQ,REPLY>
August 9, 201510 yr Author I copy pasted your code thinking I did something wrong and nope. I'm back at problem 1.
August 9, 201510 yr for your handler implement IMessageHandler and your message needs to implement IMessage. that will fix the problem with not applicable args
August 9, 201510 yr I copy pasted your code thinking I did something wrong and nope. I'm back at problem 1. Sorry that I answered on your first problem.
August 9, 201510 yr Author Show your attempts. "It doesn't work" does not allow us to help you in any way shape or form. I told you, I'm back at problem 1: The method registerMessage(Class<? extends IMessageHandler<REQ,REPLY>>, Class<REQ>, int, Side) in the type SimpleNetworkWrapper is not applicable for the arguments (Class<PacketNova.Handler>, Class<PacketNova>, int, Side)
August 9, 201510 yr Author NovaMod.java: http://pastebin.com/Q00rCHD0 PacketNova.java: http://pastebin.com/duvJ3NDb I compressed the handler into the packet class.
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.