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;
}
Aggregations