2022-03-20 13:49:57 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Video <videogamesm12@gmail.com>
|
|
|
|
Date: Sun, 20 Mar 2022 07:46:37 -0600
|
|
|
|
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
|
|
|
when handling Creative Inventory packets
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-03-20 17:40:17 +00:00
|
|
|
index 621ec8e8a197323da6b423fee57c816ac9d7c875..83333ae9c8e8c1edc6e7f02468bd8dc7e44bb66e 100644
|
2022-03-20 13:49:57 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2022-03-20 17:40:17 +00:00
|
|
|
@@ -2933,20 +2933,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2022-03-20 14:38:11 +00:00
|
|
|
if (this.player.gameMode.isCreative()) {
|
|
|
|
boolean flag = packet.getSlotNum() < 0;
|
|
|
|
ItemStack itemstack = packet.getItem();
|
|
|
|
- CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
2022-03-20 13:49:57 +00:00
|
|
|
|
2022-03-20 14:38:11 +00:00
|
|
|
+ CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
2022-03-20 13:49:57 +00:00
|
|
|
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
|
|
|
BlockPos blockposition = new BlockPos(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
|
|
|
- BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
2022-03-20 17:40:17 +00:00
|
|
|
+ // Scissors start - Validate coordinates and whether or not the player can reach them
|
|
|
|
+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) {
|
2022-03-20 13:49:57 +00:00
|
|
|
+ BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
|
|
|
|
|
|
|
- if (tileentity != null) {
|
|
|
|
- CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
|
|
|
+ if (tileentity != null) {
|
|
|
|
+ CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
|
|
|
|
|
|
|
- nbttagcompound1.remove("x");
|
|
|
|
- nbttagcompound1.remove("y");
|
|
|
|
- nbttagcompound1.remove("z");
|
|
|
|
- itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
|
|
|
+ nbttagcompound1.remove("x");
|
|
|
|
+ nbttagcompound1.remove("y");
|
|
|
|
+ nbttagcompound1.remove("z");
|
|
|
|
+ itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
|
|
|
+ }
|
|
|
|
}
|
2022-03-20 17:40:17 +00:00
|
|
|
+ // Scissors end
|
2022-03-20 13:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;
|