Skip to content

Commit

Permalink
Merge pull request #1612 from ManInMyVan/fix/bpU-understacked
Browse files Browse the repository at this point in the history
Don't check item amount in BadPacketsU
  • Loading branch information
AoElite authored Jul 23, 2024
2 parents 23d80f9 + ee0148f commit 167d453
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.item.ItemStack;
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.world.BlockFace;
Expand All @@ -29,8 +32,7 @@ public void onPacketReceive(final PacketReceiveEvent event) {
// except y gets wrapped?
final int expectedY = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8) ? 4095 : 255;

// never sent when not holding anything
final boolean failedItemCheck = packet.getItemStack().isPresent() && packet.getItemStack().get().isEmpty()
final boolean failedItemCheck = packet.getItemStack().isPresent() && isEmpty(packet.getItemStack().get())
// ViaVersion can sometimes cause this part of the check to false
&& player.getClientVersion().isOlderThan(ClientVersion.V_1_9);

Expand Down Expand Up @@ -58,4 +60,8 @@ public void onPacketReceive(final PacketReceiveEvent event) {
}
}
}

private boolean isEmpty(ItemStack itemStack) {
return itemStack.getType() == null || itemStack.getType() == ItemTypes.AIR;
}
}

0 comments on commit 167d453

Please sign in to comment.