From 2f41057c3bd123ad1d8480c6d1a45d65f959012c Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Sat, 21 Jun 2025 10:54:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(block):=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=8D=E8=BF=9E=E6=8E=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/behavior/StairsBlockBehavior.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StairsBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StairsBlockBehavior.java index 346a179d9..7aa395877 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StairsBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StairsBlockBehavior.java @@ -39,10 +39,11 @@ public class StairsBlockBehavior extends BukkitBlockBehavior { Direction clickedFace = context.getClickedFace(); BlockPos clickedPos = context.getClickedPos(); Object fluidState = FastNMS.INSTANCE.method$Level$getFluidState(context.getLevel().serverWorld(), LocationUtils.toBlockPos(clickedPos)); - return state.owner().value().defaultState() + ImmutableBlockState blockState = state.owner().value().defaultState() .with(this.facingProperty, context.getHorizontalDirection().toHorizontalDirection()) .with(this.halfProperty, clickedFace != Direction.DOWN && (clickedFace == Direction.UP || !(context.getClickLocation().y - clickedPos.y() > 0.5)) ? SingleBlockHalf.BOTTOM : SingleBlockHalf.TOP) .with(this.waterloggedProperty, FastNMS.INSTANCE.method$FluidState$getType(fluidState) == MFluids.WATER); + return blockState.with(this.shapeProperty, getStairsShape(blockState, context.getLevel().serverWorld(), clickedPos)); } @Override @@ -128,27 +129,27 @@ public class StairsBlockBehavior extends BukkitBlockBehavior { private StairsShape getStairsShape(ImmutableBlockState state, Object level, BlockPos blockPos) { Direction direction = state.get(this.facingProperty).toDirection(); Object blockState = FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, LocationUtils.toBlockPos(blockPos.relative(direction))); - StairsShape straight1 = getStairsShape(state, level, blockPos, blockState, direction); + StairsShape straight1 = getStairsShape(state, level, blockPos, blockState, direction, true); if (straight1 != null) return straight1; Object blockState1 = FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, LocationUtils.toBlockPos(blockPos.relative(direction.opposite()))); - StairsShape straight = getStairsShape(state, level, blockPos, blockState1, direction); + StairsShape straight = getStairsShape(state, level, blockPos, blockState1, direction, false); if (straight != null) return straight; return StairsShape.STRAIGHT; } @Nullable - private StairsShape getStairsShape(ImmutableBlockState state, Object level, BlockPos blockPos, Object blockState1, Direction direction) { + private StairsShape getStairsShape(ImmutableBlockState state, Object level, BlockPos blockPos, Object blockState1, Direction direction, boolean opposite) { if (isStairs(blockState1)) { int stateId = BlockStateUtils.blockStateToId(blockState1); ImmutableBlockState immutableBlockState = BukkitBlockManager.instance().getImmutableBlockState(stateId); if (immutableBlockState == null || immutableBlockState.isEmpty()) return StairsShape.STRAIGHT; if (state.get(this.facingProperty) == immutableBlockState.get(this.facingProperty)) { Direction direction1 = immutableBlockState.get(this.facingProperty).toDirection(); - if (direction1.axis() != state.get(this.facingProperty).toDirection().axis() && canTakeShape(state, level, blockPos, direction1.opposite())) { + if (direction1.axis() != state.get(this.facingProperty).toDirection().axis() && canTakeShape(state, level, blockPos, opposite ? direction1.opposite() : direction1)) { if (direction1 == direction.counterClockWise()) { - return StairsShape.OUTER_LEFT; + return opposite ? StairsShape.OUTER_LEFT : StairsShape.INNER_LEFT; } - return StairsShape.OUTER_RIGHT; + return opposite ? StairsShape.OUTER_RIGHT : StairsShape.INNER_LEFT; } } }