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

I created a Networkchannel, that is working just fine, and a IMessage and its Handler.

I am triing to send an integer over the channel, shorts are working no problem. The message is registered, but if I try to send it I get a strange exception.

 

 

 

[08:38:56] [Netty Local Client IO #0/ERROR] [FML]: There was a critical exception handling a packet on channel TriamChannel

io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: Varint length is between 1 and 5, not 16

at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:4.0.15.Final]

at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:338) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:324) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:4.0.15.Final]

at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:4.0.15.Final]

at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:88) [FMLProxyPacket.class:?]

at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:144) [NetworkManager.class:?]

at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:469) [NetworkManager.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103) [simpleChannelInboundHandler.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:338) [DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:324) [DefaultChannelHandlerContext.class:4.0.15.Final]

at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:363) [NetworkDispatcher.class:?]

at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:230) [NetworkDispatcher.class:?]

at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:49) [NetworkDispatcher.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103) [simpleChannelInboundHandler.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:338) [DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:324) [DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:4.0.15.Final]

at io.netty.channel.local.LocalChannel.finishPeerRead(LocalChannel.java:312) [LocalChannel.class:4.0.15.Final]

at io.netty.channel.local.LocalChannel.access$400(LocalChannel.java:44) [LocalChannel.class:4.0.15.Final]

at io.netty.channel.local.LocalChannel$6.run(LocalChannel.java:298) [LocalChannel$6.class:4.0.15.Final]

at io.netty.channel.local.LocalEventLoop.run(LocalEventLoop.java:33) [LocalEventLoop.class:4.0.15.Final]

at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:4.0.15.Final]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]

 

 

 

 

Message and Handler class

 

public class ActualEnergyMessage implements IMessage{

private int actualEnergy;

public ActualEnergyMessage() {

}

public ActualEnergyMessage(int actualEnergy) {
	this.actualEnergy = actualEnergy;
}

@Override
public void fromBytes(ByteBuf buf) {
	actualEnergy = ByteBufUtils.readVarInt(buf, 16);

}

@Override
public void toBytes(ByteBuf buf) {
	ByteBufUtils.writeVarInt(buf, actualEnergy, 16);

}


public static class Handler implements IMessageHandler<ActualEnergyMessage, IMessage> {

	@Override
	public IMessage onMessage(ActualEnergyMessage message,
			MessageContext ctx) {
		((ExtendedPlayer)(Minecraft.getMinecraft().thePlayer.getExtendedProperties(ExtendedPlayer.EXT_PROP_NAME))).setActualEnergy(message.actualEnergy);
		return null;
	}

}

}

It literally says in the top line...

 

[08:38:56] [Netty Local Client IO #0/ERROR] [FML]: There was a critical exception handling a packet on channel TriamChannel
io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: Varint length is between 1 and 5, not 16

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

  • Author

I just got it. I was reading bits all the time but it says bytes. Still thank you

Network messages are hard to get right in 1.8 because of multithreading.

 

This guide might help

http://greyminecraftcoder.blogspot.com.au/2015/01/the-client-server-division.html

especially

http://greyminecraftcoder.blogspot.com.au/2015/01/client-server-communication-using-your.html

and

http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html

 

Also this tutorial project which has a working example of network messages (MBE60)

https://github.com/TheGreyGhost/MinecraftByExample

 

-TGG

 

  • Author

So. Just so I dont get this wrong.

The important part is that I queue up the processing of the message to the queue from minecraft

  minecraft.addScheduledTask(new Runnable()
    {
      public void run() {
        processMessage(worldClient, message);
      }
    });

Right?

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.