From 6ca78631c6237d9e10ea423be4603bc94868c12b Mon Sep 17 00:00:00 2001 From: MWHunter Date: Mon, 4 Sep 2023 20:33:36 -0500 Subject: [PATCH] fix 1133 --- .../grim/grimac/checks/impl/velocity/ExplosionHandler.java | 6 ++++-- .../grim/grimac/checks/impl/velocity/KnockbackHandler.java | 6 ++++-- .../ac/grim/grimac/events/packets/CheckManagerListener.java | 6 +++--- .../ac/grim/grimac/events/packets/PacketPlayerSteer.java | 4 ++-- .../grim/grimac/predictionengine/PointThreeEstimator.java | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java index e71e9998c9..497eff567f 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java @@ -184,13 +184,15 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) { } - public VelocityData getPossibleExplosions(int lastTransaction) { + public VelocityData getPossibleExplosions(int lastTransaction, boolean isJustTesting) { handleTransactionPacket(lastTransaction); if (lastExplosionsKnownTaken == null) return null; VelocityData returnLastExplosion = lastExplosionsKnownTaken; - lastExplosionsKnownTaken = null; + if (!isJustTesting) { + lastExplosionsKnownTaken = null; + } return returnLastExplosion; } diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java index 1cfbabdbf0..b09fa481e5 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java @@ -92,7 +92,7 @@ private void addPlayerKnockback(int entityID, int breadOne, Vector knockback) { firstBreadMap.add(new VelocityData(entityID, breadOne, player.getSetbackTeleportUtil().isSendingSetback, knockback)); } - public VelocityData calculateRequiredKB(int entityID, int transaction) { + public VelocityData calculateRequiredKB(int entityID, int transaction, boolean isJustTesting) { tickKnockback(transaction); VelocityData returnLastKB = null; @@ -101,7 +101,9 @@ public VelocityData calculateRequiredKB(int entityID, int transaction) { returnLastKB = data; } - lastKnockbackKnownTaken.clear(); + if (!isJustTesting) { + lastKnockbackKnownTaken.clear(); + } return returnLastKB; } diff --git a/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java b/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java index 5fa7352a77..3f912891aa 100644 --- a/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java +++ b/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java @@ -378,12 +378,12 @@ public void onPacketReceive(PacketReceiveEvent event) { int kbEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID; VelocityData calculatedFirstBreadKb = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(kbEntityId, player.lastTransactionReceived.get()); - VelocityData calculatedRequireKb = player.checkManager.getKnockbackHandler().calculateRequiredKB(kbEntityId, player.lastTransactionReceived.get()); + VelocityData calculatedRequireKb = player.checkManager.getKnockbackHandler().calculateRequiredKB(kbEntityId, player.lastTransactionReceived.get(), false); player.firstBreadKB = calculatedFirstBreadKb == null ? player.firstBreadKB : calculatedFirstBreadKb; player.likelyKB = calculatedRequireKb == null ? player.likelyKB : calculatedRequireKb; VelocityData calculateFirstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get()); - VelocityData calculateRequiredExplosion = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get()); + VelocityData calculateRequiredExplosion = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), false); player.firstBreadExplosion = calculateFirstBreadExplosion == null ? player.firstBreadExplosion : calculateFirstBreadExplosion; player.likelyExplosions = calculateRequiredExplosion == null ? player.likelyExplosions : calculateRequiredExplosion; } @@ -492,7 +492,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if ((placedWith.getType().getPlacedType() != null || placedWith.getType() == ItemTypes.FIRE_CHARGE) && !player.compensatedEntities.getSelf().inVehicle()) player.checkManager.onBlockPlace(blockPlace); - if (blockPlace.isCancelled() || player.getSetbackTeleportUtil().shouldBlockMovement()) { // The player tried placing blocks in air/water + if (true || blockPlace.isCancelled() || player.getSetbackTeleportUtil().shouldBlockMovement()) { // The player tried placing blocks in air/water event.setCancelled(true); player.onPacketCancel(); diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java index bc140dc26b..f15a5a9ffb 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java @@ -62,7 +62,7 @@ public void onPacketReceive(PacketReceiveEvent event) { // Update knockback and explosions after getting the vehicle int controllingEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID; player.firstBreadKB = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(controllingEntityId, player.lastTransactionReceived.get()); - player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get()); + player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get(), false); // The player still applies kb even if they aren't in control of the vehicle, for some reason if (player.firstBreadKB != null) { @@ -73,7 +73,7 @@ public void onPacketReceive(PacketReceiveEvent event) { } player.firstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get()); - player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get()); + player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), false); // Not responsible for applying knockback/explosions player.checkManager.getExplosionHandler().forceExempt(); diff --git a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java index f5227dc176..b771405a55 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java @@ -151,10 +151,10 @@ public void handleChangeBlock(int x, int y, int z, WrappedBlockState state) { // https://github.com/MWHunter/Grim/issues/613 int controllingEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID; player.firstBreadKB = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(controllingEntityId, player.lastTransactionReceived.get()); - player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get()); + player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get(), true); player.firstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get()); - player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get()); + player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), true); player.updateVelocityMovementSkipping();