/** Invalidates a TileEntity */
  public static void invalidate(TileEntity tileEntity) {
    for (int i = 0; i < 6; i++) {
      ForgeDirection direction = ForgeDirection.getOrientation(i);
      TileEntity checkTile =
          VectorHelper.getConnectorFromSide(
              tileEntity.worldObj, new Vector3(tileEntity), direction);

      if (checkTile instanceof INetworkPart) {
        NetworkTileEntities network = ((INetworkPart) checkTile).getTileNetwork();

        if (network != null && network instanceof NetworkFluidTiles) {
          network.removeTile(tileEntity);
        }
      }
    }
  }
  /**
   * Invalidates a TileEntity from the electrical network, thereby removing it from all electricity
   * network that are adjacent to it.
   */
  public static void invalidate(TileEntity tileEntity) {
    for (int i = 0; i < 6; i++) {
      ForgeDirection direction = ForgeDirection.getOrientation(i);
      TileEntity checkTile =
          VectorHelper.getConnectorFromSide(
              tileEntity.worldObj, new Vector3(tileEntity), direction);

      if (checkTile instanceof INetworkProvider) {
        IElectricityNetwork network = ((INetworkProvider) checkTile).getNetwork();

        if (network != null) {
          network.stopRequesting(tileEntity);
          network.stopProducing(tileEntity);
        }
      }
    }
  }
  @Override
  public boolean produceUE(ForgeDirection outputDirection) {
    if (!this.worldObj.isRemote
        && outputDirection != null
        && outputDirection != ForgeDirection.UNKNOWN) {
      float provide = this.getProvide(outputDirection);

      if (provide > 0) {
        TileEntity outputTile =
            VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
        IElectricityNetwork outputNetwork =
            ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
        if (outputNetwork != null) {
          ElectricityPack powerRequest = outputNetwork.getRequest(this);

          if (powerRequest.getWatts() > 0) {
            ElectricityPack sendPack =
                ElectricityPack.min(
                    ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()),
                    ElectricityPack.getFromWatts(provide, this.getVoltage()));
            float rejectedPower = outputNetwork.produce(sendPack, this);
            this.provideElectricity(sendPack.getWatts() - rejectedPower, true);
            return true;
          }
        } else if (outputTile instanceof IElectrical) {
          float requestedEnergy =
              ((IElectrical) outputTile).getRequest(outputDirection.getOpposite());

          if (requestedEnergy > 0) {
            ElectricityPack sendPack =
                ElectricityPack.min(
                    ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()),
                    ElectricityPack.getFromWatts(provide, this.getVoltage()));
            float acceptedEnergy =
                ((IElectrical) outputTile)
                    .receiveElectricity(outputDirection.getOpposite(), sendPack, true);
            this.setEnergyStored(this.getEnergyStored() - acceptedEnergy);
            return true;
          }
        }
      }
    }

    return false;
  }