2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 2 May 2020 03:09:46 -0400
|
|
|
|
Subject: [PATCH] Validate PickItem Packet and kick for invalid
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-07-07 06:52:40 +00:00
|
|
|
index a18a9f86da8015fff02c3efe98c8afbb3ef61235..ca3991e3cea5de32418469540fe70b99ff21bed0 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-07-07 06:52:40 +00:00
|
|
|
@@ -876,7 +876,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-11 12:02:28 +00:00
|
|
|
@Override
|
|
|
|
public void handlePickItem(ServerboundPickItemPacket packet) {
|
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
2021-06-14 01:06:38 +00:00
|
|
|
- this.player.getInventory().pickSlot(packet.getSlot());
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper start - validate pick item position
|
2021-06-14 01:06:38 +00:00
|
|
|
+ if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.getInventory().items.size())) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
|
|
|
+ this.disconnect("Invalid hotbar selection (Hacking?)");
|
|
|
|
+ return;
|
|
|
|
+ }
|
2021-06-14 01:06:38 +00:00
|
|
|
+ this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper end
|
2021-07-07 06:52:40 +00:00
|
|
|
this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, this.player.getInventory().selected, this.player.getInventory().getItem(this.player.getInventory().selected)));
|
|
|
|
this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, packet.getSlot(), this.player.getInventory().getItem(packet.getSlot())));
|
2021-06-14 01:06:38 +00:00
|
|
|
this.player.connection.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected));
|