added comparator output to the pressurizer

Related to #79
This commit is contained in:
Ell 2022-03-30 14:32:40 +02:00
parent 1c5a3a118d
commit 27aa6809ae
2 changed files with 15 additions and 1 deletions

View file

@ -65,4 +65,17 @@ public class PressurizerBlock extends BaseEntityBlock {
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> 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);
}
}

View file

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