getPoppet() seems to be causing heavy chunkloads.
TheGrimsey opened this issue ยท 4 comments
moriyashiine.bewitchment.api.BewitchmentAPI.getPoppet()
seems to be loading chunks that are then almost instantly unloaded again by the server causing lag spikes.
Based on this spark report: https://spark.lucko.me/tHGlHv3eZ6
(Switch from all to sources at the top)
This issue just recently appeared as a server member began messing with Bewitchment
Alright, I've got it working without having to load chunks at all and just need to do some testing :)
This is caused by Poppet Shelves and isn't really avoidable due to how they work. I can attempt a fix that involves storing the entire shelf in the world, but this isn't ideal either. Can you see what the difference is if there are no Poppet Shelves in the world?
This is a spark report after removing all poppet shelves:
https://spark.lucko.me/xpxhuSby84
I have a question though and perhaps a suggestion:
Normally can anything but a player have a poppet?
Related to this bit of code
You only check if it is a player for the first condition. If players are the only ones who could reasonably have poppets you could just add a return condition if this isn't a player like how you exit out for client worlds.
You also get the poppet again for every if-statement so it passes multiple conditions you will go and grab the poppet again. Since the chunks are already loaded at this point it doesn't matter much but it's another full linear search.