diff --git a/lophine-server/minecraft-patches/features/0010-Redstone-Shears-Wrench.patch b/lophine-server/minecraft-patches/features/0010-Redstone-Shears-Wrench.patch new file mode 100644 index 0000000..83f9db7 --- /dev/null +++ b/lophine-server/minecraft-patches/features/0010-Redstone-Shears-Wrench.patch @@ -0,0 +1,153 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Wed, 23 Jul 2025 20:28:40 +0800 +Subject: [PATCH] Redstone Shears Wrench + +Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> +As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/bfde470a867b74d177fe1b9a2a3ed5c49cd126c7/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/world/item/ShearsItem.java b/net/minecraft/world/item/ShearsItem.java +index 8cf3e51e12f9cf98836657e722edb23943f9e866..dc3e33223ac7b11a969ef1a8e3fa73a9b8b44696 100644 +--- a/net/minecraft/world/item/ShearsItem.java ++++ b/net/minecraft/world/item/ShearsItem.java +@@ -24,6 +24,30 @@ import net.minecraft.world.level.block.GrowingPlantHeadBlock; + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.gameevent.GameEvent; + ++// Leaves start - shears wrench ++import net.minecraft.Util; ++import net.minecraft.network.chat.Component; ++import net.minecraft.world.level.block.ComparatorBlock; ++import net.minecraft.world.level.block.DispenserBlock; ++import net.minecraft.world.level.block.HopperBlock; ++import net.minecraft.world.level.block.ObserverBlock; ++import net.minecraft.world.level.block.RepeaterBlock; ++import net.minecraft.world.level.block.CrafterBlock; ++import net.minecraft.world.level.block.LeverBlock; ++import net.minecraft.world.level.block.CocoaBlock; ++import net.minecraft.world.level.block.TrapDoorBlock; ++import net.minecraft.world.level.block.FenceGateBlock; ++import net.minecraft.world.level.block.LightningRodBlock; ++import net.minecraft.world.level.block.RailBlock; ++import net.minecraft.world.level.block.BaseRailBlock; ++import net.minecraft.world.level.block.PoweredRailBlock; ++import net.minecraft.world.level.block.CalibratedSculkSensorBlock; ++import net.minecraft.world.level.block.piston.PistonBaseBlock; ++import net.minecraft.world.level.block.state.StateDefinition; ++import net.minecraft.world.level.block.state.properties.RailShape; ++import net.minecraft.world.level.block.state.properties.Property; ++// Leaves end - shears wrench ++ + public class ShearsItem extends Item { + public ShearsItem(Item.Properties properties) { + super(properties); +@@ -80,7 +104,108 @@ public class ShearsItem extends Item { + + return InteractionResult.SUCCESS; + } else { ++ // Leaves start - shears wrench ++ Block block = blockState.getBlock(); ++ if (fun.bm.lophine.config.modules.misc.RedStoneConfig.shears && ++ 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 ++ ) { ++ StateDefinition blockstatelist = block.getStateDefinition(); ++ Property iblockstate; ++ if (block instanceof CrafterBlock) iblockstate = blockstatelist.getProperty("orientation"); ++ else if (block instanceof BaseRailBlock) iblockstate = blockstatelist.getProperty("shape"); ++ else iblockstate = blockstatelist.getProperty("facing"); ++ Player player = context.getPlayer(); ++ ++ if (iblockstate == null || player == null) { ++ return InteractionResult.FAIL; ++ } ++ ++ if (block instanceof BaseRailBlock) { ++ if (block instanceof RailBlock) { ++ if (blockState.getValue(RailBlock.SHAPE).isSlope()) { ++ return InteractionResult.FAIL; ++ } ++ } else { ++ if (getNameHelper(blockState, PoweredRailBlock.POWERED).equals("true")) { ++ return InteractionResult.FAIL; ++ } ++ if (blockState.getValue(PoweredRailBlock.SHAPE).isSlope()) { ++ return InteractionResult.FAIL; ++ } ++ } ++ } ++ ++ if (block instanceof PistonBaseBlock) { ++ if (getNameHelper(blockState, PistonBaseBlock.EXTENDED).equals("true")) { ++ return InteractionResult.FAIL; ++ } ++ } ++ ++ if (block instanceof RepeaterBlock || block instanceof ComparatorBlock) { ++ if (getNameHelper(blockState, ComparatorBlock.POWERED).equals("true")) { ++ return InteractionResult.FAIL; ++ } ++ if (block instanceof RepeaterBlock) { ++ if (getNameHelper(blockState, RepeaterBlock.LOCKED).equals("true")) { ++ return InteractionResult.FAIL; ++ } ++ } ++ } ++ ++ if (block instanceof CrafterBlock) { ++ if (getNameHelper(blockState, CrafterBlock.CRAFTING).equals("true")) { ++ return InteractionResult.FAIL; ++ } ++ } ++ ++ BlockState iblockdata1 = ShearsItem.cycleState(blockState, iblockstate, player.isSecondaryUseActive()); ++ level.setBlock(clickedPos, iblockdata1, 18); ++ ShearsItem.message(player, Component.translatable("item.minecraft.debug_stick.update", iblockstate.getName(), ShearsItem.getNameHelper(iblockdata1, iblockstate))); ++ return InteractionResult.CONSUME; ++ } ++ // Leaves end - shears wrench ++ + return super.useOn(context); + } + } ++ ++ // Leaves start - shears wrench ++ private static > BlockState cycleState(BlockState state, Property property, boolean inverse) { ++ List possibleValues = property.getPossibleValues(); ++ if (possibleValues.getFirst() instanceof RailShape) { ++ boolean isRailBlock = state.getBlock() instanceof RailBlock; ++ possibleValues = possibleValues.stream().filter(possibleValue -> { ++ RailShape shape = (RailShape) possibleValue; ++ if (isRailBlock) return !shape.isSlope(); ++ return !shape.isSlope() && shape != RailShape.NORTH_EAST && shape != RailShape.NORTH_WEST && shape != RailShape.SOUTH_EAST && shape != RailShape.SOUTH_WEST; ++ }).toList(); ++ } ++ return state.setValue(property, ShearsItem.getRelative(possibleValues, state.getValue(property), inverse)); // CraftBukkit - decompile error ++ } ++ ++ private static T getRelative(Iterable elements, T current, boolean inverse) { ++ return inverse ? Util.findPreviousInIterable(elements, current) : Util.findNextInIterable(elements, current); ++ } ++ ++ private static void message(Player player, Component message) { ++ ((ServerPlayer) player).sendSystemMessage(message, true); ++ } ++ ++ private static > String getNameHelper(BlockState state, Property property) { ++ return property.getName(state.getValue(property)); ++ } ++ // Leaves end - shears wrench + } diff --git a/lophine-server/minecraft-patches/features/0010-Stackable-ShulkerBoxes.patch b/lophine-server/minecraft-patches/features/0011-Stackable-ShulkerBoxes.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0010-Stackable-ShulkerBoxes.patch rename to lophine-server/minecraft-patches/features/0011-Stackable-ShulkerBoxes.patch diff --git a/lophine-server/minecraft-patches/features/0011-Spawn-invulnerable-time.patch b/lophine-server/minecraft-patches/features/0012-Spawn-invulnerable-time.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0011-Spawn-invulnerable-time.patch rename to lophine-server/minecraft-patches/features/0012-Spawn-invulnerable-time.patch diff --git a/lophine-server/minecraft-patches/features/0012-Old-Explosion-Damage-Calculator.patch b/lophine-server/minecraft-patches/features/0013-Old-Explosion-Damage-Calculator.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0012-Old-Explosion-Damage-Calculator.patch rename to lophine-server/minecraft-patches/features/0013-Old-Explosion-Damage-Calculator.patch diff --git a/lophine-server/minecraft-patches/features/0013-Old-replaceable-by-mushrooms.patch b/lophine-server/minecraft-patches/features/0014-Old-replaceable-by-mushrooms.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0013-Old-replaceable-by-mushrooms.patch rename to lophine-server/minecraft-patches/features/0014-Old-replaceable-by-mushrooms.patch diff --git a/lophine-server/minecraft-patches/features/0014-Old-zombie-reinforcement.patch b/lophine-server/minecraft-patches/features/0015-Old-zombie-reinforcement.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0014-Old-zombie-reinforcement.patch rename to lophine-server/minecraft-patches/features/0015-Old-zombie-reinforcement.patch diff --git a/lophine-server/minecraft-patches/features/0015-I18n-support.patch b/lophine-server/minecraft-patches/features/0016-I18n-support.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0015-I18n-support.patch rename to lophine-server/minecraft-patches/features/0016-I18n-support.patch diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java new file mode 100644 index 0000000..23d4048 --- /dev/null +++ b/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java @@ -0,0 +1,21 @@ +package fun.bm.lophine.config.modules.misc; + +import me.earthme.luminol.config.EnumConfigCategory; +import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.flags.ConfigInfo; + +public class RedStoneConfig implements IConfigModule { + @ConfigInfo(baseName = "allow_skip_cooldown", comments = + """ + Allows you to use the Shears to right-click to rotate the block.""") + public static boolean shears = false; + @Override + public EnumConfigCategory getCategory() { + return EnumConfigCategory.MISC; + } + + @Override + public String getBaseName() { + return "redstone"; + } +} \ No newline at end of file