diff --git a/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch b/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch index 3fae639c..6967f23a 100644 --- a/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch +++ b/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch @@ -4,25 +4,6 @@ Date: Sun, 27 Mar 2022 12:48:40 +0800 Subject: [PATCH] Redstone Shears Wrench -diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 6db566adf2d0df1d26221eda04aa01738df6d3d2..24ebfdf98e343a7892af621d032c35819156deec 100644 ---- a/net/minecraft/world/item/BlockItem.java -+++ b/net/minecraft/world/item/BlockItem.java -@@ -56,6 +56,14 @@ public class BlockItem extends Item { - if (blockPlaceContext == null) { - return InteractionResult.FAIL; - } else { -+ // Leaves start - shears wrench -+ if (org.leavesmc.leaves.util.ShearsWrenchUtil.shouldSkipPlace(context)) { -+ if (context.getPlayer() != null) { -+ context.getPlayer().containerMenu.forceHeldSlot(blockPlaceContext.getHand()); -+ } -+ return InteractionResult.FAIL; -+ } -+ // Leaves end - shears wrench - BlockState placementState = this.getPlacementState(blockPlaceContext); - // CraftBukkit start - special case for handling block placement with water lilies and snow buckets - org.bukkit.block.BlockState bukkitState = null; diff --git a/net/minecraft/world/item/ShearsItem.java b/net/minecraft/world/item/ShearsItem.java index 8cf3e51e12f9cf98836657e722edb23943f9e866..5fd5e9fd4e1a79dd1a9d62a5cf0c308805979420 100644 --- a/net/minecraft/world/item/ShearsItem.java diff --git a/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch b/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch index 60dab362..c2c5ef80 100644 --- a/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch @@ -9,10 +9,10 @@ MasaGadget(https://github.com/plusls/MasaGadget) litematica(https://github.com/maruohon/litematica) diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 24ebfdf98e343a7892af621d032c35819156deec..8eafee0225377d53650435091c4b1d865e0d487b 100644 +index 6db566adf2d0df1d26221eda04aa01738df6d3d2..8f112f382190d606a87f38da8bcdf8dd5f31d1c5 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -157,7 +157,7 @@ public class BlockItem extends Item { +@@ -149,7 +149,7 @@ public class BlockItem extends Item { @Nullable protected BlockState getPlacementState(BlockPlaceContext context) { diff --git a/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch b/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch index fb75cda1..c259c03f 100644 --- a/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch +++ b/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch @@ -85,10 +85,10 @@ index cfbf34964288526e93d0a5b212c1b60296c10430..9cce442c16ced8d9320a5760580ff13f this.debugLogging(pos, true, sequence, message); } else { diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 8eafee0225377d53650435091c4b1d865e0d487b..bf5ecf388b2ae69a0b093f65acf2169ae9488c4b 100644 +index 8f112f382190d606a87f38da8bcdf8dd5f31d1c5..a46a50d1385897cc7fcf0d6976f0de7e8078d260 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -73,6 +73,21 @@ public class BlockItem extends Item { +@@ -65,6 +65,21 @@ public class BlockItem extends Item { final org.bukkit.block.BlockState oldBukkitState = bukkitState != null ? bukkitState : org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockPlaceContext.getLevel(), blockPlaceContext.getClickedPos()); // Paper - Reset placed block on exception // CraftBukkit end diff --git a/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch b/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch index 654e96ae..50bf5f9b 100644 --- a/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch +++ b/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Creative fly no clip diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 8ec6f52f58bcc985fdc758a692798a35d6c86378..9e6929e84a4422daa3cd4c92ae64187193b6044a 100644 +index 8ec6f52f58bcc985fdc758a692798a35d6c86378..61baebc707cb6afcaf8c7f56fd906813d309a2cf 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java @@ -287,8 +287,8 @@ public abstract class Player extends LivingEntity { @@ -69,10 +69,10 @@ index 8ec6f52f58bcc985fdc758a692798a35d6c86378..9e6929e84a4422daa3cd4c92ae641871 @Override diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index bf5ecf388b2ae69a0b093f65acf2169ae9488c4b..a6e15400b927cab2295c14d617c6157ca34252e4 100644 +index a46a50d1385897cc7fcf0d6976f0de7e8078d260..593e65ef3a768d4039047e42e666c8382a5d38eb 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -193,8 +193,9 @@ public class BlockItem extends Item { +@@ -185,8 +185,9 @@ public class BlockItem extends Item { protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); // CraftBukkit start diff --git a/leaves-server/minecraft-patches/features/0118-Do-not-reset-placed-block-on-exception.patch b/leaves-server/minecraft-patches/features/0118-Do-not-reset-placed-block-on-exception.patch index 73596933..11a77121 100644 --- a/leaves-server/minecraft-patches/features/0118-Do-not-reset-placed-block-on-exception.patch +++ b/leaves-server/minecraft-patches/features/0118-Do-not-reset-placed-block-on-exception.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not reset placed block on exception diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index a6e15400b927cab2295c14d617c6157ca34252e4..7ddbf7d600120b992a04364fe03675d4e216f3ec 100644 +index 593e65ef3a768d4039047e42e666c8382a5d38eb..cf143589407dc2146c9ce18f509077017fba0b48 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -100,20 +100,22 @@ public class BlockItem extends Item { +@@ -92,20 +92,22 @@ public class BlockItem extends Item { BlockState blockState = level.getBlockState(clickedPos); if (blockState.is(placementState.getBlock())) { blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java index 545436ba..07fb9a13 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java @@ -30,6 +30,9 @@ public class ShearsWrenchUtil { if (!LeavesConfig.modify.redstoneShearsWrench || !(block instanceof ObserverBlock || block instanceof DispenserBlock || block instanceof PistonBaseBlock || block instanceof HopperBlock || block instanceof RepeaterBlock || block instanceof ComparatorBlock || block instanceof CrafterBlock || block instanceof LeverBlock || block instanceof CocoaBlock || block instanceof TrapDoorBlock || block instanceof FenceGateBlock || block instanceof LightningRodBlock || block instanceof CalibratedSculkSensorBlock || block instanceof BaseRailBlock)) { return null; } + if (context.getPlayer() == null || !context.getPlayer().getItemInHand(invert(context.getHand())).isEmpty()) { + return null; + } StateDefinition blockstatelist = block.getStateDefinition(); Property iblockstate; if (block instanceof CrafterBlock) { @@ -89,10 +92,8 @@ public class ShearsWrenchUtil { return InteractionResult.CONSUME; } - public static boolean shouldSkipPlace(BlockPlaceContext context) { - return LeavesConfig.modify.redstoneShearsWrench && - context.getPlayer() != null && - context.getPlayer().getItemInHand(InteractionHand.MAIN_HAND).is(Items.SHEARS); + private static InteractionHand invert(InteractionHand original) { + return original == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } private static > BlockState cycleState(BlockState state, Property property, boolean inverse) {