2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-05-02 09:10:26 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 2 May 2020 03:09:46 -0400
|
|
|
|
Subject: [PATCH] Validate PickItem Packet and kick for invalid
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
index b6d326ea30a806240e4a87c277b3cd73a04c805c..6db70005ebc99b19185b8efca550a0783ea05cad 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
@@ -883,7 +883,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2020-05-02 09:10:26 +02:00
|
|
|
@Override
|
|
|
|
public void a(PacketPlayInPickItem packetplayinpickitem) {
|
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinpickitem, this, this.player.getWorldServer());
|
|
|
|
- this.player.inventory.c(packetplayinpickitem.b());
|
|
|
|
+ // Paper start - validate pick item position
|
2020-05-02 19:32:03 +02:00
|
|
|
+ if (!(packetplayinpickitem.b() >= 0 && packetplayinpickitem.b() < this.player.inventory.items.size())) {
|
2020-05-02 09:10:26 +02:00
|
|
|
+ PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString());
|
|
|
|
+ this.disconnect("Invalid hotbar selection (Hacking?)");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.player.inventory.c(packetplayinpickitem.b()); // Paper - Diff above if changed
|
|
|
|
+ // Paper end
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-2, this.player.inventory.itemInHandIndex, this.player.inventory.getItem(this.player.inventory.itemInHandIndex)));
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-2, packetplayinpickitem.b(), this.player.inventory.getItem(packetplayinpickitem.b())));
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
|