Guest User

Untitled

a guest
Sep 3rd, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.     @Override
  2.     public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
  3.     {
  4.         LogHelper.info("Ticked!");
  5.         if(worldIn.getTileEntity(pos) instanceof TileEntityLamp)
  6.         {
  7.             TileEntityLamp entityLamp = (TileEntityLamp) worldIn.getTileEntity(pos);
  8.  
  9.             //"LIFETIME" is the maximum lifetime this block can have. entityLamp.getLifetime is the current lifetime value.
  10.             float lifetimePercentage = (entityLamp.getLifetime() * 100) / this.LIFETIME;
  11.  
  12.             int randomedNumber = random.nextInt(100);
  13.  
  14.             if(randomedNumber <= 50 && lifetimePercentage <= 25)
  15.             {
  16.                 if(getLightValue(state, worldIn, pos) <= 0)
  17.                 {
  18.                     this.setLightLevel(getBaseLightValue() / 15);
  19.                 }
  20.                 else
  21.                 {
  22.                     this.setLightLevel(0);
  23.                 }
  24.                 worldIn.checkLight(pos);
  25.                 worldIn.notifyBlockUpdate(pos, state, state, 19);
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment