366 Commits

Author SHA1 Message Date
Spottedleaf
87f8bd3e00 Implement Bukkit#getTps
Note that this requires the caller to be on a ticking region
or the global region, otherwise it will throw
UnsupportedOperationException.

Now the function returns the TPS for the current region.
2025-01-28 16:50:39 -08:00
Euphyllia Bierque
1f0b85d4e4 Add API to retrieve TPS from a specified location
Resolves https://github.com/PaperMC/Folia/pull/310
2025-01-28 16:49:08 -08:00
kerudion
5cc35a8e23 Fix flickering with teleportAsync
Fixes flickering of entities without passengers when teleporting
them with teleportAsync.

We do not need to untrack/track the entity when there are no
passengers, so we should not.
2025-01-28 16:11:25 -08:00
M2ke4U
35d31075a6
Use correct TrackedEntity variable in ChunkMap#addEntity
The variable `trackedEntity` is the input parameter, but we need use the TrackedEntity variable for the possible other entity.
2025-01-28 15:55:07 -08:00
Spottedleaf
ec78da5ae0 Fix spectator camera implementation
There are several problems that were solved:

1. Spectating failed to follow players through cross-region/cross-world
   teleporting.
2. Inability to set camera to off-region entity
3. Various crashes involved with off-region camera entity
4. Spectator does not always follow entities through portals

We fix #1 by sending ClientboundSetCameraPacket when the spectated
entity becomes in tracked, as the client appears to be unable to
correctly handle when the camera entity is removed, even temporarily.

We fix #2 by allowing off-region entities that are not dead.
However, this required the teleportation code in both setCamera
and the ServerPlayer#tick method to be modified to correctly
handle off-region camera targets.

We fix #3 by correctly teleporting to off-region locations
when needed.

We fix #4 by following the Bukkit entity. This allows spectator
mode to properly follow non-player entities through portals.

Issues #1 (cross-world) and #4 are probably present in Paper/Vanilla, however
solving #2 and #3 required a solution for these.

Fixes https://github.com/PaperMC/Folia/issues/324
2025-01-28 15:46:51 -08:00
Spottedleaf
e7bb50eac6 Add missing throw for ServerPlayer#teleport override
All teleports must use teleportAsync, so we need to throw
on the old implementations to prevent their usage.
2025-01-28 14:13:41 -08:00
Spottedleaf
81b9f70be9 Update Paper 2025-01-28 14:03:45 -08:00
Spottedleaf
e7e959208c Force out of region chunk in collision to collide
Instead of relying on COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS,
we will force a chunk not owned by the current region to collide
so that entities moving at high speed cannot move out of region.
2025-01-28 04:50:30 -08:00
Spottedleaf
92efc63ec3 Fix missing chunk shift on Z coordinate in last commit 2025-01-25 12:46:33 -08:00
Spottedleaf
41eab7ad00 Update Paper 2025-01-25 11:37:24 -08:00
Spottedleaf
75f1605833 Schedule POTENTIAL_JOB_SITE to correct region
The position may not be owned by the current region so we must
schedule the release to the correct region.

Fixes https://github.com/PaperMC/Folia/issues/319
2025-01-25 11:32:13 -08:00
Spottedleaf
4e7607dce4 Update Paper 2025-01-22 12:11:28 -08:00
Spottedleaf
290f78994a Do not invoke ender pearl registration logic
The owner of the projectile would need to be retrieved, which
may trip a thread check. We do not track ender pearls anyways,
so the registration logic does nothing regardless.

Fixes https://github.com/PaperMC/Folia/issues/315
2025-01-20 05:09:33 -08:00
Spottedleaf
35b98633ba Add thread check to YieldJobSite
We cannot yield the job site if it is outside of the current
region.

Fixes https://github.com/PaperMC/Folia/issues/316
2025-01-20 05:06:14 -08:00
Spottedleaf
b54ba0d75b Remove nearbyPlayers cache on ChunkData
We cannot guarantee that the current region owns the chunk
associated with the ChunkData. As a result, more than 1 region
may write to the field.

Additionally, we did not include any logic to adjust the field during
a region merge or split - which would leave invalid data in the field.

As a result, the nearbyPlayers data retrieved from the ChunkData
was possibly invalid which may have lead to entity tracker desync
problems.

Fixes https://github.com/PaperMC/Folia/issues/317
2025-01-20 04:56:56 -08:00
Spottedleaf
575f5f39e2 Update Paper 2025-01-20 04:40:25 -08:00
Spottedleaf
306dc07ce6 Update Paper 2025-01-16 14:31:34 -08:00
Spottedleaf
5198c2f583 Update Paper 2025-01-14 11:22:26 -08:00
Spottedleaf
7dbde1de00 Rebuild patches 2025-01-11 06:46:58 -08:00
Spottedleaf
0acb7b08b7 Split Minecraft patches into file patches 2025-01-11 06:45:50 -08:00
Spottedleaf
504f90840b Split paper feature patches into file patches 2025-01-11 06:42:06 -08:00
Spottedleaf
b1da93e90b Resolve notes 2025-01-11 06:36:44 -08:00
Spottedleaf
838465ab24 Begin hard fork 2025-01-11 05:26:16 -08:00
Spottedleaf
8af1aef1f1 Update Paper 2024-12-12 07:14:18 -08:00
Spottedleaf
1c0ecd3d18 Use ThreadLocal for CraftBlockStates#DISABLE_SNAPSHOT
We need to use a thread-local to prevent race conditions
across regions.

Fixes https://github.com/PaperMC/Folia/issues/293
2024-12-08 16:36:00 -08:00
Spottedleaf
94d65c398c Update old position/rotation when teleporting entity
This will fix any problems accessing the old position, which
may be outside of the current region.

This might be a fix for https://github.com/PaperMC/Folia/issues/302
2024-12-08 15:16:07 -08:00
Spottedleaf
d8bef962a8 Fix time command
We need to run the time synchronisation on the global region.

Fixes https://github.com/PaperMC/Folia/issues/306
2024-12-08 12:45:19 -08:00
Spottedleaf
61aed65cce Update Paper 2024-12-08 12:39:49 -08:00
Spottedleaf
d4bc33870b Update Paper 2024-12-04 02:56:21 -08:00
Spottedleaf
ff947a77c7 Update to 1.21.4 2024-12-03 19:46:13 -08:00
Spottedleaf
e1601057b3 Ensure ticket updates are processed for task queue reference count
It is possible that when the reference count is retrieved that
the ticket updates have not yet been processed, which means
that the region section at the queued position may not exist or may
become nonexistant while or after the task is being added.

This restructures the reference counting code to now refer to
both a reference counter and a flag indicating whether ticket
updates are processed.

Fixes https://github.com/PaperMC/Folia/issues/262
This issue shows the race condition where the region becomes
nonexistant.
2024-12-03 02:20:29 -08:00
Spottedleaf
f50f36339c Use same position selection during spawn pos selection fallback
If we cannot find a spawn pos in the spawn radius,
use the same fallback logic as when the world type or player's
gamemode does not support spawn selection. This adjusts the spawn
position to not be inside a wall or on water.
2024-12-03 01:59:04 -08:00
Spottedleaf
eb5ec0b932 Adjust shutdown logic to close player inventories
We need to drop items in special containers on shutdown
to prevent them from being lost.

Fixes https://github.com/PaperMC/Folia/issues/148
2024-12-02 23:52:38 -08:00
Spottedleaf
815dd7bae8 Fix compile 2024-12-01 16:54:40 -08:00
Spottedleaf
227b50fe38 Update Paper 2024-12-01 16:13:58 -08:00
Spottedleaf
c937c72ef9 Update Paper 2024-11-28 19:06:32 -08:00
Spottedleaf
88f8af4c06 Use redstone game time for saving chunk tick list 2024-11-27 08:32:43 -08:00
Spottedleaf
97805cb5c9 Update LeafProfiler formatting 2024-11-27 08:07:50 -08:00
Spottedleaf
be8908e2b2 Update to 1.21.3 2024-11-27 07:54:37 -08:00
Spottedleaf
2e7bc0721a Adjust initial world spawn radius load
The spawn selection may actually be farther than 32 blocks,
so we need a larger load radius to prevent a deadlock on startup.

Additionally, re-insert thread checks for sync loads that were
previously in 1.20.
2024-11-14 21:35:50 -08:00
Spottedleaf
5833269c4c Update Paper 2024-11-04 11:15:46 -08:00
Spottedleaf
06d719d57d Do not show end credits
Fixes end portalling not working correctly when the player has
not seen the end credits.
2024-10-21 10:03:18 -07:00
Spottedleaf
7b534ef0bd Update Paper 2024-10-21 09:30:58 -07:00
Spottedleaf
88e0907cad Do not create raids in positions not owned
If a player moves away before the raid is created, then we would
possibly trigger the raid cross-region.

Considering Vanilla doesn't trigger the raid cross-dimension, this
doesn't seem like an important behavior to break.

Fixes https://github.com/PaperMC/Folia/issues/264
2024-08-30 20:04:09 -07:00
Spottedleaf
99ba4bd7be Store projectile owner as CraftEntity
CraftEntity properly tracks the underlying entity handle
when the entity teleports. This resolves a race condition
where if an enderpearl was ticked while its owner was teleporting,
the owner reference would be lost.

Fixes https://github.com/PaperMC/Folia/issues/279
2024-08-30 19:13:44 -07:00
Spottedleaf
2e88b1680f Add watchdog thread
When regions take too long, having the server print the stacktrace
of the ticking region should help debug the cause.
2024-08-30 18:36:46 -07:00
Spottedleaf
d8461e8ec5 Remove toProcessTrackingUnloading
This field is covered by the entity tracker optimisations in Paper,
but currently was not properly maintained - resulting in memory leaks.

Fixes https://github.com/PaperMC/Folia/issues/283
2024-08-30 12:58:17 -07:00
Spottedleaf
11e6f61697 Update Paper 2024-08-28 21:52:48 -07:00
Spottedleaf
bfa3106e76 Update Paper 2024-08-24 13:13:45 -07:00
Spottedleaf
9203a7a887 Update Paper 2024-08-16 15:43:38 -07:00