Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
- {
- LogHelper.info("Ticked!");
- if(worldIn.getTileEntity(pos) instanceof TileEntityLamp)
- {
- TileEntityLamp entityLamp = (TileEntityLamp) worldIn.getTileEntity(pos);
- //"LIFETIME" is the maximum lifetime this block can have. entityLamp.getLifetime is the current lifetime value.
- float lifetimePercentage = (entityLamp.getLifetime() * 100) / this.LIFETIME;
- int randomedNumber = random.nextInt(100);
- if(randomedNumber <= 50 && lifetimePercentage <= 25)
- {
- if(getLightValue(state, worldIn, pos) <= 0)
- {
- this.setLightLevel(getBaseLightValue() / 15);
- }
- else
- {
- this.setLightLevel(0);
- }
- worldIn.checkLight(pos);
- worldIn.notifyBlockUpdate(pos, state, state, 19);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment