diff options
author | maxcom1 <[email protected]> | 2024-03-23 22:26:17 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-23 17:26:17 -0400 |
commit | b6001403e9703cadaa6e8c8558e732b91c3c6d6e (patch) | |
tree | a8c57bbc334a8ad48d4ad2b43db335667b142bee /patches/server/0690-Reset-placed-block-on-exception.patch | |
parent | 9ec7dfcbc41c6e625de0050b6997160a75df9f44 (diff) | |
download | Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.tar.gz Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.zip |
Add methods to change entity physics (#10334)
Diffstat (limited to 'patches/server/0690-Reset-placed-block-on-exception.patch')
-rw-r--r-- | patches/server/0690-Reset-placed-block-on-exception.patch | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/patches/server/0690-Reset-placed-block-on-exception.patch b/patches/server/0690-Reset-placed-block-on-exception.patch new file mode 100644 index 0000000000..b6bf08780c --- /dev/null +++ b/patches/server/0690-Reset-placed-block-on-exception.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nassim Jahnke <[email protected]> +Date: Fri, 7 Jan 2022 11:45:15 +0100 +Subject: [PATCH] Reset placed block on exception + + +diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java +index c19069f65a9ecbc9000ea4333417a2df4ace1007..1ac739c92031e80c35e1af4417e6358346079580 100644 +--- a/src/main/java/net/minecraft/world/item/BlockItem.java ++++ b/src/main/java/net/minecraft/world/item/BlockItem.java +@@ -80,6 +80,7 @@ public class BlockItem extends Item { + if (this instanceof PlaceOnWaterBlockItem || this instanceof SolidBucketItem) { + blockstate = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getLevel(), blockactioncontext1.getClickedPos()); + } ++ final org.bukkit.block.BlockState oldBlockstate = blockstate != null ? blockstate : org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getLevel(), blockactioncontext1.getClickedPos()); // Paper - Reset placed block on exception + // CraftBukkit end + + if (iblockdata == null) { +@@ -95,7 +96,19 @@ public class BlockItem extends Item { + + if (iblockdata1.is(iblockdata.getBlock())) { + iblockdata1 = this.updateBlockStateFromTag(blockposition, world, itemstack, iblockdata1); ++ // Paper start - Reset placed block on exception ++ try { + this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1); ++ } catch (Exception e) { ++ oldBlockstate.update(true, false); ++ if (entityhuman instanceof ServerPlayer player) { ++ org.apache.logging.log4j.LogManager.getLogger().error("Player {} tried placing invalid block", player.getScoreboardName(), e); ++ player.getBukkitEntity().kickPlayer("Packet processing error"); ++ return InteractionResult.FAIL; ++ } ++ throw e; // Rethrow exception if not placed by a player ++ } ++ // Paper end - Reset placed block on exception + iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack); + // CraftBukkit start + if (blockstate != null) { |