Skip to content

Commit

Permalink
Merge pull request Updated-NoCheatPlus#369 from EclipsesDev/fix-noslow
Browse files Browse the repository at this point in the history
Fixed updatedncp switchitem bypass
  • Loading branch information
Lysandr0 authored Sep 4, 2024
2 parents dd2136e + 6143288 commit 38d0486
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<Integer> ints = packet.getIntegers();
// Legacy: pre 1.9
if (ints.size() > 0 && !ServerIsAtLeast1_9) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 38d0486

Please sign in to comment.