@Override
  public void updateEntity() {
    if (interval > 0) {
      int next = this.chargeAmount + 2;
      next = Math.min(next, MAX_CHARGE);
      this.setChargeAmount(next);

      int r = this.round + 4;
      if (r > 360) r -= 360;
      this.round = r;

      this.interval--;
    }

    // 真下のTileのチェック
    TileEntity tile = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
    if (tile != null) {
      int ext = Math.min(this.chargeAmount, 2);
      boolean b = false;

      if (tile instanceof IChargeableMachine) {
        b = true;
      }
      if (!b && Loader.isModLoaded("SextiarySector")) {
        int ext2 = ext * PropertyHandler.rateGF();
        ext2 = SS2DeviceHandler.inputEnergy(tile, ForgeDirection.UP, ext2, true);
        if (SS2DeviceHandler.isGFDevice(tile) && ext2 > 0) {
          SS2DeviceHandler.inputEnergy(tile, ForgeDirection.UP, ext2, false);
          this.chargeAmount -= ext;
          b = true;
        }
      }
      if (!b && ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy")) {
        int ext2 = ext * PropertyHandler.rateRF();
        ext2 = RFDeviceHandler.inputEnergy(ForgeDirection.UP, tile, ext2, true);
        if (RFDeviceHandler.isRFDevice(tile) && ext2 > 0) {
          RFDeviceHandler.inputEnergy(ForgeDirection.UP, tile, ext2, false);
          this.chargeAmount -= ext;
          b = true;
        }
      }
    }

    if (!worldObj.isRemote) {
      this.updateServer();
    }
  }
  // 右クリック効果
  @Override
  public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    Block block = par3World.getBlock(par4, par5, par6);
    TileEntity tile = par3World.getTileEntity(par4, par5, par6);
    int meta = par3World.getBlockMetadata(par4, par5, par6);

    if (par2EntityPlayer == null) return false;
    boolean se = false;

    // charge
    if (tile instanceof MachineBase) {
      MachineBase machine = (MachineBase) tile;
      if (!machine.isFullCharged()) {
        int max = machine.getMaxChargeAmount();
        int ret = machine.getChargeAmount() + 800;
        ret = MathHelper.clamp_int(ret, 0, max);
        machine.setChargeAmount(ret);
        se = true;
      }
    } else if (tile instanceof TileChargerDevice) {
      TileChargerDevice device = (TileChargerDevice) tile;
      if (!device.isFullCharged()) {
        int max = device.getMaxChargeAmount();
        int ret = device.getChargeAmount() + 800;
        ret = MathHelper.clamp_int(ret, 0, max);
        device.setChargeAmount(ret);
        se = true;
      }
    }
    // RF
    else if (ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy") && RFDeviceHandler.isRFDevice(tile)) {
      se = RFDeviceHandler.inputEnergy(ForgeDirection.UP, tile, 1000, false) > 0;
    }

    // Barrel
    if (tile instanceof TileBrewingBarrel) {
      TileBrewingBarrel barrel = (TileBrewingBarrel) tile;
      if (!barrel.getAged() && !barrel.productTank.isEmpty()) {
        barrel.setAgingStage(4);
        se = true;
      }
    }

    // 骨粉
    if (ItemDye.applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) {
      if (!par3World.isRemote) {
        par3World.playAuxSFX(2005, par4, par5, par6, 0);
        se = true;
      }
    }

    // どれでもなかった場合
    if (!se) {
      if (block.canPlaceTorchOnTop(par3World, par4, par5, par6)
          && par3World.isAirBlock(par4, par5 + 1, par6)) {
        if (!par3World.isRemote) par3World.setBlock(par4, par5 + 1, par6, Blocks.torch);
        se = true;
      }
    }

    if (se) {
      par3World.playSoundAtEntity(par2EntityPlayer, "random.pop", 0.4F, 1.8F);
    }
    return true;
  }