diff --git a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlock.java b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlock.java index 9684727..4b15282 100644 --- a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlock.java +++ b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlock.java @@ -65,4 +65,17 @@ public class PressurizerBlock extends BaseEntityBlock { public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { return level.isClientSide ? null : createTickerHelper(type, Registry.pressurizerBlockEntity, PressurizerBlockEntity::tick); } + + @Override + public boolean hasAnalogOutputSignal(BlockState state) { + return true; + } + + @Override + public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { + var pipe = Utility.getBlockEntity(PressurizerBlockEntity.class, world, pos); + if (pipe == null) + return 0; + return (int) (pipe.getEnergy() / (float) pipe.getMaxEnergy() * 15); + } } diff --git a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java index 17315cf..ff59b52 100644 --- a/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java +++ b/src/main/java/de/ellpeck/prettypipes/pressurizer/PressurizerBlockEntity.java @@ -134,9 +134,10 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider, } } - // send energy update + // send energy update and comparator output if (pressurizer.lastEnergy != pressurizer.storage.getEnergyStored() && pressurizer.level.getGameTime() % 10 == 0) { pressurizer.lastEnergy = pressurizer.storage.getEnergyStored(); + level.updateNeighbourForOutputSignal(pos, state.getBlock()); Utility.sendBlockEntityToClients(pressurizer); } }