added comparator output to pipes

This commit is contained in:
Ellpeck 2020-05-03 15:33:56 +02:00
parent 5306595e24
commit d8255ca07b
2 changed files with 18 additions and 0 deletions

View file

@ -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) {

View file

@ -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();
}