2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 01:02:51 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								From: Spottedleaf <Spottedleaf@users.noreply.github.com>
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								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
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                     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 - 1.0E-6D; // Paper - diff on change, used for checking large move vectors above
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 }
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                 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();
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 boolean flag2 = false;
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-                    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)});
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 entity.absMoveTo(d3, d4, d5, f, f1);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 this.player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-                boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-                if (flag && (flag2 || !flag3)) {
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                // Paper start - optimise out extra getCubes
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                boolean teleportBack = flag2; // violating this is always a fail
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                if (!teleportBack) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                    // note: only call after setLocation, or else getBoundingBox is wrong
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                    AABB newBox = entity.getBoundingBox();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                    if (didCollide || !oldBox.equals(newBox)) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                        teleportBack = this.hasNewCollision(worldserver, entity, 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
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                     this.send(new ClientboundMoveVehiclePacket(entity));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     private boolean noBlocksAround(Entity entity) {
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-        return entity.level().getBlockStates(entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::isAir);
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+        // 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);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int minX = Mth.floor(box.minX);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int minY = Mth.floor(box.minY);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int minZ = Mth.floor(box.minZ);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int maxX = Mth.floor(box.maxX);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int maxY = Mth.floor(box.maxY);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        int maxZ = Mth.floor(box.maxZ);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        Level world = entity.level();
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+        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);
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 15:32:02 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                    BlockState type = world.getBlockStateIfLoaded(pos);
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                    if (type != null && !type.isAir()) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                        return false;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                    }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+            }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        return true;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        // Paper end - stop using streams, this is already a known fixed problem in Entity#move
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     @Override
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                                 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                             }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-                            AABB axisalignedbb = this.player.getBoundingBox();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                            AABB axisalignedbb = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                             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
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                             this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                             this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                            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...
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                             // Paper start - prevent position desync
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                             if (this.awaitingPositionFromClient != null) {
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                                 return; // ... thanks Mojang for letting move calls teleport across dimensions.
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								                             }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-25 14:07:39 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                             // Paper start - Add fail move event
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 21:04:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-                            boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2));
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                            // Paper start - optimise out extra getCubes
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 21:04:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                            boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && movedWrongly;
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 16:04:53 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                            this.player.absMoveTo(d0, d1, d2, f, f1); // prevent desync by tping to the set position, dropped for unknown reasons by mojang
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                            if (!this.player.noPhysics && !this.player.isSleeping() && !teleportBack) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                                AABB newBox = this.player.getBoundingBox();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                                if (didCollide || !axisalignedbb.equals(newBox)) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                                    // note: only call after setLocation, or else getBoundingBox is wrong
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                                    teleportBack = this.hasNewCollision(worldserver, this.player, axisalignedbb, newBox);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                                } // else: no collision at all detected, why do we care?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                            }
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 21:04:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                            // 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);
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 16:58:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-04 12:34:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     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
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								         }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    // Paper start - optimise out extra getCubes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    private boolean hasNewCollision(final ServerLevel world, final Entity entity, final AABB oldBox, final AABB newBox) {
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        final List<AABB> collisionsBB = new java.util.ArrayList<>();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        final List<VoxelShape> collisionsVoxel = new java.util.ArrayList<>();
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 06:56:13 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisions(
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+            world, entity, newBox, collisionsVoxel, collisionsBB,
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 06:56:13 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+            ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS | ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+            null, null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        for (int i = 0, len = collisionsBB.size(); i < len; ++i) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+            final AABB box = collisionsBB.get(i);
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 06:56:13 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+            if (!ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.voxelShapeIntersect(box, oldBox)) {
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                return true;
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+            }
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        }
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+        for (int i = 0, len = collisionsVoxel.size(); i < len; ++i) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+            final VoxelShape voxel = collisionsVoxel.get(i);
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 06:56:13 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+            if (!ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.voxelShapeIntersectNoEmpty(voxel, oldBox)) {
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                return true;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+            }
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+        }
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 15:54:36 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        return false;
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 02:56:09 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+    }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    // Paper end - optimise out extra getCubes
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 03:20:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								     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));