Jump to content

SimpleNetworkWrapper.registerMessage has arguments that are not applicable.


BadBoy6767

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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