mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
Improve invalid container event patch (#36)
This commit is contained in:
parent
c2b2427622
commit
3b8ad1a45d
@ -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
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index ca595abe940463a62da033c7082c868c4c4b28d8..6f43eec3490dd44d0f680977710f1d65dc6fc3b2 100644
|
index ca595abe940463a62da033c7082c868c4c4b28d8..d6aa46443b0ec9b02259222d8ee9a7ff0cec4ae7 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/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;
|
@@ -24,6 +24,8 @@ import java.util.function.UnaryOperator;
|
||||||
@ -17,21 +17,23 @@ index ca595abe940463a62da033c7082c868c4c4b28d8..6f43eec3490dd44d0f680977710f1d65
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.CrashReport;
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.CrashReportCategory;
|
import net.minecraft.CrashReportCategory;
|
||||||
@@ -2782,6 +2784,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
@@ -2593,6 +2595,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
}
|
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||||
if (packet.getClickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) {
|
if (this.player.isImmobile()) return; // CraftBukkit
|
||||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
|
||||||
+ if(packet.getSlotNum() > 45)
|
|
||||||
+ {
|
|
||||||
+ this.getCraftPlayer().kick(
|
|
||||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
|
||||||
+ .color(NamedTextColor.RED)
|
|
||||||
+ );
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
+
|
||||||
if (click == ClickType.NUMBER_KEY) {
|
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||||
event = new InventoryClickEvent(inventory, type, packet.getSlotNum(), click, action, packet.getButtonNum());
|
+ final int sentSlotNum = packet.getSlotNum();
|
||||||
} else {
|
+ if(Mth.clamp(sentSlotNum, 0, 45) != sentSlotNum)
|
||||||
|
+ {
|
||||||
|
+ this.getCraftPlayer().kick(
|
||||||
|
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||||
|
+ .color(NamedTextColor.RED)
|
||||||
|
+ );
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
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 New Issue
Block a user