2021-06-11 14:02:28 +02: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
|
2024-04-25 05:40:32 +02:00
|
|
|
index 556a10d17acbd558cd4b23f729dc1644ecdd2fed..819ef697b3d88024310745014b4c2457de07db37 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-04-24 08:44:48 +02:00
|
|
|
@@ -898,7 +898,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2021-06-11 14:02:28 +02:00
|
|
|
@Override
|
|
|
|
public void handlePickItem(ServerboundPickItemPacket packet) {
|
2023-06-08 00:58:10 +02:00
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
2021-06-14 03:06:38 +02:00
|
|
|
- this.player.getInventory().pickSlot(packet.getSlot());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - validate pick item position
|
2021-06-14 03:06:38 +02:00
|
|
|
+ if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.getInventory().items.size())) {
|
2021-06-11 14:02:28 +02: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 03:06:38 +02:00
|
|
|
+ this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
|
2024-01-21 12:11:43 +01:00
|
|
|
+ // Paper end - validate pick item position
|
2021-07-07 08:52:40 +02: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 03:06:38 +02:00
|
|
|
this.player.connection.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected));
|