use of com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour in project Create by Creators-of-Create.
the class TransparentStraightPipeRenderer method renderSafe.
@Override
protected void renderSafe(StraightPipeTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
FluidTransportBehaviour pipe = te.getBehaviour(FluidTransportBehaviour.TYPE);
if (pipe == null)
return;
for (Direction side : Iterate.directions) {
Flow flow = pipe.getFlow(side);
if (flow == null)
continue;
FluidStack fluidStack = flow.fluid;
if (fluidStack.isEmpty())
continue;
LerpedFloat progress = flow.progress;
if (progress == null)
continue;
float value = progress.getValue(partialTicks);
boolean inbound = flow.inbound;
if (value == 1) {
if (inbound) {
Flow opposite = pipe.getFlow(side.getOpposite());
if (opposite == null)
value -= 1e-6f;
} else {
FluidTransportBehaviour adjacent = TileEntityBehaviour.get(te.getLevel(), te.getBlockPos().relative(side), FluidTransportBehaviour.TYPE);
if (adjacent == null)
value -= 1e-6f;
else {
Flow other = adjacent.getFlow(side.getOpposite());
if (other == null || !other.inbound && !other.complete)
value -= 1e-6f;
}
}
}
FluidRenderer.renderFluidStream(fluidStack, side, 3 / 16f, value, inbound, buffer, ms, light);
}
}
use of com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour in project Create by Creators-of-Create.
the class ContentObserverTileEntity method tick.
@Override
public void tick() {
super.tick();
BlockState state = getBlockState();
if (turnOffTicks > 0) {
turnOffTicks--;
if (turnOffTicks == 0)
level.scheduleTick(worldPosition, state.getBlock(), 1);
}
if (!isActive())
return;
Direction facing = state.getValue(ContentObserverBlock.FACING);
BlockPos targetPos = worldPosition.relative(facing);
// Detect items on belt
TransportedItemStackHandlerBehaviour behaviour = TileEntityBehaviour.get(level, targetPos, TransportedItemStackHandlerBehaviour.TYPE);
if (behaviour != null) {
behaviour.handleCenteredProcessingOnAllItems(.45f, stack -> {
if (!filtering.test(stack.stack) || turnOffTicks == 6)
return TransportedResult.doNothing();
activate();
return TransportedResult.doNothing();
});
return;
}
// Detect fluids in pipe
FluidTransportBehaviour fluidBehaviour = TileEntityBehaviour.get(level, targetPos, FluidTransportBehaviour.TYPE);
if (fluidBehaviour != null) {
for (Direction side : Iterate.directions) {
Flow flow = fluidBehaviour.getFlow(side);
if (flow == null || !flow.inbound || !flow.complete)
continue;
if (!filtering.test(flow.fluid))
continue;
activate();
return;
}
return;
}
if (!observedInventory.simulate().extract().isEmpty()) {
activate();
return;
}
if (!observedTank.simulate().extractAny().isEmpty()) {
activate();
return;
}
}
use of com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour in project Create by Creators-of-Create.
the class FluidPipeBlock method canConnectTo.
public static boolean canConnectTo(BlockAndTintGetter world, BlockPos neighbourPos, BlockState neighbour, Direction direction) {
if (FluidPropagator.hasFluidCapability(world, neighbourPos, direction.getOpposite()))
return true;
if (VanillaFluidTargets.shouldPipesConnectTo(neighbour))
return true;
FluidTransportBehaviour transport = TileEntityBehaviour.get(world, neighbourPos, FluidTransportBehaviour.TYPE);
BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, neighbourPos, BracketedTileEntityBehaviour.TYPE);
if (isPipe(neighbour))
return bracket == null || !bracket.isBracketPresent() || FluidPropagator.getStraightPipeAxis(neighbour) == direction.getAxis();
if (transport == null)
return false;
return transport.canHaveFlowToward(neighbour, direction.getOpposite());
}
Aggregations