Skip to content

Commit

Permalink
added comparator output to the pressurizer
Browse files Browse the repository at this point in the history
Related to #79
  • Loading branch information
Ellpeck committed Mar 30, 2022
1 parent 1c5a3a1 commit 27aa680
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ public static void tick(Level level, BlockPos pos, BlockState state, Pressurizer
}
}

// 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);
}
}
Expand Down

0 comments on commit 27aa680

Please sign in to comment.