Search in sources :

Example 1 with AxisPipeBlock

use of com.simibubi.create.content.contraptions.fluids.pipes.AxisPipeBlock in project Create by Creators-of-Create.

the class FluidPropagator method getStraightPipeAxis.

@Nullable
public static Axis getStraightPipeAxis(BlockState state) {
    if (state.getBlock() instanceof PumpBlock)
        return state.getValue(PumpBlock.FACING).getAxis();
    if (state.getBlock() instanceof AxisPipeBlock)
        return state.getValue(AxisPipeBlock.AXIS);
    if (!FluidPipeBlock.isPipe(state))
        return null;
    Axis axisFound = null;
    int connections = 0;
    for (Axis axis : Iterate.axes) {
        Direction d1 = Direction.get(AxisDirection.NEGATIVE, axis);
        Direction d2 = Direction.get(AxisDirection.POSITIVE, axis);
        boolean openAt1 = FluidPipeBlock.isOpenAt(state, d1);
        boolean openAt2 = FluidPipeBlock.isOpenAt(state, d2);
        if (openAt1)
            connections++;
        if (openAt2)
            connections++;
        if (openAt1 && openAt2)
            if (axisFound != null)
                return null;
            else
                axisFound = axis;
    }
    return connections == 2 ? axisFound : null;
}
Also used : AxisPipeBlock(com.simibubi.create.content.contraptions.fluids.pipes.AxisPipeBlock) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis) Nullable(javax.annotation.Nullable)

Aggregations

AxisPipeBlock (com.simibubi.create.content.contraptions.fluids.pipes.AxisPipeBlock)1 Nullable (javax.annotation.Nullable)1 Direction (net.minecraft.core.Direction)1 Axis (net.minecraft.core.Direction.Axis)1 AxisDirection (net.minecraft.core.Direction.AxisDirection)1