Jump to content

DecoderException: Packet was larger than I expected [1.7.2]


TeNNoX

Recommended Posts

After a while of playing/testing with my mod I got this exception:

 

 

Client> [14:32:06] [Netty Client IO #2/ERROR] [FML]: NetworkDispatcher exception
Client> io.netty.handler.codec.DecoderException: java.io.IOException: Packet was larger than I expected, found 41348 bytes extra whilst reading packet 53
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:263) ~[byteToMessageDecoder.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:131) ~[byteToMessageDecoder.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) [byteToMessageDecoder.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:149) [ReadTimeoutHandler.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
Client> 	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100) [AbstractNioByteChannel$NioByteUnsafe.class:?]
Client> 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:480) [NioEventLoop.class:?]
Client> 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:447) [NioEventLoop.class:?]
Client> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:341) [NioEventLoop.class:?]
Client> 	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?]
Client> 	at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
Client> Caused by: java.io.IOException: Packet was larger than I expected, found 41348 bytes extra whilst reading packet 53
Client> 	at net.minecraft.util.MessageDeserializer.decode(SourceFile:35) ~[eq.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:232) ~[byteToMessageDecoder.class:?]
Client> 	... 16 more
Client> [14:32:06] [Netty Client IO #2/ERROR] [FML]: NetworkDispatcher exception
Client> io.netty.handler.codec.DecoderException: java.io.IOException: Packet was larger than I expected, found 41339 bytes extra whilst reading packet 31
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:263) ~[byteToMessageDecoder.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:196) ~[byteToMessageDecoder.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:214) [byteToMessageDecoder.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [ChannelInboundHandlerAdapter.class:?]
Client> 	at io.netty.handler.timeout.ReadTimeoutHandler.channelInactive(ReadTimeoutHandler.java:143) [ReadTimeoutHandler.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
Client> 	at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:767) [DefaultChannelPipeline.class:?]
Client> 	at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:558) [AbstractChannel$AbstractUnsafe$5.class:?]
Client> 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [singleThreadEventExecutor.class:?]
Client> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348) [NioEventLoop.class:?]
Client> 	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?]
Client> 	at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
Client> Caused by: java.io.IOException: Packet was larger than I expected, found 41339 bytes extra whilst reading packet 31
Client> 	at net.minecraft.util.MessageDeserializer.decode(SourceFile:35) ~[eq.class:?]
Client> 	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:232) ~[byteToMessageDecoder.class:?]
Client> 	... 16 more
Client> [14:32:19] [Client thread/INFO]: Stopping!
Client> 
Client> SoundSystem shutting down...
Client>     Author: Paul Lamb, www.paulscode.com

 

 

The only packet I send that COULD be larger that 32k is my Item counter, but the only time it sends a packet is a NBT description packet like this:

 

getDescriptionPacket:

NBTTagCompound nbttagcompound = new NBTTagCompound();
writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);

 

writeToNBT:

super.writeToNBT(nbttagcompound);
NBTTagCompound nbt = new NBTTagCompound();

nbt.setInteger("countedsize", counted.size());
nbt.setInteger("countersize", counted.size());
nbt.setBoolean("doublecount", doublecount);
for (int i = 0; i < counted.size(); i++) {
nbt.setInteger("counted" + i, ((Integer) counted.get(i)).intValue());
}
Iterator it = counter.entrySet().iterator();
int i = 0;
while (it.hasNext()) {
Entry<int[], Integer> entry = (Entry) it.next();
nbt.setInteger("counter" + i + "_id", ((int[]) entry.getKey())[0]);
nbt.setInteger("counter" + i + "_damage", ((int[]) entry.getKey())[1]);
nbt.setInteger("counter" + i + "_count", ((Integer) entry.getValue()).intValue());
i++;
}
nbttagcompound.setTag("counterdata", nbt);

 

 

Any idea how to fix that one?

Link to comment
Share on other sites

You need to learn how to use NBT storage properly, such as NBTTagList and NBTTagCompound and how to properly record counts for things you put in there.

You cannot put arbitrary values in NBT tags and expect the receiver to know "know what you meant". It doesn't work that way. Check for typos. I doubt both the array/list and the map have the same # of elements.

Link to comment
Share on other sites

You need to learn how to use NBT storage properly, such as NBTTagList and NBTTagCompound and how to properly record counts for things you put in there.

You cannot put arbitrary values in NBT tags and expect the receiver to know "know what you meant". It doesn't work that way. Check for typos. I doubt both the array/list and the map have the same # of elements.

 

The value saving and loading works perfectly. It's not perfectly coded but it works. The problem I have is a different one:

The error that a "Packet was larger than I expected" ... (see the error in the main post) I just put my code because I THINK it could be that the packet I create there is too large.

Any other advice?

Link to comment
Share on other sites

You can send NBT data, that is unlikely the issue here.

What you should worry about is the map size you are trying to send over.

The "counter" map should be kept under a maximum size.

 

As sequituri said, you might have left some typo too:

nbt.setInteger("countedsize", counted.size());
nbt.setInteger("countersize", counted.size());

Twice the same data under a different tag is unlikely to be what you want.

Link to comment
Share on other sites

You can send NBT data, that is unlikely the issue here.

What you should worry about is the map size you are trying to send over.

The "counter" map should be kept under a maximum size.

So how do I keep it under a maximum size (and how high would that be?) when I want to count all items?

 

Another thing: Is it possible that the error is Minecraft-related, and not an error in my mod?

Because at the stage where it crashes I didn't count that many items at all...

 

As sequituri said, you might have left some typo too

Twice the same data under a different tag is unlikely to be what you want.

 

Yep, thanks :D

Link to comment
Share on other sites

Tennox, dude! Are you blind, you've been told by me, and now shown your typing error. Don't blame stupidity or blindness on Minecraft or Forge! It's in the quote Gotolink posted.

Link to comment
Share on other sites

Tennox, dude! Are you blind, you've been told by me, and now shown your typing error. Don't blame stupidity or blindness on Minecraft or Forge! It's in the quote Gotolink posted.

 

I don't want to be offensive in any way, but that doesn't help me... I get the same error without even saving the nbt stuff...

Please please help me, ignore the nbt stuff I posted, I fixed the typo. Just look at the error and could you tell me some tip or advice on fixing that one?

Link to comment
Share on other sites

How/When do you send your packet then ?

 

At first, I am not sure which of my packets would cause the problem, would be nice if I could find that out, but I can't place Breakpoints in the Minecraft compiled code :/

(I am also not sure if my packets ARE the problem, but I think they are)

 

I thought, which of my packets could be so big, that it would be too big.. the only packet that came to my mind is the NBT Packet which I send when Minecraft calls getDescriptionPacket(...), because I put all NBT stuff in there. In the NBT there are 2 arrays stored, the first contains the count of items traversed per type and the second one the entityId's of the items traversed.

(All this never caused an error in 1.6 or earlier, and I counted MANY items!)

 

So my question is, Could this packet be the problem? If yes, how can I fix it? If no, how can I find out which packet is causing the problem?

Link to comment
Share on other sites

Okay, so post your new code (where the typo was) and your  log, so we can debug for you. Other than that, I cannot guess your issue or help in any other way.

 

If you cannot be cooperative and at least try to work with people, people will start giving up on you.

Link to comment
Share on other sites

Okay, so post your new code (where the typo was) and your  log, so we can debug for you. Other than that, I cannot guess your issue or help in any other way.

If you cannot be cooperative and at least try to work with people, people will start giving up on you.

 

Thank you for trying to work with me :)

 

The error log:

 

[18:05:19] [Client thread/INFO] [FML]: [Client thread] Client side modded connection established
[18:05:20] [Netty Client IO #1/ERROR] [FML]: NetworkDispatcher exception
io.netty.handler.codec.DecoderException: net.minecraft.util.ReportedException: Loading NBT data
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:263) ~[byteToMessageDecoder.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:131) ~[byteToMessageDecoder.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) [byteToMessageDecoder.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:149) [ReadTimeoutHandler.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100) [AbstractNioByteChannel$NioByteUnsafe.class:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:480) [NioEventLoop.class:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:447) [NioEventLoop.class:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:341) [NioEventLoop.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
Caused by: net.minecraft.util.ReportedException: Loading NBT data
at net.minecraft.nbt.NBTTagCompound.func_150293_a(NBTTagCompound.java:522) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.load(NBTTagCompound.java:60) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.CompressedStreamTools.func_150664_a(CompressedStreamTools.java:171) ~[CompressedStreamTools.class:?]
at net.minecraft.nbt.CompressedStreamTools.read(CompressedStreamTools.java:128) ~[CompressedStreamTools.class:?]
at net.minecraft.nbt.CompressedStreamTools.decompress(CompressedStreamTools.java:70) ~[CompressedStreamTools.class:?]
at net.minecraft.network.PacketBuffer.readNBTTagCompoundFromBuffer(PacketBuffer.java:114) ~[PacketBuffer.class:?]
at net.minecraft.network.play.server.S35PacketUpdateTileEntity.readPacketData(S35PacketUpdateTileEntity.java:41) ~[s35PacketUpdateTileEntity.class:?]
at net.minecraft.util.MessageDeserializer.decode(MessageDeserializer.java:37) ~[MessageDeserializer.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:232) ~[byteToMessageDecoder.class:?]
... 16 more
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source) ~[?:1.7.0_51]
at java.util.zip.InflaterInputStream.read(Unknown Source) ~[?:1.7.0_51]
at java.util.zip.GZIPInputStream.read(Unknown Source) ~[?:1.7.0_51]
at java.io.BufferedInputStream.fill(Unknown Source) ~[?:1.7.0_51]
at java.io.BufferedInputStream.read1(Unknown Source) ~[?:1.7.0_51]
at java.io.BufferedInputStream.read(Unknown Source) ~[?:1.7.0_51]
at java.io.DataInputStream.readFully(Unknown Source) ~[?:1.7.0_51]
at java.io.DataInputStream.readUTF(Unknown Source) ~[?:1.7.0_51]
at java.io.DataInputStream.readUTF(Unknown Source) ~[?:1.7.0_51]
at net.minecraft.nbt.NBTTagCompound.func_150294_b(NBTTagCompound.java:504) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.load(NBTTagCompound.java:59) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.func_150293_a(NBTTagCompound.java:513) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.load(NBTTagCompound.java:60) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.CompressedStreamTools.func_150664_a(CompressedStreamTools.java:171) ~[CompressedStreamTools.class:?]
at net.minecraft.nbt.CompressedStreamTools.read(CompressedStreamTools.java:128) ~[CompressedStreamTools.class:?]
at net.minecraft.nbt.CompressedStreamTools.decompress(CompressedStreamTools.java:70) ~[CompressedStreamTools.class:?]
at net.minecraft.network.PacketBuffer.readNBTTagCompoundFromBuffer(PacketBuffer.java:114) ~[PacketBuffer.class:?]
at net.minecraft.network.play.server.S35PacketUpdateTileEntity.readPacketData(S35PacketUpdateTileEntity.java:41) ~[s35PacketUpdateTileEntity.class:?]
at net.minecraft.util.MessageDeserializer.decode(MessageDeserializer.java:37) ~[MessageDeserializer.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:232) ~[byteToMessageDecoder.class:?]
... 16 more
[18:05:20] [Netty Client IO #1/ERROR] [FML]: NetworkDispatcher exception
io.netty.handler.codec.DecoderException: java.io.IOException: Packet was larger than I expected, found 65528 bytes extra whilst reading packet 21
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:263) ~[byteToMessageDecoder.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:196) ~[byteToMessageDecoder.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:214) [byteToMessageDecoder.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [ChannelInboundHandlerAdapter.class:?]
at io.netty.handler.timeout.ReadTimeoutHandler.channelInactive(ReadTimeoutHandler.java:143) [ReadTimeoutHandler.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:237) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:223) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:767) [DefaultChannelPipeline.class:?]
at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:558) [AbstractChannel$AbstractUnsafe$5.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [singleThreadEventExecutor.class:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348) [NioEventLoop.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
Caused by: java.io.IOException: Packet was larger than I expected, found 65528 bytes extra whilst reading packet 21
at net.minecraft.util.MessageDeserializer.decode(MessageDeserializer.java:41) ~[MessageDeserializer.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:232) ~[byteToMessageDecoder.class:?]
... 16 more

 

 

My code (the important stuff, hope that's all you need)

http://pastebin.com/RL5WeXc7

 

Link to comment
Share on other sites

Your description packet has type 4 (4th argument) this indicates a vanilla TileEntityMobSpawner is the target of that description packet. That is probably why it doesn't like the length.

1 - TileEntityModSpawner

2 - TileEntityCommandBlock

3 - TileEntityBeacon

4 - TileEntitySkull

5 - TileEntityFlowerPot

 

Of course, your TE would need to use a different ID byte.

Link to comment
Share on other sites

Your description packet has type 4 (4th argument) this indicates a vanilla TileEntityMobSpawner is the target of that description packet. That is probably why it doesn't like the length.

1 - TileEntityModSpawner

2 - TileEntityCommandBlock

3 - TileEntityBeacon

4 - TileEntitySkull

5 - TileEntityFlowerPot

 

Of course, your TE would need to use a different ID byte.

 

Okay, and where should I register my TileEntity DesciptionPacket id? Can I just take 7?

Link to comment
Share on other sites

Yes. Anything that is not one of the reserved IDs will be sent directly to your TE to handle. So, if can't conflict as far as I can tell.

Link to comment
Share on other sites

Are you trying to load an old world ?

It isn't going to work with tile entity data being corrupted.

 

Okay, so it wasn't really fixed but I removed the list with entityIds that was getting bigger (found a better solution) and now I don't get the error even after counting 100.000 items.. :)

 

But after some time I got this error: (Bad packet id stuff)

http://pastebin.com/gus7Rcwq

 

What is this now? -.-

 

PS: Should I open a new Thread() for the new topic?

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.



×
×
  • Create New...

Important Information

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