From c28364c5dd4f2cff78fba1a294e0d384274be479 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:06:07 -0400 Subject: [PATCH] Prevent large ArrayLists from growing on collision checks See #2540 - not confirmed to be resolved as we weren't able to replicate a cause for this issue but this solved the issue from artifically invoking it. --- .../network/session/GeyserSession.java | 2 +- .../network/session/cache/PistonCache.java | 2 +- .../player/BedrockMovePlayerTranslator.java | 2 +- .../collision/CollisionManager.java | 25 ++++++++++++------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index c9c42e756..97773458c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -929,7 +929,7 @@ public class GeyserSession implements CommandSender { // Check to see if the player's position needs updating - a position update should be sent once every 3 seconds if (spawned && (System.currentTimeMillis() - lastMovementTimestamp) > 3000) { // Recalculate in case something else changed position - Vector3d position = collisionManager.adjustBedrockPosition(playerEntity.getPosition(), playerEntity.isOnGround()); + Vector3d position = collisionManager.adjustBedrockPosition(playerEntity.getPosition(), playerEntity.isOnGround(), false); // A null return value cancels the packet if (position != null) { ClientPlayerPositionPacket packet = new ClientPlayerPositionPacket(playerEntity.isOnGround(), diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/PistonCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/PistonCache.java index aa929759c..a0bed9ad4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/PistonCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/PistonCache.java @@ -150,7 +150,7 @@ public class PistonCache { Vector3d delta = totalDisplacement.sub(playerDisplacement); // Check if the piston is pushing a player into collision - delta = session.getCollisionManager().correctPlayerMovement(delta, true); + delta = session.getCollisionManager().correctPlayerMovement(delta, true, false); session.getCollisionManager().getPlayerBoundingBox().translate(delta.getX(), delta.getY(), delta.getZ()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockMovePlayerTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockMovePlayerTranslator.java index b0ab3f1e4..869af9ae6 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockMovePlayerTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/entity/player/BedrockMovePlayerTranslator.java @@ -97,7 +97,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator