Exemple #1
0
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!world.isRemote) {
     int meta = world.getBlockMetadata(x, y, z);
     if (!isLampLit(meta)) {
       TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z);
       if (te != null) {
         te.updateLampFuel(
             false); // Update lamp fuel, but don't burn fuel for time passed while lamp was off
         // before turning the lamp on.
         if (te.isFuelValid())
           if (te.getFuelTimeLeft() > 0) world.setBlockMetadataWithNotify(x, y, z, meta - 8, 3);
       }
     } else {
       TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z);
       if (te != null) {
         te.updateLampFuel(
             true); // Update lamp fuel and burn fuel for time passed before turning the lamp off.
       }
       world.setBlockMetadataWithNotify(x, y, z, meta + 8, 3);
     }
   }
   return true;
 }
Exemple #2
0
 /** Ticks the block if it's been scheduled */
 @Override
 public void updateTick(World world, int x, int y, int z, Random rand) {
   super.updateTick(world, x, y, z, rand);
   int meta = world.getBlockMetadata(x, y, z);
   if (meta < 8) {
     TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z);
     if (te != null) {
       te.updateLampFuel(true); // Burn fuel for time passed while lamp is on.
       if (te.getFuelTimeLeft() == 0) world.setBlockMetadataWithNotify(x, y, z, meta + 8, 3);
     }
   }
 }