mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
allow modules in pipes connected to terminals
This commit is contained in:
parent
8046081653
commit
f2ebe8af90
4 changed files with 20 additions and 4 deletions
|
@ -19,4 +19,8 @@ public interface IPipeConnectable {
|
|||
default ItemStack insertItem(World world, BlockPos pipePos, Direction direction, PipeItem item) {
|
||||
return item.stack;
|
||||
}
|
||||
|
||||
default boolean allowsModules(World world, BlockPos pipePos, Direction direction) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||
if (tile == null)
|
||||
return ActionResultType.PASS;
|
||||
if (!tile.isConnectedInventory())
|
||||
if (!tile.canHaveModules())
|
||||
return ActionResultType.PASS;
|
||||
if (!worldIn.isRemote)
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
||||
|
@ -185,7 +185,7 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
|
||||
public static void onStateChanged(World world, BlockPos pos, BlockState newState) {
|
||||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, world, pos);
|
||||
if (tile != null && !tile.isConnectedInventory())
|
||||
if (tile != null && !tile.canHaveModules())
|
||||
Utility.dropInventory(tile, tile.modules);
|
||||
|
||||
PipeNetwork network = PipeNetwork.get(world);
|
||||
|
|
|
@ -228,8 +228,15 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
return this.getItemHandler(dir, null) != null;
|
||||
}
|
||||
|
||||
public boolean isConnectedInventory() {
|
||||
return Arrays.stream(Direction.values()).anyMatch(this::isConnectedInventory);
|
||||
public boolean canHaveModules() {
|
||||
for (Direction dir : Direction.values()) {
|
||||
if (this.isConnectedInventory(dir))
|
||||
return true;
|
||||
IPipeConnectable connectable = this.getPipeConnectable(dir);
|
||||
if (connectable != null && connectable.allowsModules(this.world, this.pos, dir))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canNetworkSee() {
|
||||
|
|
|
@ -77,6 +77,11 @@ public class ItemTerminalBlock extends ContainerBlock implements IPipeConnectabl
|
|||
return item.stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsModules(World world, BlockPos pipePos, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
|
|
Loading…
Reference in a new issue