Commit Graph

274 Commits

Author SHA1 Message Date
Spottedleaf
4d78338afe Generated API
Fixes build
2024-01-10 14:03:31 -08:00
Spottedleaf
be90fb8d36 Update Paper 2024-01-09 14:49:27 -08:00
Spottedleaf
16e8d3aea4 Check processed disconnect after invoking keepConnectionAlive()
Since we move this up, we need to check it to prevent ticking
a possibly removed player
2024-01-09 14:37:27 -08:00
Spottedleaf
e89a107ef0 Guard against double onDisconnect calls in common packet listener
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
2024-01-09 14:22:00 -08:00
Spottedleaf
6928284a56 Update Paper and add configurable region shift
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.
2023-12-30 17:20:19 -08:00
Spottedleaf
9a389a1a5e Update Paper 2023-12-23 06:03:14 -08:00
Spottedleaf
cd713b8ea2 Fix compile/run for 1.20.4
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.
2023-12-18 15:06:11 -08:00
Spottedleaf
de6a87e338 Apply patches for 1.20.4
- Compile needs to be checked.
- Behaviors around the new tick manager need to be designed
  and implemented.

Chk update.txt for anything specific.
2023-12-16 15:32:48 -08:00
Spottedleaf
1e5e2154c9 Implement command execution support for RCON
Just need to change the executeBlocking() call to use the
global region to execute the command instead.
2023-11-24 19:43:47 -08:00
Jason Penilla
c1e3c3c532 Bump paper-mojangapi and Gradle 2023-11-24 17:23:52 -08:00
Jason Penilla
3843340cba Fix command sender check 2023-11-21 13:27:29 -08:00
Siroshun09
d58fab2cce Fix animal spawning issue 2023-11-21 13:12:55 -08:00
Spottedleaf
7aacf902b0 Update Paper 2023-11-16 14:33:41 -08:00
Spottedleaf
757cb09c41 Update Paper 2023-10-16 19:08:01 -07:00
Spottedleaf
9190eb011c Update paper 2023-10-15 13:03:17 -07:00
Spottedleaf
84aecdc64a Update paper 2023-10-09 10:13:26 -07:00
Spottedleaf
905cf0b6be Fix crash when generating swamp structure
Need to implement structureManager on CB's DelegatedGeneratorAccess,
as that is now used during population.
2023-10-06 19:33:13 -07:00
Spottedleaf
8cde60d1f9 Use tracker field instead of entity map lookup in CraftEntity#getTrackedBy
Fixes compilation
2023-10-06 18:30:21 -07:00
Spottedleaf
dc3fcef3bb Use postprocess annotation for config 2023-10-06 18:26:56 -07:00
Spottedleaf
6c59a955b0 Re-add RandomCommand
Now that RandomSequences is thread-safe, do not need to disable
this command
2023-10-06 17:53:48 -07:00
Spottedleaf
726cdc39a5 Update paper 2023-10-06 17:50:00 -07:00
Spottedleaf
a4d99b3cd3 Update paperweight to 1.5.7
Apparently, fixes some compile issues for some users.
2023-10-06 17:36:18 -07:00
Spottedleaf
e5b552fb0c Properly synchronise RandomSequences access
The underlying map should be CHM, and the access to the
underlying random should be synchronised as well.
2023-10-06 17:34:34 -07:00
Spottedleaf
e876103942 Region profiler
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.
2023-10-03 06:27:57 -07:00
Spottedleaf
cdf356915b Properly revert reversion of per-player mob caps
Some diffs were stilled dropped, which made mob spawning
limitless.
2023-09-26 13:53:10 -07:00
Spottedleaf
4a59238743 Update to 1.20.2
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
2023-09-26 13:28:33 -07:00
Spottedleaf
edafbcef68 Update Paper 2023-09-11 11:18:04 -07:00
Spottedleaf
372d479cc1 Update upstream Paper 2023-09-06 20:02:39 -07:00
Spottedleaf
55796e2084 Further optimise hoppers
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.
2023-09-06 19:49:47 -07:00
Spottedleaf
1f46b2ca93 Fix NPE in TeleportUtils if the Entity becomes retired
The onComplete variable is possibly null and should be checked
before trying to invoke it.

Fixes https://github.com/PaperMC/Folia/issues/151
2023-09-06 17:28:06 -07:00
Spottedleaf
f6e91e9a4c Update Paper 2023-08-09 15:45:26 -07:00
Spottedleaf
9ae65d1b3e Additionally remove Mob target if the target is removed
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
2023-08-08 18:16:25 -07:00
Spottedleaf
bd72070fb9 Remove bee flower/hive position if it is too far away
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
2023-08-08 18:14:40 -07:00
Spottedleaf
09ac612b2f Do not attempt to pathfind into non-owned chunks
Fixes https://github.com/PaperMC/Folia/issues/117
2023-08-08 17:54:27 -07:00
Spottedleaf
3379b89797 Add thread check for NMS block setting
To catch block updates in chunks, currently for performance
reasons loaded chunks do not perform thread checks
2023-08-08 17:49:52 -07:00
Spottedleaf
65667ccd07 Fix race condition on UpgradeData.BlockFixers class init
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
2023-08-08 17:31:01 -07:00
Spottedleaf
3cf16eeaf2 Reset player before running place logic
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
2023-08-07 14:35:18 -07:00
Spottedleaf
b2d7bdb0bb Make loadChunksAsync callback thread-safe
Need to perform synchronisation on the return list to avoid CMEs
2023-07-25 12:00:33 -07:00
Spottedleaf
57983f77f7 Rewrite spawn selection algorithm
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
2023-07-25 11:52:46 -07:00
Spottedleaf
daacd42550 Use Folia for bstats version instead of Paper 2023-07-12 18:41:19 -07:00
Spottedleaf
b5fc6d0a12 Correctly handle ender pearl end gateway teleportations
The end gateway is supposed to teleport the person who threw
the ender pearl.

The changes more closely mirror Vanilla behavior. The current
exceptions to Vanilla behavior are:

1. The first teleportation attempt for the end gateway always fails
2. If the ender pearl thrower is riding a vehicle, the thrower is
   dismounted from their vehicle.

I don't see any solutions for #1 right now. The root issue is that
since the end gateway does not have a target location, it has to
search for one. However, it can _fail_ to find a target location,
in which case the teleportation should not occur. Since the search
must take place asynchronously, it requires the entity to be
removed from the world.

For #2, this is because Vanilla's behavior is broken and does not
correctly teleport players riding boats. We can fix this by simply
dismounting the player and teleporting them separately of their boat,
which seems to be what Vanilla is trying to do given it does _not_
try to teleport the root vehicle of the player.

This is a partial fix to https://github.com/PaperMC/Folia/issues/51
2023-07-09 21:47:25 -07:00
Spottedleaf
62b165bd7c Set correct riding position for entity passengers on vehicle move packet
Since Folia moves the connection tick to the beginning of the tick,
the player's position would be incorrectly updated by the move
packet and be used during the tick.

This would cause the player's bounding box to be incorrect, which
would cause incorrect movement collision calculations, such as
colliding with fire.

Fixes https://github.com/PaperMC/Folia/issues/119
2023-07-09 20:40:57 -07:00
Spottedleaf
c0631fd5cd Do not erase job site memory when not in tick thread region
The intention behind erasing the memory was to match the case
where the villager would lose. However, there may not be
any competitors in which case the villager would never lose.

Instead, the new behavior is to behave as if the villager was not
loaded.

Fixes https://github.com/PaperMC/Folia/issues/64
2023-07-09 20:40:44 -07:00
Spottedleaf
bd96e299d4 Update paper 2023-07-06 22:26:45 -07:00
Sofiane H. Djerbi
6b978f2aaf Add Yaw and Pitch to CraftEntity.teleportAsync 2023-07-01 13:51:05 -07:00
Spottedleaf
6e317fd38a Only thread-check addEffect for entities in the world
Resolves possible crashes when adding effects before adding to the
world or when adding from the worldgen threads.
2023-07-01 13:43:32 -07:00
Spottedleaf
bff0370b70 Check region for Vex spell origin
If the Vex portals or is moved far enough away, it may trip
a thread check.

Fixes https://github.com/PaperMC/Folia/issues/95
2023-07-01 13:12:44 -07:00
Spottedleaf
eb2231736b Only update time for local players in time update tick
This was done in 1.19.4, but the diff to use getLocalPlayers()
was dropped by accident.

Fixes https://github.com/PaperMC/Folia/issues/114
2023-07-01 12:18:44 -07:00
Spottedleaf
d1c9e63470 Use teleportAsync for handling cancelled move events
Some plugins are bad and update the `from` position to something
completely garbage. To avoid a crash from this cross-region
teleportation, the teleportAsync function is now used.

The reason the teleport isn't simply ignored is since there may
be legitimate reasons to update the `from` position to something
off-region. This also handles the case where the plugin _uses_
an asynchronous teleport while cancelling the event.

This mirrors the behavior for changing the target destination
but not cancelling the event.

Fixes https://github.com/PaperMC/Folia/issues/115
2023-07-01 12:10:16 -07:00
Spottedleaf
801cff1570 Re-add dropped thread check for retrieving fall position from entities
Additionally, reset the fall position on dimension change.

Fixes https://github.com/PaperMC/Folia/issues/99#issuecomment-1610453068
2023-06-27 19:14:35 -07:00