}
else if (EnergyConfigHandler.isIndustrialCraft2Loaded())
{
if (item instanceof IElectricItem)
{
IElectricItem electricItem = (IElectricItem) item;
if (electricItem.canProvideEnergy(itemStack))
{
double result = 0;
double energyDischargeIC2 = energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO;
//Do this by reflection:
//result = ic2.api.item.ElectricItem.manager.discharge(itemStack, energyDischargeIC2, 4, false, false, false)
try
{
Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, double.class, int.class, boolean.class, boolean.class, boolean.class);
result = (Double) dischargeMethod.invoke(ic2.api.item.ElectricItem.manager, itemStack, energyDischargeIC2, 4, false, false, false);
}
catch (Exception e)
{
e.printStackTrace();
}
float energyDischarged = (float) result * EnergyConfigHandler.IC2_RATIO;
this.storage.receiveEnergyGC(energyDischarged);
}
}
else if (item instanceof ISpecialElectricItem)
{
ISpecialElectricItem electricItem = (ISpecialElectricItem) item;
if (electricItem.canProvideEnergy(itemStack))
{
double result = 0;
double energyDischargeIC2 = energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO;
//Do this by reflection:
//result = electricItem.getManager(itemStack).discharge(itemStack, energyDischargeIC2, 4, false, false, false)
try
{
Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, double.class, int.class, boolean.class, boolean.class, boolean.class);
result = (Double) dischargeMethod.invoke(electricItem.getManager(itemStack), itemStack, energyDischargeIC2, 4, false, false, false);
}
catch (Exception e)
{
e.printStackTrace();
}