@Override
 public boolean canHarvestBlock(ItemStack stack, Block block, int meta, EntityPlayer player) {
   if (block instanceof BlockLeaves || block instanceof BlockFlower) {
     if (ElectricItemUtils.getPlayerEnergy(player)
         > ModuleManager.computeModularProperty(stack, LEAF_BLOWER_ENERGY_CONSUMPTION)) {
       return true;
     }
   }
   return false;
 }
  @Override
  public boolean onBlockDestroyed(
      ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) {
    boolean b = false;
    Block block = Block.blocksList[blockID];
    int plant = (int) ModuleManager.computeModularProperty(stack, PLANT_RADIUS);
    int leaf = (int) ModuleManager.computeModularProperty(stack, LEAF_RADIUS);
    int totalEnergyDrain = 0;

    // Leaves
    if (block != null && block.isLeaves(world, x, y, z)) {
      for (int i = -leaf; i < leaf; i++) {
        for (int j = -leaf; j < leaf; j++) {
          for (int k = -leaf; k < leaf; k++) {
            int id = world.getBlockId(x + i, y + j, z + k);
            int meta = world.getBlockId(x + i, y + j, z + k);
            Block tempBlock = Block.blocksList[id];
            if (tempBlock != null && tempBlock.isLeaves(world, x + i, y + j, z + k)) {
              if (block.canHarvestBlock(player, meta)) {
                block.harvestBlock(world, player, x + i, y + j, z + k, meta);
                totalEnergyDrain +=
                    ModuleManager.computeModularProperty(stack, LEAF_BLOWER_ENERGY_CONSUMPTION);
              }
              world.setBlock(x + i, y + j, z + k, 0);
              b = true;
            }
          }
        }
      }
    }

    for (int i = -plant; i < plant; i++) {
      for (int j = -plant; j < plant; j++) {
        for (int k = -plant; k < plant; k++) {
          int id = world.getBlockId(x + i, y + j, z + k);
          int meta = world.getBlockId(x + i, y + j, z + k);
          Block tempBlock = Block.blocksList[id];
          if (tempBlock != null && tempBlock instanceof BlockFlower) {
            if (block.canHarvestBlock(player, meta)) {
              block.harvestBlock(world, player, x + i, y + j, z + k, meta);
              totalEnergyDrain +=
                  ModuleManager.computeModularProperty(stack, LEAF_BLOWER_ENERGY_CONSUMPTION);
            }
            world.setBlock(x + i, y + j, z + k, 0);
            b = true;
          }
        }
      }
    }
    ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
    return b;
  }
 @Override
 public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
   double totalEnergy = ElectricItemUtils.getPlayerEnergy(player);
   PotionEffect invis = null;
   Collection<PotionEffect> effects = player.getActivePotionEffects();
   for (PotionEffect effect : effects) {
     if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
       invis = effect;
       break;
     }
   }
   if (50 < totalEnergy) {
     if (invis == null || invis.getDuration() < 210) {
       player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
       ElectricItemUtils.drainPlayerEnergy(player, 50);
     }
   } else {
     if (invis != null) {
       player.removePotionEffect(Potion.invisibility.id);
     }
   }
 }
  @Override
  public void tickEnd(EnumSet<TickType> type, Object... tickData) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player != null) {
      double currEnergy = ElectricItemUtils.getPlayerEnergy(player);
      double maxEnergy = ElectricItemUtils.getMaxEnergy(player);
      if (maxEnergy > 0) {
        String currStr = MuseStringUtils.formatNumberShort(currEnergy);
        String maxStr = MuseStringUtils.formatNumberShort(maxEnergy);
        MuseRenderer.drawString(currStr + '/' + maxStr + " J", 1, 1);
      }
    }
    if (Minecraft.getMinecraft().currentScreen == null) {
      Minecraft mc = Minecraft.getMinecraft();
      ScaledResolution screen =
          new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
      int i = player.inventory.currentItem;
      ItemStack stack = player.inventory.mainInventory[i];
      if (stack != null && stack.getItem() instanceof IModularItem) {
        MuseRenderer.blendingOn();
        NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
        int swapTime = (int) Math.min(System.currentTimeMillis() - lastSwapTime, SWAPTIME);
        Icon currentMode = null;
        Icon nextMode = null;
        Icon prevMode = null;
        List<String> modes = MuseItemUtils.getModes(stack, player);
        String mode = itemTag.getString("Mode");
        int modeIndex = modes.indexOf(mode);
        if (modeIndex > -1) {
          String prevModeName = modes.get((modeIndex + modes.size() - 1) % modes.size());
          String nextModeName = modes.get((modeIndex + 1) % modes.size());
          IPowerModule module = ModuleManager.getModule(mode);
          IPowerModule nextModule = ModuleManager.getModule(nextModeName);
          IPowerModule prevModule = ModuleManager.getModule(prevModeName);

          if (module != null) {
            currentMode = module.getIcon(stack);
            if (!nextModeName.equals(mode)) {
              nextMode = nextModule.getIcon(stack);
              prevMode = prevModule.getIcon(stack);
            }
          }
        }
        double prevX, prevY, currX, currY, nextX, nextY;
        double sw = screen.getScaledWidth_double();
        double baroffset = screen.getScaledHeight_double() - 40;
        if (!player.capabilities.isCreativeMode) {
          baroffset -= 16;
          if (ForgeHooks.getTotalArmorValue(player) > 0) {
            baroffset -= 8;
          }
        }
        // Root locations of the mode list
        prevX = sw / 2.0 - 105.0 + 20.0 * i;
        prevY = baroffset + 10;
        currX = sw / 2.0 - 89.0 + 20.0 * i;
        currY = baroffset;
        nextX = sw / 2.0 - 73.0 + 20.0 * i;
        nextY = baroffset + 10;
        if (swapTime == SWAPTIME || lastSwapDirection == 0) {
          drawIcon(prevX, prevY, prevMode, 0.4, 0, 0, 16, baroffset - prevY + 16);
          drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
          drawIcon(nextX, nextY, nextMode, 0.4, 0, 0, 16, baroffset - nextY + 16);
        } else {
          double r1 = 1 - swapTime / (double) SWAPTIME;
          double r2 = swapTime / (double) SWAPTIME;
          if (lastSwapDirection == -1) {
            nextX = (currX * r1 + nextX * r2);
            nextY = (currY * r1 + nextY * r2);
            currX = (prevX * r1 + currX * r2);
            currY = (prevY * r1 + currY * r2);
            drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
            drawIcon(nextX, nextY, nextMode, 0.8, 0, 0, 16, baroffset - nextY + 16);

          } else {
            prevX = (currX * r1 + prevX * r2);
            prevY = (currY * r1 + prevY * r2);
            currX = (nextX * r1 + currX * r2);
            currY = (nextY * r1 + currY * r2);
            // MuseRenderer
            drawIcon(prevX, prevY, prevMode, 0.8, 0, 0, 16, baroffset - prevY + 16);
            drawIcon(currX, currY, currentMode, 0.8, 0, 0, 16, baroffset - currY + 16);
          }
        }
        // MuseRenderer.blendingOff();
        GL11.glDisable(GL11.GL_LIGHTING);
        Colour.WHITE.doGL();
      }
    }
  }