From a72dccdea4bf67aad0bd7958f7284cb9664f71ad Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 17 Nov 2019 13:11:42 +0100 Subject: [PATCH] Fixed holder of cable blocks sometimes conflicting with a cable connection while rendering --- CHANGELOG.md | 1 + .../refinedstorage/block/CableBlock.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b345bfe..ac7386aeb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed Pattern Grid causing world hanging on load (raoulvdberge) - Fixed External Storage not refreshing when the storage is broken or replaced (raoulvdberge) - Fixed delay in block update when placing a cable block (raoulvdberge) +- Fixed holder of cable blocks sometimes conflicting with a cable connection while rendering (raoulvdberge) ### 1.7 NOTE: This is an alpha release. Bugs may happen. Remember to take backups. diff --git a/src/main/java/com/raoulvdberge/refinedstorage/block/CableBlock.java b/src/main/java/com/raoulvdberge/refinedstorage/block/CableBlock.java index 54dac262b..53eadd4ae 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/block/CableBlock.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/block/CableBlock.java @@ -18,6 +18,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; +import net.minecraft.world.World; import javax.annotation.Nullable; @@ -93,6 +94,20 @@ public class CableBlock extends NetworkNodeBlock { return shape; } + @Override + protected void onDirectionChanged(World world, BlockPos pos, Direction newDirection) { + // rotate() in BaseBlock "stupidly" changes the direction without checking if our cable connections are still valid. + // You'd expect that cable connections are not changing when simply changing the direction. + // But they need to. For example, when rotating a constructor to connect to a neighboring cable, the connection to that neighbor + // needs to be removed as otherwise the "holder" of the constructor will conflict with the cable connection. + // This is already checked in hasNode(). + // But since rotate() doesn't invalidate that connection, we need to do it here. + // Ideally, this code would be in rotate(). But rotate() doesn't have any data about the position and world, so we need to do it here. + world.setBlockState(pos, getState(world.getBlockState(pos), world, pos)); + + super.onDirectionChanged(world, pos, newDirection); + } + @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext ctx) { @@ -100,6 +115,7 @@ public class CableBlock extends NetworkNodeBlock { } private boolean hasNode(IWorld world, BlockPos pos, BlockState state, Direction direction) { + // Prevent the "holder" of a cable block conflicting with a cable connection. if (getDirection() != BlockDirection.NONE && state.get(getDirection().getProperty()).getOpposite() == direction) { return false; }