2022-07-28 03:57:50 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Allink <arclicious@vivaldi.net>
|
|
|
|
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
|
|
|
Subject: [PATCH] Prevent invalid container events
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-12-11 01:20:31 +00:00
|
|
|
index 987001ab3a7cdd1c8c37e528077e5d33060ab505..87d5f576ef8be68256191df7c3bf4f081c2e7370 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-12-11 01:20:31 +00:00
|
|
|
@@ -29,6 +29,7 @@ import java.util.function.UnaryOperator;
|
2023-10-15 22:45:13 +00:00
|
|
|
import java.util.stream.Collectors;
|
2022-07-28 03:57:50 +00:00
|
|
|
import java.util.stream.Stream;
|
|
|
|
import javax.annotation.Nullable;
|
2023-07-01 20:21:13 +00:00
|
|
|
+import net.kyori.adventure.text.format.NamedTextColor; // Scissors
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.ChatFormatting;
|
2023-09-24 21:42:28 +00:00
|
|
|
import net.minecraft.SharedConstants;
|
|
|
|
import net.minecraft.Util;
|
2023-12-11 01:20:31 +00:00
|
|
|
@@ -2902,6 +2903,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2022-07-28 03:57:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Scissors start - Do not call events when the slot/button number is invalid
|
|
|
|
+ final int sentSlotNum = packet.getSlotNum();
|
|
|
|
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
|
|
|
+ {
|
|
|
|
+ this.getCraftPlayer().kick(
|
|
|
|
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
|
|
|
+ .color(NamedTextColor.RED)
|
|
|
|
+ );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
+
|
|
|
|
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
|
|
|
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
|
|
|
|