Example #1
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);
     }
   }
 }
Example #2
0
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entity, ItemStack is) {
   TileEntity _t = world.getTileEntity(x, y, z);
   if (_t != null && _t instanceof TEOilLamp) {
     ((TEOilLamp) _t).create();
     FluidStack fs = FluidStack.loadFluidStackFromNBT(is.getTagCompound());
     if (fs != null) {
       ((TEOilLamp) _t).setFuelFromStack(fs);
     } else {
       // world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+8, 0x3);
     }
     ((TEOilLamp) _t).hourPlaced = (int) TFC_Time.getTotalHours();
   }
 }
Example #3
0
 @Override
 public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
   if (!world.isRemote) {
     TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z);
     if ((meta & 8) != 0) meta -= 8;
     if (te != null) {
       if (te.getFuel() != null) {
         ItemStack is = new ItemStack(this, 1, meta);
         NBTTagCompound nbt = te.getFuel().writeToNBT(new NBTTagCompound());
         is.setTagCompound(nbt);
         EntityItem ei = new EntityItem(world, x, y, z, is);
         world.spawnEntityInWorld(ei);
       } else {
         ItemStack is = new ItemStack(this, 1, meta);
         EntityItem ei = new EntityItem(world, x, y, z, is);
         world.spawnEntityInWorld(ei);
       }
     }
   }
 }
Example #4
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;
 }