(SOLVED) Extreme lag when using find path on entity tick update

Started by ManuehTheModder405 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(SOLVED) Extreme lag when using find path on entity tick update
Fri, 03/29/2024 - 12:08 (edited)

In my mod there's an entity that always track the player, the problem is that i need to use the procedure "find path movement to (x,y,z) with speed...",  i have to put it into entity tick update, and im not the only one because i've seen in other posts that other people does/recommends it, but when i do it i suffer lag spikes every time the mob moves (cause is a weeping angel), i don't know if only happens to me, i tried increasing the ram to 8000mb but still the same, does anyone know about this or has suffered the same bug?

Edited by ManuehTheModder405 on Fri, 03/29/2024 - 12:08
Calling this every tick will…
Mon, 03/25/2024 - 18:06

Calling this every tick will lag a lot. The procedure is very heavyweight and it can't be executed on every tick as this will overload computer resources

Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've already noticed that…
Mon, 03/25/2024 - 18:21

I've already noticed that something was wrong about the tick update, but when every post that i found said that this must be inside it and made me doubt and try it. Thanks, i will try another way to do it ;)

One way would be to only run…
Tue, 03/26/2024 - 18:23

One way would be to only run the procedure every N ticks, say 100 ticks and cache the value in-between somehow

Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've done something…
Fri, 03/29/2024 - 12:08

I've done something different before reading your answer but I realized that your way is more optimized than using a global value that updates every tick, I'm going to try it, thank you so much :D