From 1a748f754c5a0b92d9bbf2e951753f21d651a840 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 20 Mar 2022 06:32:37 -0600 Subject: [PATCH 1/3] Downgrades Paperclip to 2.0.1 Now you can actually create functional paperclip jars. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6226a31..9ae1adb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ repositories { dependencies { remapper("net.fabricmc:tiny-remapper:0.8.1:fat") decompiler("net.minecraftforge:forgeflower:1.5.498.22") - paperclip("io.papermc:paperclip:3.0.2") + paperclip("io.papermc:paperclip:2.0.1") } allprojects { From 72b21094502c4f8a80127cdfdd2f20525d4e5ebf Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 20 Mar 2022 07:49:57 -0600 Subject: [PATCH 2/3] Validate coordinates before attempting to get block entities when handling Creative Inventory packets --- ...ates-before-attempting-to-get-block-.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch diff --git a/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch b/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch new file mode 100644 index 0000000..73ed5fa --- /dev/null +++ b/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Video +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 +index 621ec8e8a197323da6b423fee57c816ac9d7c875..f3d6b9b8db85c8e93a3af161c15b7aa873ebc5cf 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2937,16 +2937,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + + 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); ++ // Scissors start - Validate coordinates before anything else ++ if (Level.isInSpawnableBounds(blockposition)) ++ { ++ 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); ++ } + } ++ // Scissors end + } + + boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45; From dcef1afe08d41464b583852971a15f1aa38b2c12 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 20 Mar 2022 08:38:11 -0600 Subject: [PATCH 3/3] A better solution Realized what they are doing. Will rename commit later --- ...dinates-before-attempting-to-get-block-.patch | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch b/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch index 73ed5fa..61f08d8 100644 --- a/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch +++ b/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch @@ -6,16 +6,21 @@ Subject: [PATCH] Validate coordinates before attempting to get block entities diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 621ec8e8a197323da6b423fee57c816ac9d7c875..f3d6b9b8db85c8e93a3af161c15b7aa873ebc5cf 100644 +index 621ec8e8a197323da6b423fee57c816ac9d7c875..88d1620ba81eaa2d868401951a264fe0e0f998c6 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2937,16 +2937,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -2933,21 +2933,26 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + if (this.player.gameMode.isCreative()) { + boolean flag = packet.getSlotNum() < 0; + ItemStack itemstack = packet.getItem(); +- CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag"); ++ /* Scissors - Do not pre-load chunks ++ CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag"); 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); -+ // Scissors start - Validate coordinates before anything else -+ if (Level.isInSpawnableBounds(blockposition)) ++ if (Level.isInSpawnableBounds(blockposition) && blockposition.getY() < 255) + { + BlockEntity tileentity = this.player.level.getBlockEntity(blockposition); @@ -34,7 +39,8 @@ index 621ec8e8a197323da6b423fee57c816ac9d7c875..f3d6b9b8db85c8e93a3af161c15b7aa8 + itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1); + } } -+ // Scissors end } ++ */ boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45; + boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();