Tile Entities syncing
Keridos opened this issue ยท 2 comments
As far as I know tile entities do not need to sync their state to the client unless:
- They need the nbt for rendering
- The need the nbt for GUI stuff
Since neither of this points except for the GUI stuff is valid for the DSU, we can safely remove all of the (manual) sync data methods within the tile entity itself. Just getDescriptionPacket() and the rest that is called automatically by forge should be left in, but not manually called, except in cases where we absolutely need it (like in the GUI Container). Should basically fix the network usage to be almost 0 unless when the user has the GUI open. Then we should send stuff just to the client, that has the GUI opened. this can be done from inside the container (the server side class for the GUI) in detectAndSendChanges(). Just call super there and then add in a snipped of code that sends the nbt data to the connected client. That way you just have traffic when the GUI is opened.
This is an example from one of my mods, though this uses a SimpleImpl network handler and a custom message. In QuantumStorage you should be able to to ((EntityPlayerMP)listener).connections.sendPacket(tileEntity.getDescriptionPacket())
instead of the networkinghandler method. :
for (IContainerListener listener:listeners){ if (listener instanceof EntityPlayerMP) { PacketHandler.INSTANCE.sendTo(new MessageTileEntityFL(electricFloodlight)(EntityPlayerMP) listener);
The biggest reason for syncing atm is just waila support and that all the restocking is on the server side