VVV101 / AlchemistNPCLite

Lite version of AlchemistNPC mod
8 stars 10 forks source link

LifeformAnalyzer feature causes massive lag in multiplayer #4

Open JavidPack opened 3 years ago

JavidPack commented 3 years ago

https://github.com/VVV101/AlchemistNPCLite/blob/f3673369039ab9e9eca8caaafbe0a208f4801faf/Items/AlchemistGlobalItem.cs#L32-L52

This code, found in a GlobalItem.UpdateInventory hook, has many issues. The biggest issue is that GlobalItem.UpdateInventory runs for each item in the inventory, so this code runs 50 times at once, every second. In multiplayer, this results in 50 projectiles spawning and syncing over the network for each rare creature, each second. The other big issue is that using a Projectile for this is definitely not the right approach. Just draw the arrows manually in any hook that allows drawing.

To replicate, simply spawn a few mimics on a multiplayer game.

If you come across this issue and want to fix the issue on your end, simply disable the LifeformAnalyzer feature in the config.