mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-14 19:34:54 -05:00
Improve invalid container event patch (#37)
This commit is contained in:
parent
b30b7223e5
commit
3ea91b9dbc
1 changed files with 20 additions and 18 deletions
|
@ -5,7 +5,7 @@ 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
|
||||
index b0bd0412010320cc624535d6abffe417a135a4dc..e8157a809ed2b018dfd155e8bc712a8c73aa79e6 100644
|
||||
index b0bd0412010320cc624535d6abffe417a135a4dc..0d8d28a324b4bf093d7318be71eb67bb0dad9429 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -24,6 +24,8 @@ import java.util.function.UnaryOperator;
|
||||
|
@ -17,12 +17,14 @@ index b0bd0412010320cc624535d6abffe417a135a4dc..e8157a809ed2b018dfd155e8bc712a8c
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -2836,6 +2838,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
}
|
||||
|
||||
if (packet.getClickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) {
|
||||
@@ -2642,6 +2644,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (this.player.isImmobile()) return; // CraftBukkit
|
||||
+
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ if(packet.getSlotNum() > 45)
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if(Mth.clamp(sentSlotNum, 0, 45) != sentSlotNum)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
|
@ -32,6 +34,6 @@ index b0bd0412010320cc624535d6abffe417a135a4dc..e8157a809ed2b018dfd155e8bc712a8c
|
|||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (click == ClickType.NUMBER_KEY) {
|
||||
event = new InventoryClickEvent(inventory, type, packet.getSlotNum(), click, action, packet.getButtonNum());
|
||||
} else {
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
||||
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
||||
|
|
Loading…
Reference in a new issue