GlobbyPotato / Rockhounding_Chemistry

The purpose of Rockhounding Chemistry is to assembly and maintain an industrial area in which several machines handle various types of ingredients (solid, fluid and gaseous) to produce advanced material for mid-late game stages. It also leads to several features, functional applications and experiments.
Other
15 stars 17 forks source link

Machines cause excessive chunk updates #87

Open codewarrior0 opened 5 years ago

codewarrior0 commented 5 years ago

image

(This is almost certainly an FPS issue for players whose computers aren't of the same caliber as mine, and is probably related to an intermittent issue where the visuals for those chunks simply disappear.)

This is way too many chunk updates for a bunch of blocks that are basically unchanging. The tree farm munchdew-based mana farm that eats ten leaves per second on the other side of my base maxes out at 60 chunk updates.

A quick look with a decompiler (why aren't you publishing your sources any more, btw?) shows that a method in rockhounding_core named markDirtyClient is calling worldObj.notifyBlockUpdate, which causes the chunk to be redrawn and also syncs the TileEntity to the client.

Those two concerns need to be separated. The chunk should only be redrawn whenever a blockstate actually changes (such as when the connections on a gas or fluid pipeline change). Similarly, the TileEntity should only be synced whenever the TileEntitySpecialRenderer needs to show updated visuals (such as when the fluid type or amount in a visible tank changes, or a moving bit like a crushing gear or fluid agitator starts or stops moving), or when the visuals in an open GUI need to be updated (e.g. power buffers and machine progress).

The recommended solution is to explicitly send a SPacketUpdateTileEntity to all interested players whenever TileEntity data should be synced but a chunk update is not needed. As an example, here is how ActuallyAdditions does it - it leverages the existing getUpdatePacket method to send the update packet without triggering a chunk update via worldObj.notifyBlockUpdate. (ActuallyAdditions also has a bunch of logic to separate data that must be saved to disk from data that only needs to be synced to clients - this helps to cut down on network traffic)

rockhounding_chemistry-1.12.2-3.30.jar

wormzjl commented 5 years ago

That explains the weird lag I've encountered last time...

wormzjl commented 5 years ago

Allright, this issue is getting really serious for me.

In regions with extensive RH installations on my server, fps could drop to less than 1 when approaching. I was forced to nuke these regions to prevent players from lagging to death.

I think this is the most important issue for rockhounding in order to be used in modpacks, since the performance hit is too significant.