From 6143288a88e6f404511dd46f079a4014f9b299d5 Mon Sep 17 00:00:00 2001 From: Eclipses <99494277+EclipsesDev@users.noreply.github.com> Date: Fri, 30 Aug 2024 21:41:38 +0700 Subject: [PATCH] Fixed updatedncp switchitem bypass previous one fixes switchitem noslow if it is send constantly, but if it send once + c08 packet, previous fix will not work, so this one should patch it --- .../nocheatplus/checks/net/protocollib/NoSlow.java | 9 ++++++++- .../nocheatplus/checks/moving/MovingData.java | 1 + .../nocheatplus/checks/moving/player/SurvivalFly.java | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/NoSlow.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/NoSlow.java index 4e326e980..a78ec143c 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/NoSlow.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/NoSlow.java @@ -216,7 +216,13 @@ private static void onChangeSlot(final PlayerItemHeldEvent e) { // p.getInventory().setHeldItemSlot(data.olditemslot); // data.changeslot = false; //} - if (e.getPreviousSlot() != e.getNewSlot()) data.isUsingItem = false; + if (e.getPreviousSlot() != e.getNewSlot()) { + if ((data.isUsingItem || p.isBlocking()) && data.playerMoves.getCurrentMove() != null) { + p.getInventory().setHeldItemSlot(e.getPreviousSlot()); + data.invalidItemUse = true; + } + data.isUsingItem = false; + } } private static boolean hasArrow(final PlayerInventory i, final boolean fw) { @@ -233,6 +239,7 @@ private void handleBlockPlacePacket(PacketEvent event) { final IPlayerData pData = DataManager.getPlayerData(p); final MovingData data = pData.getGenericInstance(MovingData.class); final PacketContainer packet = event.getPacket(); + final StructureModifier ints = packet.getIntegers(); // Legacy: pre 1.9 if (ints.size() > 0 && !ServerIsAtLeast1_9) { diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index f767a5eec..2f7c6e35a 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -157,6 +157,7 @@ public class MovingData extends ACheckData implements IDataOnRemoveSubCheckData, public long releaseItemTime = 0; /** Detection flag */ public boolean isHackingRI = false; + public boolean invalidItemUse = false; /** Keep track of hopping while using items */ public int noSlowHop = 0; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java index 42e5823ce..be299306c 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java @@ -1197,6 +1197,15 @@ else if (data.isHackingRI && (!checkPermissions || !pData.hasPermission(Permissi friction = 0.0; } + // InvalidUse packet + else if (data.invalidItemUse && (!checkPermissions || !pData.hasPermission(Permissions.MOVING_SURVIVALFLY_BLOCKING, player))) { + tags.add("invalidate_use"); + data.invalidItemUse = false; + hAllowedDistance = 0.0; + useBaseModifiers = false; + friction = 0.0; + } + // Collision tolerance for entities (1.9+) else if (ServerIsAtLeast1_9 && CollisionUtil.isCollidingWithEntities(player, true) && hAllowedDistance < 0.35 && data.liftOffEnvelope == LiftOffEnvelope.NORMAL) {