This may be invoked by a worldgen thread, in which case the
region data would be null and cause a crash. Returning true
is the default state of shouldSignal, so this should maintain
expected behavior.
The world tick will synchronise block data to clients. If
the connection tick is ran before, then the server will
send the block ack before the block updates - which causes
the client to think that any blocks it broke/placed
were rejected.
Fixes https://github.com/PaperMC/Folia/issues/194
The delta position packet instructs the client to update
the entity position by a position difference. However, this position
difference is relative to the last position in the entity tracker
state, not the last position which has been sent to the player. As
a result, if the last position the player has recorded is different
than the one stored in the entity tracker (which occurs when a new
player is added to an existing entity tracker state) then the sent
position difference will cause a position desync for the client.
We can resolve this problem by either tracking the last position
sent per-player, or by simply resetting the last sent position
in the entity tracker state every time a new player is added.
Resetting the last sent position every time a new player is
added to the tracker is just easier to do, so that is what
this patch does.
Fixes https://github.com/PaperMC/Folia/issues/197
The data both store are caches which are cleared after updates,
which means that there is no block/position data being tracked
across ticks. As long as each region has its own instance, there
should be no cross-region data access.
Fixes https://github.com/PaperMC/Folia/issues/202
Additionally, fix ActivationRange using global state to store
the AABBs it checks entities against. This fixes an issue where
entities would not be activated when they should be.
The non-game type implementation will not guard against double calls,
which means that any invocation of disconnect() would immediately
call onDisconnect and then later the connection handler would
also call onDisconnect.
Fixes https://github.com/PaperMC/Folia/pull/181
The region shift is configurable under `grid-exponent`, which
allows setting the region shift to any value in [0, 31]. Note
that values above 6 affect the lock shift, as the lock shift
currently is computed as max(ticket shift = 6, region shift).
The shift is left configurable for now as the lower default
shift of 2 may have negative performance impacts.
The default region shift has been adjusted to 2 from 4, and
the empty chunk buffer has been reduced to 8 from 16. These
changes reduce, but do not eliminate, player spread
requirements. The previous block range was around ~1500 blocks
at VD = 10, but is now closer to ~900 blocks at VD = 10. This
roughly reduces the area that each player uses in the regioniser
by 2.5x.
Currently, /tick is disabled but is planned to be re-added.
It's unlikely that support for sprinting can be implemented
precisely due to the fact that Folia ticks many regions
independently. However, a best-effort approach will be used.
Profiling for a region starts with the /profiler command.
The usage for /profiler:
/profiler <world> <block x> <block z> <time in s> [radius, default 100 blocks]
Any region within the radius of the specified block coordinates
will be profiled. The profiling will stop after the specified
time has passed.
Once the profiler finishes, it will place a report in
the directory ./profiler/<id>.
Since regions can split into smaller regions, or merge into
other regions, the profiler will track this information. If
a profiled region splits, then all of the regions it splits
into are attached to the same profiler instance. If a profiled
region merges into another region, then the merged region is
profiled. This information is tracked and logged into the
"journal.txt" file contained in the report directory. The
journal tracks the region ids for the merge/split operations.
Region profiling is placed into the "region-X.txt" file where
X is the region id inside the profile directory. The header
of the file describes some stats about the region, namely
total profiling duration, ticks, utilisation, TPS, and MSPT.
Then, the timing tree is follows. The format is as specified:
There are two types of data recorded: Timers and Counters.
Timers are specified as follows:
<indent><name> X% total, Y% parent, self A% total, self B% children, avg D sum E, Fms raw sum
The above specifies the format for a named timer.
The <indent> specifies the number of parent timers.
"X" represents the percentage of time the timer took relative
to the entire profiling instance.
"Y" represents the percentage of time the timer took relative
to its _parents_ timer. For example:
```
Full Tick 100.000% total, 100.000% parent, self 0.889% total, self 0.889% children, avg 200.000 sum 200, 401.300ms raw sum
|+++Tick World: minecraft:overworld 81.409% total, 81.409% parent, self 1.873% total, self 2.301% children, avg 1.000 sum 200, 326.694ms raw sum
|---|---Entity Tick 56.784% total, 69.751% parent, self 6.049% total, self 10.652% children, avg 1.000 sum 200, 227.874ms raw sum
```
"Entity Tick" measured 69.751% of the time for the "Tick World: minecraft:overworld" timer.
"A" represents the self time relative to the entire profiling instance.
The self time is the amount of time for a timer that is _not_ measured
by a child timer.
"B" represents the self time relative to its _parents_ timer.
"D" represents the average number of times the timer is invoked relative to
its parent.
For example:
```
|---|---|---Entity Tick: bat 2.642% total, 7.343% parent, self 2.642% total, self 100.000% children, avg 14.975 sum 2,995, 23.127ms raw sum
```
In this case, an average of 14.975 bats were ticked for every
time the "Entity Tick" timer was invoked.
"E" represents the total number of times the timer is invoked.
"F" represents the total raw time accumulated by the timer.
Counters are specified as follows:
<indent>#<name> avg X sum Y
The X is the average number of times the counter is invoked
relative to the parent, exactly similar to the D field of Timers,
where Y is the total number of times the counter is invoked.
Very early build, network configuration switching is supported
but not tested (note: changes need to be backported to Paper)
Changes:
- Supports per player mob caps
- Adds entity tracker optimisations which are not in Paper
(and will not be ported to Paper due to plugin conflicts)
- No longer reverts paper distance map optimisations, as
those are replaced by the NearbyPlayers class
These changes should bring Folia in-line with Paper's optimisations
at least (probably more given the entity tracker optimisations),
still missing features like world loading / some commands
Merge the container is empty and move checks when attempting
to pull from other containers, as in both cases the container
needs to be searched entirely anyways.
Use getEntitiesOfClass when searching for entity containers,
so that non-containers are not searched.
For tryMoveItems, merge both the empty and full checks into one
as they basically perform the same logic. Note that it
relies on ejectItems returning true if _any_ item is moved, as
moving items out of the hopper would affect whether the hopper
is full or not.
If the target is removed, then it is possible that
using the CraftEntity could retrieve a teleported
entity. This would cause the Mob to be removed
when getHandle() is invoked.
Fixes https://github.com/PaperMC/Folia/issues/117
This should prevent attempting to load chunks in areas outside
of the current region, and is what Vanilla logic would do eventually
Fixes https://github.com/PaperMC/Folia/issues/117
The CHUNKY_FIXERS field is modified during the constructors
of the BlockFixers, but the code that uses CHUNKY_FIXERS does
not properly ensure that BlockFixers has been initialised before
using it, leading to a possible race condition where instances of
BlockFixers are accessed before they have initialised correctly.
We can force the class to initialise fully before accessing the
field by calling any method on the class, and for convenience
we use values().
Fixes https://github.com/PaperMC/Folia/issues/141
As part of Folia's place logic, the player's health is sent
after the respawn packet.
Since the health is <= 0.0, this would cause the client to
die again. This would cause the respawn screen to appear again,
and would additionally cause other players to see the player as
dead as well.
There is a small window where this would not have occurred, and
that is where the server would send the correct health before
the client ticks again. This is why the issue was not reproducable
locally, as there was is almost zero delay between those events
on an idle server and on perfect 0ms ping.
Fixes https://github.com/PaperMC/Folia/issues/112
The new spawn selection algorithm attempts to search the area
around a selected point, in an effort to reduce the total number
of chunk loads required to select a spawn point.
Additionally, the new spawn selection algorithm does not perform
recursion when the selected area is already loaded and owned by
the current region. This fixes https://github.com/PaperMC/Folia/issues/138