mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 23:43:43 +01:00
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:
parent
1b5ede1a5d
commit
5bd0c73f45
1 changed files with 13 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue