Closed drzpk closed 6 years ago
Its worth noting that TileNBTContainer's update method should only be hit as a last resort, if that inst the case then there are other issue to look into.
Looks like the method responsible for creating composite tile entity returns null
only when a TileNBTContainer
is empty:
val newTile = TileMultipart.createFromNBT(tag)
Shouldn't a container block just be removed in such cases? There's no point in keeping them empty.
Besides, after more thorough analysis I'm pretty sure that calling World.removeTileEntity
is the source of the issue I've been experiencing:
TileNBTContainer
wishes to remove tile entity without removing its container.World
calls Block.onNeighborChange
event on adjacent blocks.BlockMultipart
receives the event and wants to get the TileMultipart
instance.World.getTileEntity
)BlockMultipart
s are adjacent (i.e. they're cables), the whole procedure starts over.I think i have a cleaner fix for this. Give me a few to write it up.
I believe https://gist.github.com/covers1624/99eed3a286820de14146730bf19025f6 should fix the problem, It covers all edge cases you pointed out. https://cdn.discordapp.com/attachments/159971888485892096/476441440440942602/ForgeMultipart-1.12.2-2.5.0.null-universal.jar
Please verify.
I can confirm that almost everything works properly now.
But there's one minor problem left: log is being flooded with these messages:
SavedMultipart at BlockPos{x, y, z} still exists after 600 ticks!
It's caused by multipart tile entities that disappeared during game update (1.10 -> 1.12), but their container is still there. Why the container block can't be removed when this happens? I just checked few of these phantom blocks im McEdit and their NBT tags are empty (don't contain any parts).
Hmm, i guess its safe to set those blocks to air then. Please try this build: https://cdn.discordapp.com/attachments/159971888485892096/476456361891201035/ForgeMultipart-1.12.2-2.5.0.null-universal.jar Here's the patch incase you were curious: https://gist.github.com/cc67011b05660e93e05dbde71065aa32
As far as I can tell, problem is solved.
Thank you for dealing with this issue so quickly.
No problem, Suppressed by https://github.com/TheCBProject/ForgeMultipart/commit/c6a0dcf4d3e283adbd4fbb9e9813a6d6c3398418
Also, Thanks for your effort here, even though i ended up with a slightly different implementation.
In the issue #40 I've written that there was a massive lag caused by the fix you provided. I figured out what was causing it.
The issue was occurring only when a saved multipart tile entity couldn't be loaded properly. Take look at the TileNBTContainer.update method: when the variable
newTile
isnull
, tile entity should removed from world. But somehow it isn't (I have no idea why). The problem is that none of the conditions (failed
andloaded
) is changed afterwards and a tile entity is being removed 20 times per second. Note that every time theWorld.removeTileEntity
method is called (even if that tile doesn't exist anymore) container block's neighbors get notified. Multiply this by a large amount of corrupted multipart tile entities (in my case after update 1.10 to 1.12) and you've got a lag.