use of com.simibubi.create.content.logistics.block.funnel.FunnelBlock in project Create by Creators-of-Create.
the class ChuteBlock method updateChuteState.
@Override
public BlockState updateChuteState(BlockState state, BlockState above, BlockGetter world, BlockPos pos) {
if (!(state.getBlock() instanceof ChuteBlock))
return state;
Map<Direction, Boolean> connections = new HashMap<>();
int amtConnections = 0;
Direction facing = state.getValue(FACING);
boolean vertical = facing == Direction.DOWN;
if (!vertical) {
BlockState target = world.getBlockState(pos.below().relative(facing.getOpposite()));
if (!isChute(target))
return state.setValue(FACING, Direction.DOWN).setValue(SHAPE, Shape.NORMAL);
}
for (Direction direction : Iterate.horizontalDirections) {
BlockState diagonalInputChute = world.getBlockState(pos.above().relative(direction));
boolean value = diagonalInputChute.getBlock() instanceof ChuteBlock && diagonalInputChute.getValue(FACING) == direction;
connections.put(direction, value);
if (value)
amtConnections++;
}
boolean noConnections = amtConnections == 0;
if (vertical)
return state.setValue(SHAPE, noConnections ? state.getValue(SHAPE) == Shape.WINDOW ? Shape.WINDOW : Shape.NORMAL : Shape.INTERSECTION);
if (noConnections)
return state.setValue(SHAPE, Shape.INTERSECTION);
if (connections.get(Direction.NORTH) && connections.get(Direction.SOUTH))
return state.setValue(SHAPE, Shape.INTERSECTION);
if (connections.get(Direction.EAST) && connections.get(Direction.WEST))
return state.setValue(SHAPE, Shape.INTERSECTION);
if (amtConnections == 1 && connections.get(facing) && !(getChuteFacing(above) == Direction.DOWN) && !(above.getBlock() instanceof FunnelBlock && FunnelBlock.getFunnelFacing(above) == Direction.DOWN))
return state.setValue(SHAPE, Shape.NORMAL);
return state.setValue(SHAPE, Shape.INTERSECTION);
}
Aggregations