continue rotating if block points into cover

This commit is contained in:
Darkere
2021-11-14 21:58:31 +01:00
parent f616ed4cb1
commit de63fccf43

View File

@@ -22,6 +22,7 @@ import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
@@ -126,6 +127,16 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
// 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. // 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)); world.setBlockState(pos, getState(world.getBlockState(pos), world, pos));
//when rotating skip rotations blocked by covers
BlockDirection dir = getDirection();
if (dir != BlockDirection.NONE) {
if (isSideCovered(world.getTileEntity(pos), newDirection)) {
BlockState newState = rotate(world.getBlockState(pos), Rotation.CLOCKWISE_90);
world.setBlockState(pos, newState);
}
}
super.onDirectionChanged(world, pos, newDirection); super.onDirectionChanged(world, pos, newDirection);
} }