Fix packet-related lag exploits (1.19.4) (#118)

* Fix packet-related lag exploits

* Fix oopsie
This commit is contained in:
Luna 2023-07-05 12:08:30 -03:00 committed by GitHub
parent 65d7993679
commit 5360df819c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,46 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Tue, 4 Jul 2023 18:49:34 -0300
Subject: [PATCH] Fix packet-related lag exploits
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ca6b809f56cf4d28d5a6514c18322419c8184f30..6bbf1a5620a5ab52add56b9fcf9ce92288498dab 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -958,7 +958,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
} else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
- } else {
+ } else if (this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
BaseCommandBlock commandblocklistenerabstract = null;
CommandBlockEntity tileentitycommand = null;
BlockPos blockposition = packet.getPos();
@@ -1122,7 +1122,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
- if (this.player.canUseGameMasterBlocks()) {
+ if (this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
BlockPos blockposition = packet.getPos();
BlockState iblockdata = this.player.level.getBlockState(blockposition);
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
@@ -1180,7 +1180,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
- if (this.player.canUseGameMasterBlocks()) {
+ if (this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
BlockPos blockposition = packet.getPos();
BlockState iblockdata = this.player.level.getBlockState(blockposition);
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
@@ -1203,7 +1203,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
- if (this.player.canUseGameMasterBlocks()) {
+ if (this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
BlockPos blockposition = packet.getPos();
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);