Added support for outputting MJ from power conduits.

This commit is contained in:
CrazyPants committed 2014-09-08 18:27:49 +08:00
1 parent 05354515b1
commit 8434f34541
6 files changed
+176 -10

No files matched your search

@@ -1,16 +1,31 @@
package crazypants.enderio.power;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.MjAPI;
import buildcraft.api.power.IPowerReceptor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
import crazypants.enderio.config.Config;
public class PowerHandlerUtil {
public static IPowerInterface create(Object o) {
if(o instanceof IEnergyHandler) {
return new PowerInterfaceRF((IEnergyHandler) o);
}
}
if(Config.powerConduitOutputMJ) {
IBatteryObject battery = MjAPI.getMjBattery(o);
if(battery != null) {
return new PowerInterfaceBC2(battery);
}
if(o instanceof IPowerReceptor) {
return new PowerInterfaceBC((IPowerReceptor) o);
}
}
return null;
}
@@ -19,12 +34,12 @@ public class PowerHandlerUtil {
if(tag == null) {
return 0;
}
if(tag.hasKey("storedEnergy")) {
double storedMj = tag.getDouble("storedEnergy");
return (int)(storedMj * 10);
return (int) (storedMj * 10);
}
return tag.getInteger("storedEnergyRF");
}
@@ -43,8 +58,8 @@ public class PowerHandlerUtil {
result = Math.min(target.getMaxEnergyStored() - target.getEnergyStored(), result);
if(result > 0 && !simulate) {
target.setEnergyStored(target.getEnergyStored() + result);
}
return result;
}
return result;
}