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

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.

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

 

for your handler implement IMessageHandler and your message needs to implement IMessage. that will fix the problem with not applicable args

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.

 

 

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

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.