diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java index ae84e64701..abb6958ba1 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java @@ -16,7 +16,6 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; public class PacketPlayerAttack extends PacketListenerAbstract { @@ -58,14 +57,13 @@ public void onPacketReceive(PacketReceiveEvent event) { // 1.8 players who are packet sprinting WILL get slowed // 1.9+ players who are packet sprinting might not, based on attack cooldown // Players with knockback enchantments always get slowed - if ((player.isSprinting && !hasNegativeKB && isLegacyPlayer) || hasKnockbackSword) { - player.minPlayerAttackSlow += 1; - player.maxPlayerAttackSlow += 1; + if ((player.lastSprinting && !hasNegativeKB && isLegacyPlayer) || hasKnockbackSword) { + player.minPlayerAttackSlow++; + player.maxPlayerAttackSlow++; // Players cannot slow themselves twice in one tick without a knockback sword if (!hasKnockbackSword) { - player.minPlayerAttackSlow = 0; - player.maxPlayerAttackSlow = 1; + player.maxPlayerAttackSlow = player.minPlayerAttackSlow = 1; } } else if (!isLegacyPlayer && player.isSprinting) { // 1.9+ players who have attack speed cannot slow themselves twice in one tick because their attack cooldown gets reset on swing. @@ -76,17 +74,10 @@ public void onPacketReceive(PacketReceiveEvent event) { } // 1.9+ player who might have been slowed, but we can't be sure - player.maxPlayerAttackSlow += 1; + player.maxPlayerAttackSlow++; } } } } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { - GrimPlayer player = GrimAPI.INSTANCE.getPlayerDataManager().getPlayer(event.getUser()); - if (player == null) return; - - player.minPlayerAttackSlow = 0; - } } } diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java index 063b7791ae..510f6ba302 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java @@ -364,7 +364,17 @@ private void addNonEffectiveAI(GrimPlayer player, Set data) { private void addAttackSlowToPossibilities(GrimPlayer player, Set velocities) { for (int x = 1; x <= Math.min(player.maxPlayerAttackSlow, 5); x++) { for (VectorData data : new HashSet<>(velocities)) { - velocities.add(data.returnNewModified(data.vector.clone().multiply(new Vector(0.6, 1, 0.6)), VectorData.VectorType.AttackSlow)); + if (player.minPlayerAttackSlow > 0) { + data.vector.setX(data.vector.getX() * 0.6); + data.vector.setZ(data.vector.getZ() * 0.6); + data.addVectorType(VectorData.VectorType.AttackSlow); + } else { + velocities.add(data.returnNewModified(data.vector.clone().multiply(new Vector(0.6, 1, 0.6)), VectorData.VectorType.AttackSlow)); + } + } + + if (player.minPlayerAttackSlow > 0) { + player.minPlayerAttackSlow--; } } } diff --git a/src/main/java/ac/grim/grimac/utils/data/VectorData.java b/src/main/java/ac/grim/grimac/utils/data/VectorData.java index 5c0f7f82b0..6ce46cedf5 100644 --- a/src/main/java/ac/grim/grimac/utils/data/VectorData.java +++ b/src/main/java/ac/grim/grimac/utils/data/VectorData.java @@ -65,7 +65,7 @@ public int hashCode() { return Objects.hash(vectorType, lastVector, preUncertainty, vector, isKnockback, firstBreadKb, isExplosion, firstBreadExplosion, isTrident, isZeroPointZeroThree, isSwimHop, isFlipSneaking, isFlipItem, isJump, isAttackSlow); } - private void addVectorType(VectorType type) { + public void addVectorType(VectorType type) { switch (type) { case Knockback: isKnockback = true;