Nature's Aura

Nature's Aura

19M Downloads

Memory allocation lag in BlockAnimalGenerator

LemADEC opened this issue ยท 0 comments

commented

As of NaturesAura-18.1, about 1% of server CPU load is due to BlockAnimalGenerator.onLivingUpdate().
This event is called every tick for every living entity to update NBT "time_alive" integer.
From a quick code review:

  • the key name is constantly recreated. Consider using a static string to hold the key names.
  • the "time_alive" tick count doesn't really need tick resolution. Consider only updating it every 20 ticks to save some CPU load in NBT handling.
    More importantly, there's already an Entity. tickExisted (or NBT "Age" integer) that seems to do the same thing.