Darkhax-Minecraft / BotanyPots

Adds some flower pots that can be used to grow various crops.
GNU Lesser General Public License v2.1
102 stars 77 forks source link

[BUG] Massive lags in 1.18.2 #431

Open Sabbelchen opened 2 months ago

Sabbelchen commented 2 months ago

Minecraft Version

1.18.2

Mod Version

8.1.29

Mod Loader

Forge

What environment are you running the mod in?

Dedicated Server

Issue Description

Hello,

we use a dedicated server for 5 people and we using a lot of Botany Pots. Now the server is extrem lagging because the mod is generating a lot of ticks. Without the Botany Pots everything is fine. I have used Spark with the same world but on a local server because I can't upload this mod on the actual live server at the moment.

Here you ca find the Spark Report

What can I do to stop the lags? There is no real good alternative to your mod so it would be really really sad to delete the mod.

MUYUTwilighter commented 1 month ago

I think this issue have many similarities with #421

MUYUTwilighter commented 1 month ago

The server lag is probably due to tickly invoked pot.getInventory().update(); in BlockEntityBotanyPot, where the update method would iterate all the crop & soil recipes by invoking BotanyPotHelper.findSoil and BotanyPotHelper.findCrop in BotanyPotContainer.update. I think there should be a check on whether the iteration is really necessary. Here is my solution. https://github.com/MUYUTwilighter/BotanyPotsFix/blob/master/src/main/java/cool/muyucloud/botanypotsfix/mixin/BotanyPotContainerMixin.java#L48