aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-12-17 12:46:53 +0100
committerNassim Jahnke <[email protected]>2024-12-17 12:49:23 +0100
commit7daedfcbc3e40875375a6b2b16e37134390c332e (patch)
tree2f05e6dbc25b49c9bd0eb02570a492876690e675
parent4b519277838a21d3a3dee6e621a6416380b210c5 (diff)
downloadPaper-7daedfcbc3e40875375a6b2b16e37134390c332e.tar.gz
Paper-7daedfcbc3e40875375a6b2b16e37134390c332e.zip
Update Optimise-collision-checking, apply more updated patches
-rw-r--r--feature-patches/1070-Optimise-collision-checking-in-player-move-packet-ha.patch119
-rw-r--r--paper-server/patches/features/0021-Fix-entity-tracker-desync-when-new-players-are-added.patch (renamed from feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch)0
-rw-r--r--paper-server/patches/features/0022-Lag-compensation-ticks.patch (renamed from feature-patches/1069-Lag-compensation-ticks.patch)0
-rw-r--r--paper-server/patches/features/0023-Eigencraft-redstone-implementation.patch (renamed from feature-patches/1073-Eigencraft-redstone-implementation.patch)0
-rw-r--r--paper-server/patches/features/0024-Add-Alternate-Current-redstone-implementation.patch (renamed from feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch)4
-rw-r--r--paper-server/patches/features/0025-Improve-exact-choice-recipe-ingredients.patch (renamed from feature-patches/1075-Improve-exact-choice-recipe-ingredients.patch)0
6 files changed, 61 insertions, 62 deletions
diff --git a/feature-patches/1070-Optimise-collision-checking-in-player-move-packet-ha.patch b/feature-patches/1070-Optimise-collision-checking-in-player-move-packet-ha.patch
index 3f4cd40208..9f8d28a29d 100644
--- a/feature-patches/1070-Optimise-collision-checking-in-player-move-packet-ha.patch
+++ b/feature-patches/1070-Optimise-collision-checking-in-player-move-packet-ha.patch
@@ -1,65 +1,64 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Spottedleaf <[email protected]>
Date: Thu, 2 Jul 2020 12:02:43 -0700
Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
-diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index 083585a6ab84394a2bc2de6f317c69c7b596e917..b7365e8b410a9e37257cf0a4e79a6f4f82dbbefb 100644
+--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -562,7 +562,7 @@ public class ServerGamePacketListenerImpl
return;
}
-- boolean flag = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
-+ AABB oldBox = entity.getBoundingBox(); // Paper - copy from player movement packet
-
- d6 = d3 - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
- d7 = d4 - this.vehicleLastGoodY; // Paper - diff on change, used for checking large move vectors above
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+- boolean flag = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625));
++ AABB oldBox = rootVehicle.getBoundingBox(); // Paper - copy from player movement packet
+ d3 = d - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
+ d4 = d1 - this.vehicleLastGoodY; // Paper - diff on change, used for checking large move vectors above
+ d5 = d2 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above
+@@ -572,6 +572,7 @@ public class ServerGamePacketListenerImpl
}
- entity.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
-+ boolean didCollide = toX != entity.getX() || toY != entity.getY() || toZ != entity.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
- double d11 = d7;
-
- d6 = d3 - entity.getX();
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
++ boolean didCollide = toX != rootVehicle.getX() || toY != rootVehicle.getY() || toZ != rootVehicle.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
+ d3 = d - rootVehicle.getX();
+ d4 = d1 - rootVehicle.getY();
+ if (d4 > -0.5 || d4 < 0.5) {
+@@ -582,14 +583,22 @@ public class ServerGamePacketListenerImpl
+ d7 = d3 * d3 + d4 * d4 + d5 * d5;
boolean flag2 = false;
-
- if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
+ if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
- flag2 = true;
+ flag2 = true; // Paper - diff on change, this should be moved wrongly
- ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", new Object[]{entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d10)});
+ LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7));
}
- entity.absMoveTo(d3, d4, d5, f, f1);
- this.player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
-- boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
-
+ rootVehicle.absMoveTo(d, d1, d2, f, f1);
+ this.player.absMoveTo(d, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
+- boolean flag3 = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625));
- if (flag && (flag2 || !flag3)) {
+ // Paper start - optimise out extra getCubes
+ boolean teleportBack = flag2; // violating this is always a fail
+ if (!teleportBack) {
+ // note: only call after setLocation, or else getBoundingBox is wrong
-+ AABB newBox = entity.getBoundingBox();
++ AABB newBox = rootVehicle.getBoundingBox();
+ if (didCollide || !oldBox.equals(newBox)) {
-+ teleportBack = this.hasNewCollision(worldserver, entity, oldBox, newBox);
++ teleportBack = this.hasNewCollision(serverLevel, rootVehicle, oldBox, newBox);
+ } // else: no collision at all detected, why do we care?
+ }
+ if (teleportBack) { // Paper end - optimise out extra getCubes
- entity.absMoveTo(d0, d1, d2, f, f1);
- this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
- this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ rootVehicle.absMoveTo(x, y, z, f, f1);
+ this.player.absMoveTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
+ this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle));
+@@ -667,9 +676,32 @@ public class ServerGamePacketListenerImpl
}
private boolean noBlocksAround(Entity entity) {
-- return entity.level().getBlockStates(entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::isAir);
+- return entity.level()
+- .getBlockStates(entity.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0))
+- .allMatch(BlockBehaviour.BlockStateBase::isAir);
+ // Paper start - stop using streams, this is already a known fixed problem in Entity#move
-+ AABB box = entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D);
++ AABB box = entity.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0);
+ int minX = Mth.floor(box.minX);
+ int minY = Mth.floor(box.minY);
+ int minZ = Mth.floor(box.minZ);
@@ -67,15 +66,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ int maxY = Mth.floor(box.maxY);
+ int maxZ = Mth.floor(box.maxZ);
+
-+ Level world = entity.level();
++ Level level = entity.level();
+ BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
+
+ for (int y = minY; y <= maxY; ++y) {
+ for (int z = minZ; z <= maxZ; ++z) {
+ for (int x = minX; x <= maxX; ++x) {
+ pos.set(x, y, z);
-+ BlockState type = world.getBlockStateIfLoaded(pos);
-+ if (type != null && !type.isAir()) {
++ BlockState blockState = level.getBlockStateIfLoaded(pos);
++ if (blockState != null && !blockState.isAir()) {
+ return false;
+ }
+ }
@@ -87,61 +86,61 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@Override
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+@@ -1361,7 +1393,7 @@ public class ServerGamePacketListenerImpl
}
}
-- AABB axisalignedbb = this.player.getBoundingBox();
-+ AABB axisalignedbb = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB
-
- d6 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
- d7 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
-
- this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
+- AABB boundingBox = this.player.getBoundingBox();
++ AABB boundingBox = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB
+ d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
+ d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
+ d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
+@@ -1400,6 +1432,7 @@ public class ServerGamePacketListenerImpl
+ boolean flag1 = this.player.verticalCollisionBelow;
+ this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
+ boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
// Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) {
return; // ... thanks Mojang for letting move calls teleport across dimensions.
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+@@ -1431,7 +1464,17 @@ public class ServerGamePacketListenerImpl
}
// Paper start - Add fail move event
-- boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2));
+- boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && serverLevel.noCollision(this.player, boundingBox) || this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2));
+ // Paper start - optimise out extra getCubes
+ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && movedWrongly;
-+ this.player.absMoveTo(d0, d1, d2, f, f1); // prevent desync by tping to the set position, dropped for unknown reasons by mojang
++ this.player.absMoveTo(d, d1, d2, f, f1); // prevent desync by tping to the set position, dropped for unknown reasons by mojang
+ if (!this.player.noPhysics && !this.player.isSleeping() && !teleportBack) {
+ AABB newBox = this.player.getBoundingBox();
-+ if (didCollide || !axisalignedbb.equals(newBox)) {
++ if (didCollide || !boundingBox.equals(newBox)) {
+ // note: only call after setLocation, or else getBoundingBox is wrong
-+ teleportBack = this.hasNewCollision(worldserver, this.player, axisalignedbb, newBox);
++ teleportBack = this.hasNewCollision(serverLevel, this.player, boundingBox, newBox);
+ } // else: no collision at all detected, why do we care?
+ }
+ // Paper end - optimise out extra getCubes
if (teleportBack) {
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
toX, toY, toZ, toYaw, toPitch, false);
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+@@ -1567,7 +1610,7 @@ public class ServerGamePacketListenerImpl
private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
- if (this.tickCount - this.awaitingTeleportTime > 20) {
+ if (false && this.tickCount - this.awaitingTeleportTime > 20) { // Paper - this will greatly screw with clients with > 1000ms RTT
this.awaitingTeleportTime = this.tickCount;
- this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
- }
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ this.teleport(
+ this.awaitingPositionFromClient.x,
+@@ -1586,6 +1629,33 @@ public class ServerGamePacketListenerImpl
}
}
+ // Paper start - optimise out extra getCubes
-+ private boolean hasNewCollision(final ServerLevel world, final Entity entity, final AABB oldBox, final AABB newBox) {
++ private boolean hasNewCollision(final ServerLevel level, final Entity entity, final AABB oldBox, final AABB newBox) {
+ final List<AABB> collisionsBB = new java.util.ArrayList<>();
+ final List<VoxelShape> collisionsVoxel = new java.util.ArrayList<>();
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisions(
-+ world, entity, newBox, collisionsVoxel, collisionsBB,
++ level, entity, newBox, collisionsVoxel, collisionsBB,
+ ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS | ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER,
+ null, null
+ );
@@ -163,6 +162,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return false;
+ }
+ // Paper end - optimise out extra getCubes
- private boolean isPlayerCollidingWithAnythingNew(LevelReader world, AABB box, double newX, double newY, double newZ) {
- AABB axisalignedbb1 = this.player.getBoundingBox().move(newX - this.player.getX(), newY - this.player.getY(), newZ - this.player.getZ());
- Iterable<VoxelShape> iterable = world.getCollisions(this.player, axisalignedbb1.deflate(9.999999747378752E-6D));
+ private boolean isPlayerCollidingWithAnythingNew(LevelReader level, AABB box, double x, double y, double z) {
+ AABB aabb = this.player.getBoundingBox().move(x - this.player.getX(), y - this.player.getY(), z - this.player.getZ());
+ Iterable<VoxelShape> collisions = level.getCollisions(this.player, aabb.deflate(1.0E-5F));
diff --git a/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0021-Fix-entity-tracker-desync-when-new-players-are-added.patch
index d7fc36933f..d7fc36933f 100644
--- a/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch
+++ b/paper-server/patches/features/0021-Fix-entity-tracker-desync-when-new-players-are-added.patch
diff --git a/feature-patches/1069-Lag-compensation-ticks.patch b/paper-server/patches/features/0022-Lag-compensation-ticks.patch
index 1d692f7144..1d692f7144 100644
--- a/feature-patches/1069-Lag-compensation-ticks.patch
+++ b/paper-server/patches/features/0022-Lag-compensation-ticks.patch
diff --git a/feature-patches/1073-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0023-Eigencraft-redstone-implementation.patch
index 9b2677a63c..9b2677a63c 100644
--- a/feature-patches/1073-Eigencraft-redstone-implementation.patch
+++ b/paper-server/patches/features/0023-Eigencraft-redstone-implementation.patch
diff --git a/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0024-Add-Alternate-Current-redstone-implementation.patch
index 30c303e0c2..789e1ac2c4 100644
--- a/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch
+++ b/paper-server/patches/features/0024-Add-Alternate-Current-redstone-implementation.patch
@@ -2434,7 +2434,7 @@ index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b
dropResources(state, level, pos);
level.removeBlock(pos, false);
diff --git a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
-index 83f5da3e24834882193b9d7e3a788517e4b12b55..db7a7b091d2eb0f5b7efbe0db2b91709dee688e8 100644
+index 83f5da3e24834882193b9d7e3a788517e4b12b55..0c50a0bbbef1229230712b7c04364fea06859674 100644
--- a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
+++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
@@ -17,6 +17,11 @@ public class ExperimentalRedstoneUtils {
@@ -2442,7 +2442,7 @@ index 83f5da3e24834882193b9d7e3a788517e4b12b55..db7a7b091d2eb0f5b7efbe0db2b91709
orientation = orientation.withFront(front);
}
+ // Paper start - Optimize redstone (Alternate Current) - use default front instead of random
-+ else if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
++ else if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
+ orientation = orientation.withFront(Direction.WEST);
+ }
+ // Paper end - Optimize redstone (Alternate Current)
diff --git a/feature-patches/1075-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0025-Improve-exact-choice-recipe-ingredients.patch
index 91119626f1..91119626f1 100644
--- a/feature-patches/1075-Improve-exact-choice-recipe-ingredients.patch
+++ b/paper-server/patches/features/0025-Improve-exact-choice-recipe-ingredients.patch