Compare commits

...

5 Commits

Author SHA1 Message Date
Spottedleaf 7f0a317854 Update Paper 2024-02-20 18:42:54 -08:00
Spottedleaf 5652259e1a Fix entity tracker desync when new players are added to the tracker
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
2024-02-20 18:30:53 -08:00
Spottedleaf 0265fdd4f4 Make endermite spawn at original thrower position
This is how Vanilla does it, and we don't have any reason to change
this other than an oversight in copying the code.
2024-02-20 17:25:53 -08:00
Spottedleaf e22501a8e3 Remove pending connections for login VERIFYING state
The login state PROTOCOL_SWITCHING is only set once the player
passes initial login checks during the VERIFYING state
(ban,whitelist,slots,login event), but we add to pending during
the VERIFYING state.

Fixes https://github.com/PaperMC/Folia/issues/201 https://github.com/PaperMC/Folia/issues/200
2024-02-20 16:26:42 -08:00
Spottedleaf 7a3dea9038 Add support for Eigen/Alternate current
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
2024-02-20 16:16:18 -08:00
8 changed files with 273 additions and 181 deletions

View File

@ -2,7 +2,7 @@ group=dev.folia
version=1.20.4-R0.1-SNAPSHOT
mcVersion=1.20.4
paperRef=31699ae9a8f3a57491e9c9276cffa5a51e9a5f60
paperRef=4939f8711884901ddf1c56337f606de71cdae78d
org.gradle.caching=true
org.gradle.parallel=true

View File

@ -14,7 +14,7 @@ more helpful than some random error log caused by
a breakage.
diff --git a/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java b/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
index ef393f1f93ca48264fc1b6e3a27787f6a9152e1b..1325f9fed80731b74b80145dadc843b1a34b851b 100644
index bcf91d048d84144f6acf9bfd2095df9ada2e585f..3072f95dc1cafb47c1820dc67c8d24991540fc4a 100644
--- a/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
+++ b/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
@@ -200,4 +200,12 @@ public interface PluginMeta {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts
index 376e8983fdfdbb6c3e5fd8ad0f6a05e655b622bf..959e62d800de05b2dd77a252f442c3daf8438490 100644
index ce3747d8d2a8f4327766cf23d5aaa72cfcb380bc..08d434023226af0d2c469055a3b2188fe8a4ed38 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
@ -23,7 +23,7 @@ index 376e8983fdfdbb6c3e5fd8ad0f6a05e655b622bf..959e62d800de05b2dd77a252f442c3da
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -69,7 +73,7 @@ tasks.jar {
@@ -70,7 +74,7 @@ tasks.jar {
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit",
@ -32,7 +32,7 @@ index 376e8983fdfdbb6c3e5fd8ad0f6a05e655b622bf..959e62d800de05b2dd77a252f442c3da
"Implementation-Vendor" to date, // Paper
"Specification-Title" to "Bukkit",
"Specification-Version" to project.version,
@@ -153,7 +157,7 @@ fun TaskContainer.registerRunTask(
@@ -154,7 +158,7 @@ fun TaskContainer.registerRunTask(
name: String,
block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) {

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ index b84c48902ef24fdae17578a304e6c93dc20c5dce..218c1954a7922c9e6bf6f34f9497f89c
} else {
RailShape blockpropertytrackposition1 = (RailShape) iblockdata.getValue(PoweredRailBlock.SHAPE);
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
index 18cb719ae55b736a6dade61237a845c866fb6858..306e8dc1546927def934148c0c542c48872544e7 100644
index 1fd29331e928bc76de06d5eb5ba781390af76ebe..d6df2f1d3342fcbcf8ee5aa86c4d6f3431fac580 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -200,8 +200,9 @@ public class RedStoneWireBlock extends Block {

View File

@ -22,7 +22,7 @@ index add6fc106d3c38d97b48ec0df3ac2515c8c0486e..cbc89b8898f9243776af88c2b04ad3c2
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a463c46778e5ee641c1b7d634b79ec68414cd936..b640d877f924094bcabbf9618bbd9aa0a70bf94a 100644
index ffec458e5b6dc4250758fb8a97ab1e737dcedb1d..2fa76a711a629e38a95b93e473272b8217783f99 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4374,6 +4374,11 @@ public abstract class LivingEntity extends Entity implements Attackable {

View File

@ -1629,10 +1629,10 @@ index d532043f33825ce2971d9e53f290cdead22d6916..74483543836d9ed042cc7b9cbbde8d58
// Folia end - region threading
// Paper end - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70a754a0d8 100644
index a74538bdc720efc435e7890aa835c9f255f9ebb6..ec25610cbffe30fecaeaadf9098e187bc15b5405 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -892,6 +892,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -891,6 +891,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void tick(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - regionised ticking
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking
@ -1640,7 +1640,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
ProfilerFiller gameprofilerfiller = this.getProfiler();
regionizedWorldData.setHandlingTick(true); // Folia - regionised ticking
@@ -920,9 +921,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -919,9 +920,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (!this.isDebug() && flag) {
j = regionizedWorldData.getRedstoneGameTime(); // Folia - region threading
gameprofilerfiller.push("blockTicks");
@ -1654,7 +1654,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
gameprofilerfiller.pop();
}
this.timings.scheduledBlocks.stopTiming(); // Paper
@@ -930,18 +935,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -929,18 +934,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.popPush("raid");
if (flag) {
this.timings.raids.startTiming(); // Paper - timings
@ -1679,7 +1679,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
this.timings.doSounds.stopTiming(); // Spigot
}
@@ -957,6 +968,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -956,6 +967,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.push("entities");
this.timings.tickEntities.startTiming(); // Spigot
if (this.dragonFight != null && flag) {
@ -1687,7 +1687,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
if (io.papermc.paper.util.TickThread.isTickThreadFor(this, this.dragonFight.origin)) { // Folia - region threading
gameprofilerfiller.push("dragonFight");
this.dragonFight.tick();
@@ -969,10 +981,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -968,10 +980,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
fightCenter
);
} // Folia end - region threading
@ -1700,7 +1700,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
if (!entity.isRemoved()) {
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
@@ -1000,10 +1014,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -999,10 +1013,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
});
@ -1714,7 +1714,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
}
gameprofilerfiller.push("entityManagement");
@@ -1063,12 +1080,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1062,12 +1079,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) {
@ -1730,7 +1730,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
}
}
@@ -1518,6 +1538,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1517,6 +1537,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Paper start- timings
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity);
timer = isActive ? entity.getType().tickTimer.startTiming() : entity.getType().inactiveTickTimer.startTiming(); // Paper
@ -1742,7 +1742,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
try {
// Paper end - timings
entity.setOldPosAndRot();
@@ -1543,7 +1568,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1542,7 +1567,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Folia end - region threading
} else { entity.inactiveTick(); } // Paper - EAR 2
this.getProfiler().pop();
@ -1751,7 +1751,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
Iterator iterator = entity.getPassengers().iterator();
while (iterator.hasNext()) {
@@ -1567,6 +1592,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1566,6 +1591,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Paper - EAR 2
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper
@ -1763,7 +1763,7 @@ index 172f8e1abb036669b787fde570da8d326d2ab262..a16fc5ba55dbde0cf7f968884da40d70
try {
// Paper end
passenger.setOldPosAndRot();
@@ -1606,7 +1636,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1605,7 +1635,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(passenger, entity2);
}

View File

@ -0,0 +1,85 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 20 Feb 2024 18:24:16 -0800
Subject: [PATCH] Fix entity tracker desync when new players are added to the
tracker
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.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 21ec49acb3c1241d9286959c42a7f8363f637e4f..79e507c1463dbb9039b1fed8bdf41c0ee5f4fec3 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1419,6 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.serverEntity.addPairing(player);
}
// Paper end - entity tracking events
+ this.serverEntity.onPlayerAdd(); // Paper - fix desync when a player is added to the tracker
}
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 529ab44baaf573b97cf7e89560c548642733188f..16373e0c5ea38199fab3eb289bf2a5fcf0dd7439 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -93,6 +93,13 @@ public class ServerEntity {
this.trackedDataValues = entity.getEntityData().getNonDefaultValues();
}
+ // Paper start - fix desync when a player is added to the tracker
+ private boolean forceStateResync;
+ public void onPlayerAdd() {
+ this.forceStateResync = true;
+ }
+ // Paper end - fix desync when a player is added to the tracker
+
public void sendChanges() {
List<Entity> list = this.entity.getPassengers();
@@ -141,7 +148,7 @@ public class ServerEntity {
}
}
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
int i;
int j;
@@ -177,13 +184,13 @@ public class ServerEntity {
boolean flag4 = false;
boolean flag5 = false;
- if (!(this.entity instanceof net.minecraft.world.entity.decoration.HangingEntity) || this.tickCount > 0 || this.entity instanceof AbstractArrow) { // Paper - Always update position to fix first-tick teleports
+ if (this.forceStateResync || !(this.entity instanceof net.minecraft.world.entity.decoration.HangingEntity) || this.tickCount > 0 || this.entity instanceof AbstractArrow) { // Paper - Always update position to fix first-tick teleports
long k = this.positionCodec.encodeX(vec3d);
long l = this.positionCodec.encodeY(vec3d);
long i1 = this.positionCodec.encodeZ(vec3d);
boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
- if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()&& !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
+ if (!this.forceStateResync && !flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()&& !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) {
if (flag2) {
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround());
@@ -240,6 +247,7 @@ public class ServerEntity {
}
this.entity.hasImpulse = false;
+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker
}
++this.tickCount;