Why is my datapack so laggy?
-
https://www.planetminecraft.com/data-pack/aceplante-s-rl-megapack-for-1-17/
For every single function I have added so far, I have been careful to add tag checks. For example, if I want to replace the held item of skeletons, I will only run that command at skeletons without the tag, then add it after so it doesn't run again.
So I am not sure why I am experiencing lag since as far as I can tell, everything is written as efficiently as possible. I tried debug but I do not seem to be getting a file as google claims I should.
I guess my question is what are some of the reasons it might be laggy? Is there a way I can find out what part of it specifically is causing the lag?
-
There are many many reasons why a datapack may be laggy, and it is hard to diagnose the issue(s) without knowing what it does. But, here are some common reasons that I can list off the top of my head:
- Too many entities (e.g. using too many armorstands)
- High usage of heavy entity selectors (e.g. using
@e
a high amount of times) - NBT (reading, writing, or accessing entity NBT data is extremely laggy. Like
execute if entity @e[nbt=...]
) - Large clone/fill commands
- Recursive functions, or in general, too many commands per tick (we're talking hundreds of thousands)