
The client receives and renders all facades present in the world
SuperMartijn642 opened this issue ยท 6 comments
Currently, the server stores all facades present in a world in a map. The entire contents of that map are sent to the client when a player joins. This means facades anywhere in the world are sent to the client.
This may lead to a lot of network traffic and excessive memory usage (or at least more than necessary) on the client.
Additionally, since the client does not check the distance of facades in the client's map when rendering them. Every facade in the client's field of view, no matter the distance, gets rendered.
Ideally, the facades would be indexed per chunk on the server and only facades for chunks tracked by the client would be sent to the client. This could be achieved by storing a Map<ChunkPos,Map<BlockPos,Block>>
on the server per world or storing a Map<BlockPos,Block>
on chunks which have at least one facade, and then sending facades for the respective chunk during the ChunkWatchEvent#Watch
event.
The client would then also store facades in a Map<ChunkPos,Map<BlockPos,Block>>
and clear facades for the respective chunk during the ChunkWatchEvent#UnWatch
event.
Additionally, the RemoveCamoPacket
packet is currently send to all players on the server no matter the dimension or location of the player whenever a facade is removed because the block it is on is removed.
If the proposed changes are made such that the client only stores facades for chunks it tracks, the remove packet should also be sent to just the players tracking the respective chunk. This can be done by using the
PacketDistributor#TRACKING_CHUNK
target.This explains the lag I was having when I tested the mod. A lot of very small, but very frequent frame drops. Removing the facades helped, but the frame drops were still there, for some reason, After I removed the mod, the lag was gone
I just updated to version 1.0.5 and so far it looks like the performance has been improved significantly!