Commit Graph

6 Commits

Author SHA1 Message Date
Aikar
e0ea2e0e14
Entity Activation Range 2.0! Major improvements to restoring behavior
Calling this 2.0 as it's a pretty major improvement with more knobs to twist.

This update fixes many things. The goal here is to restore vanilla behavior to some degree.
Instead of permanent inactive pools of animals, let them show some signs of life some....

Yes this may reduce performance compared to before, but I hope it is minimal. Got to find a balance.
Previous EAR logic really compromised vanilla behavior of mobs. This tries to restore it.

Changes:

1) All monsters are now classed as Monster. Mojang has an interface, we should use it.
   - This now includes Shulker, Slimes, see #2 for Phantom and Ghast
2) Villagers and Flying Monsters now have their own separate activation range configs.
   - Villagers will default to your Animals config
3) Added a bunch of more immunities
   - Brand new entities are immune for a few seconds
   - Entities that recently traveled by portal are immune for few seconds
   - Entities that are leashed to a player are immune
   - Ender Signals are immune
   - Entities that are jumping, climbing, dying (lol) are immune
   - Minecarts are now always immune to the movement restriction
4) Villagers immunity received major overhaul...
   - Now has many immunities for Villager activities to let them
     do their work then go back inactive
   - Such as interacting with doors and workstations should be more normal now
   - Raids will trigger immunities, in that villagers will run and hide when bell rings.
   - Raid should keep the entire village immune during the raid to keep gameplay mechanics
     You can disable raids by game rule if you dont want raids

Then the big one.....

Wake Up Inactive Entities:
One issue plagueing "farms" is that we no longer even let entities move now.
Entities become lifeless.

A new system has been introduced to wake up inactive entities every so often, to let
them stretch their legs, eat some food, play with each other and experience the good entity life.

Animals, Villagers, Monsters (Includes Pillagers), and Flying Monsters will now wake up every
so often after staying inactive for a very long. This grants them a temporary immunity, that
the goal is they will then find "stuff to do" by having a longer activity window.

How many to wake up, how often they wake up, and for how long they wake up are all configurable.

Current EAR Immunities really don't give some entities enough of a window to find work
to then keep them immune for the work to even start. This system should help that.

We will only wake up a few entities per tick on the first wave, restoring 1 per type per world per tick.

So say you have 10 monsters qualify for inactive wake up, all 8 will wake up on the first eligible tick,
and then the 9th will wake up on next tick, 10th on next tick.

If for 5 ticks no more inactive wake up, our buffer will have built back up to 5, and then 5 can go next needed tick.

This basically incrementally wakes them up, preventing too many from waking up in a single tick, to reduce impact to TPS.
2020-04-27 01:22:44 -04:00
Aikar
fcf89e852e
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.

Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.

This guarantees that your chunk will load with at most around 1ms delay.

Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...

Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.

Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.

This is now fixed.

Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.

Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".

This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.

It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.

We solve this by ensuring new additions do not enter the currently iterated queue.

Each depth level will have its own queue.

Fixes #3220
2020-04-26 01:14:52 -04:00
Aikar
0106485ccb
Improvements to watchdog changes
catch a thread death, fix invalid watchdog timeouts

<= 0 seconds will now change to 5 minutes.
2020-04-24 00:27:50 -04:00
Aikar
65934b1fec
Fix build for last commit. 5am commits are great 2020-04-23 04:53:20 -04:00
Aikar
3f4360296c
Don't process watchdog until server has fully started and ticked.
I think adjusting watchdog settings may of caused instant crashes.

Fixes #3209
2020-04-23 04:49:41 -04:00
Ytnoos
bf698865f7
Revert "Re-track players that dismount from other players" 2020-04-22 03:16:31 -04:00