mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-26 16:49:23 +01:00
added comparator output to pipes
This commit is contained in:
parent
5306595e24
commit
d8255ca07b
2 changed files with 18 additions and 0 deletions
|
@ -227,6 +227,19 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||
PipeTileEntity pipe = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||
if (pipe == null)
|
||||
return 0;
|
||||
return Math.min(15, pipe.getItems().size());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||
|
|
|
@ -54,6 +54,7 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
}
|
||||
};
|
||||
private List<PipeItem> items;
|
||||
private int lastItemAmount;
|
||||
private int priority;
|
||||
|
||||
public PipeTileEntity() {
|
||||
|
@ -115,6 +116,10 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
List<PipeItem> items = this.getItems();
|
||||
for (int i = items.size() - 1; i >= 0; i--)
|
||||
items.get(i).updateInPipe(this);
|
||||
if (items.size() != this.lastItemAmount) {
|
||||
this.lastItemAmount = items.size();
|
||||
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
|
||||
}
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue