Flipping pipes

- Pipes not connected to anything will no longer change direction when a non-connective block is placed next to them
This commit is contained in:
reidbhuntley 2021-06-10 17:12:45 -04:00
parent 1b5ede1a5d
commit 5bd0c73f45

View File

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.fluids.pipes;
import java.util.Arrays;
import java.util.Optional;
import java.util.Random;
@ -231,6 +232,12 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
if (bracket != null && bracket.isBracketPresent())
return state;
BlockState prevState = state;
int prevStateSides = (int) Arrays.stream(Iterate.directions)
.map(FACING_TO_PROPERTY_MAP::get)
.filter(prevState::get)
.count();
// Update sides that are not ignored
for (Direction d : Iterate.directions)
if (d != ignore) {
@ -252,6 +259,10 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
if (connectedDirection != null)
return state.with(FACING_TO_PROPERTY_MAP.get(connectedDirection.getOpposite()), true);
// If we can't connect to anything and weren't connected before, do nothing
if (prevStateSides == 2)
return prevState;
// Use preferred
return state.with(FACING_TO_PROPERTY_MAP.get(preferredDirection), true)
.with(FACING_TO_PROPERTY_MAP.get(preferredDirection.getOpposite()), true);
@ -275,10 +286,10 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
return Optional.empty();
return Optional.of(new ItemStack(bracket.getBlock()));
}
@Override
public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) {
return false;
}
}