McJtyMods / TheOneProbe

This simple mod adds a probe and an API for other mods to show information with that probe
MIT License
137 stars 69 forks source link

[Info/Bug] NetworkTools writes items weird. #543

Closed Speiger closed 2 years ago

Speiger commented 2 years ago

https://github.com/McJtyMods/TheOneProbe/blob/1.16/src/main/java/mcjty/theoneprobe/network/NetworkTools.java#L24

You are aware that PacketBuffer.writeItem() exists? That has specially optimized network code that has less overhead then writing a CompoundNBT that is not even compressed? Instead of sending 1 varInt, 1 byte, and If NBT exist NBT you are sending a lot of extra data over. Including wrapper data that shouldn't even be synced?

Is a thing 1.16-1.18.

Just a service issue.

McJty commented 2 years ago

The problem with PacketBuffer.writeItem() is that it only writes the count as a byte. My routine is meant for cases where you want counts that are larger. i.e. like when TOP wants to show the total amount of some item in a chest. That's why this function exists

Speiger commented 2 years ago

@McJty yes but it is much more efficient then your "writeNBT + writeInt" variant. What i ask you is to: "writeItem + writeInt" instead.

That way you are not sending to much Junk Over. But only have 1 byte of waste. Instead of 50 bytes of waste.

McJty commented 2 years ago

Ok I can do that

McJty commented 2 years ago

Fixed