From 78f6529128943626f1dc8866cc3f45f85447dfce Mon Sep 17 00:00:00 2001 From: hailcrop Date: Sat, 19 Sep 2026 19:45:04 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20mirror=20and=20rotation=20for=20fish=20ta?= =?UTF-8?q?nk=20and=20overflow=20chute=20=E4=BF=AE=E5=A4=8D=E9=B1=BC?= =?UTF-8?q?=E7=BC=B8=E5=92=8C=E6=BA=A2=E6=B5=81=E6=BA=9C=E6=A7=BD=E7=BF=BB?= =?UTF-8?q?=E8=BD=AC=E6=97=8B=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复鱼缸和溢流溜槽无法被litematica/建筑杖/智能方块放置器正确旋转/翻转,且蓝图预览方向不正常的问题 --- .../dubhe/anvilcraft/block/FishTankBlock.java | 12 +++++++++++ .../anvilcraft/block/OverflowChuteBlock.java | 20 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dubhe/anvilcraft/block/FishTankBlock.java b/src/main/java/dev/dubhe/anvilcraft/block/FishTankBlock.java index 6c2df2ad4d..9ab6767baf 100644 --- a/src/main/java/dev/dubhe/anvilcraft/block/FishTankBlock.java +++ b/src/main/java/dev/dubhe/anvilcraft/block/FishTankBlock.java @@ -34,6 +34,8 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -109,6 +111,16 @@ public BlockState getStateForPlacement(BlockPlaceContext context) { return this.defaultBlockState().setValue(FishTankBlock.FACING, facing); } + @Override + protected BlockState rotate(BlockState state, Rotation rotation) { + return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); + } + + @Override + protected BlockState mirror(BlockState state, Mirror mirror) { + return state.setValue(FACING, mirror.mirror(state.getValue(FACING))); + } + @Override protected boolean hasAnalogOutputSignal(BlockState state) { return true; diff --git a/src/main/java/dev/dubhe/anvilcraft/block/OverflowChuteBlock.java b/src/main/java/dev/dubhe/anvilcraft/block/OverflowChuteBlock.java index c2b15d1333..3c30876f7f 100644 --- a/src/main/java/dev/dubhe/anvilcraft/block/OverflowChuteBlock.java +++ b/src/main/java/dev/dubhe/anvilcraft/block/OverflowChuteBlock.java @@ -340,12 +340,28 @@ public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos bl @Override public BlockState rotate(BlockState state, Rotation rotation) { - return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); + BlockState result = state.setValue(FACING, rotation.rotate(state.getValue(FACING))); + for (Direction direction : Direction.values()) { + Direction rotatedDirection = rotation.rotate(direction); + result = result.setValue( + overflowProperty(rotatedDirection), + state.getValue(overflowProperty(direction)) + ); + } + return result; } @Override public BlockState mirror(BlockState state, Mirror mirror) { - return this.rotate(state, mirror.getRotation(state.getValue(FACING))); + BlockState result = state.setValue(FACING, mirror.mirror(state.getValue(FACING))); + for (Direction direction : Direction.values()) { + Direction mirroredDirection = mirror.mirror(direction); + result = result.setValue( + overflowProperty(mirroredDirection), + state.getValue(overflowProperty(direction)) + ); + } + return result; } @Override