mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-26 05:28:33 +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
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private List<PipeItem> items;
|
private List<PipeItem> items;
|
||||||
|
private int lastItemAmount;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
public PipeTileEntity() {
|
public PipeTileEntity() {
|
||||||
|
@ -115,6 +116,10 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
List<PipeItem> items = this.getItems();
|
List<PipeItem> items = this.getItems();
|
||||||
for (int i = items.size() - 1; i >= 0; i--)
|
for (int i = items.size() - 1; i >= 0; i--)
|
||||||
items.get(i).updateInPipe(this);
|
items.get(i).updateInPipe(this);
|
||||||
|
if (items.size() != this.lastItemAmount) {
|
||||||
|
this.lastItemAmount = items.size();
|
||||||
|
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
|
||||||
|
}
|
||||||
profiler.endSection();
|
profiler.endSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue