Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ public enum UpdatePhase {

public Map<Direction, PipeConnection> interfaces;
public UpdatePhase phase;
public boolean scheduleUpdate;

public FluidTransportBehaviour(SmartBlockEntity be) {
super(be);
phase = UpdatePhase.WAIT_FOR_PUMPS;
scheduleUpdate = false;
}

public boolean canPullFluidFrom(FluidStack fluid, BlockState state, Direction direction) {
Expand All @@ -67,6 +69,13 @@ public void tick() {

if (interfaces == null)
return;

if (onServer && scheduleUpdate) {
FluidPropagator.propagateChangedPipe(world, pos, blockEntity.getBlockState());
scheduleUpdate = false;
return;
}

Collection<PipeConnection> connections = interfaces.values();

// Do not provide a lone pipe connection with its own flow input
Expand Down Expand Up @@ -159,6 +168,9 @@ public void read(CompoundTag nbt, HolderLookup.Provider registries, boolean clie

interfaces.values()
.forEach(connection -> connection.deserializeNBT(nbt, registries, blockEntity.getBlockPos(), clientPacket));

if (nbt.contains("ScheduleUpdate"))
scheduleUpdate = nbt.getBoolean("ScheduleUpdate");
}

@Override
Expand All @@ -171,6 +183,9 @@ public void write(CompoundTag nbt, HolderLookup.Provider registries, boolean cli

interfaces.values()
.forEach(connection -> connection.serializeNBT(nbt, registries, clientPacket));

if (scheduleUpdate)
nbt.putBoolean("ScheduleUpdate", true);
}

public FluidStack getProvidedOutwardFluid(Direction side) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ protected void distributePressureTo(Direction side) {
BlockFace blockFace = new BlockFace(currentPos, face);
BlockPos connectedPos = blockFace.getConnectedPos();

if (!level.isLoaded(connectedPos))
if (!level.isLoaded(connectedPos)) {
pipe.scheduleUpdate = true;
continue;
}
if (blockFace.isEquivalent(start))
continue;
if (hasReachedValidEndpoint(level, blockFace, pull)) {
Expand Down
Loading