9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

New shears wrench (#700)

This commit is contained in:
Lumine1909
2025-08-16 08:36:08 -07:00
committed by GitHub
parent a30c9abbc4
commit 4b21a9687f
6 changed files with 14 additions and 32 deletions

View File

@@ -4,25 +4,6 @@ Date: Sun, 27 Mar 2022 12:48:40 +0800
Subject: [PATCH] Redstone Shears Wrench 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 diff --git a/net/minecraft/world/item/ShearsItem.java b/net/minecraft/world/item/ShearsItem.java
index 8cf3e51e12f9cf98836657e722edb23943f9e866..5fd5e9fd4e1a79dd1a9d62a5cf0c308805979420 100644 index 8cf3e51e12f9cf98836657e722edb23943f9e866..5fd5e9fd4e1a79dd1a9d62a5cf0c308805979420 100644
--- a/net/minecraft/world/item/ShearsItem.java --- a/net/minecraft/world/item/ShearsItem.java

View File

@@ -9,10 +9,10 @@ MasaGadget(https://github.com/plusls/MasaGadget)
litematica(https://github.com/maruohon/litematica) litematica(https://github.com/maruohon/litematica)
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java 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 --- a/net/minecraft/world/item/BlockItem.java
+++ b/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 @Nullable
protected BlockState getPlacementState(BlockPlaceContext context) { protected BlockState getPlacementState(BlockPlaceContext context) {

View File

@@ -85,10 +85,10 @@ index cfbf34964288526e93d0a5b212c1b60296c10430..9cce442c16ced8d9320a5760580ff13f
this.debugLogging(pos, true, sequence, message); this.debugLogging(pos, true, sequence, message);
} else { } else {
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java 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 --- a/net/minecraft/world/item/BlockItem.java
+++ b/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 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 // CraftBukkit end

View File

@@ -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 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 --- a/net/minecraft/world/entity/player/Player.java
+++ b/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 { @@ -287,8 +287,8 @@ public abstract class Player extends LivingEntity {
@@ -69,10 +69,10 @@ index 8ec6f52f58bcc985fdc758a692798a35d6c86378..9e6929e84a4422daa3cd4c92ae641871
@Override @Override
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java 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 --- a/net/minecraft/world/item/BlockItem.java
+++ b/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) { protected boolean canPlace(BlockPlaceContext context, BlockState state) {
Player player = context.getPlayer(); Player player = context.getPlayer();
// CraftBukkit start // CraftBukkit start

View File

@@ -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 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 --- a/net/minecraft/world/item/BlockItem.java
+++ b/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); BlockState blockState = level.getBlockState(clickedPos);
if (blockState.is(placementState.getBlock())) { if (blockState.is(placementState.getBlock())) {
blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState);

View File

@@ -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)) { 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; return null;
} }
if (context.getPlayer() == null || !context.getPlayer().getItemInHand(invert(context.getHand())).isEmpty()) {
return null;
}
StateDefinition<Block, BlockState> blockstatelist = block.getStateDefinition(); StateDefinition<Block, BlockState> blockstatelist = block.getStateDefinition();
Property<?> iblockstate; Property<?> iblockstate;
if (block instanceof CrafterBlock) { if (block instanceof CrafterBlock) {
@@ -89,10 +92,8 @@ public class ShearsWrenchUtil {
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
public static boolean shouldSkipPlace(BlockPlaceContext context) { private static InteractionHand invert(InteractionHand original) {
return LeavesConfig.modify.redstoneShearsWrench && return original == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
context.getPlayer() != null &&
context.getPlayer().getItemInHand(InteractionHand.MAIN_HAND).is(Items.SHEARS);
} }
private static <T extends Comparable<T>> BlockState cycleState(BlockState state, Property<T> property, boolean inverse) { private static <T extends Comparable<T>> BlockState cycleState(BlockState state, Property<T> property, boolean inverse) {