Haven-King / FibLib

A Fabric library for sending false data to clients.
Creative Commons Zero v1.0 Universal
17 stars 11 forks source link

Fibbing Packet Crash #1

Closed Haven-King closed 4 years ago

Haven-King commented 4 years ago

I'm not 100% sure what causes this crash, and have spent many hours trying to fix it. If you are smarter than me and have an idea, please try it!

The exception produced is as follows: crash-2020-04-09_18.59.30-server.txt

A chunk update with high variance (greater than 9 different kinds of blocks. See PalettedContainer#setPaletteSize) will use Minecraft's built in Block.STATE_IDS as its palette. This palette uses ID numbers to represent states that can be quite large (up to 11337, to be exact) which usually isn't a problem. When replacing a lot of low ID numbers with high ID numbers (GRASS_BLOCK#9 to GLOWSTONE#3999 for instance) the packet buffer is overwhelmed.

One way that might be able to fix this error is to just use BiMapPalette's for all Chunk updates, though this sounds like it's pretty likely to break the game.

i509VCB commented 4 years ago

I think you might have to "fix" the packet before it's even created. The easiest option would be to give the packet a fake PalettedContainer before the packet calls write (not sure if it's feasible)

Cloning a paletted container should be related to a few methods in NbtHelper and maybe 2 accessors to change some stuff