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