mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Added support for outputting MJ from power conduits.
This commit is contained in:
1 parent
05354515b1
commit
8434f34541
6 files changed
+176
-10
No files matched your search
@@ -276,6 +276,7 @@ public final class Config {
|
||||
public static int powerConduitTierOneRF = 640;
|
||||
public static int powerConduitTierTwoRF = 5120;
|
||||
public static int powerConduitTierThreeRF = 20480;
|
||||
public static boolean powerConduitOutputMJ = true;
|
||||
|
||||
public static int sliceAndSpliceLevelOnePowerPerTickRF = 80;
|
||||
public static int sliceAndSpliceLevelTwoPowerPerTickRF = 160;
|
||||
@@ -334,8 +335,10 @@ public final class Config {
|
||||
.getInt(powerConduitTierThreeRF);
|
||||
powerConduitCanDifferentTiersConnect = config
|
||||
.getBoolean("powerConduitCanDifferentTiersConnect", sectionPower.name, powerConduitCanDifferentTiersConnect,
|
||||
"If set to false power conduits of different tiers cannot be connected. in this case a block such as a cap. bank is needed to bridge different tiered networks.");
|
||||
|
||||
"If set to false power conduits of different tiers cannot be connected. in this case a block such as a cap. bank is needed to bridge different tiered networks");
|
||||
powerConduitOutputMJ = config.getBoolean("powerConduitOutputMJ", sectionPower.name, powerConduitOutputMJ, "When set to true power conduits will output MJ if RF is not supported");
|
||||
|
||||
|
||||
painterEnergyPerTaskRF = config.get(sectionPower.name, "painterEnergyPerTaskRF", painterEnergyPerTaskRF,
|
||||
"The total amount of RF required to paint one block")
|
||||
.getInt(painterEnergyPerTaskRF);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package crazypants.enderio.power;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
public class PowerInterfaceBC implements IPowerInterface {
|
||||
|
||||
private IPowerReceptor bcPower;
|
||||
|
||||
public PowerInterfaceBC(IPowerReceptor powerReceptor) {
|
||||
bcPower = powerReceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDelegate() {
|
||||
return bcPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConduitConnect(ForgeDirection direction) {
|
||||
if(bcPower instanceof IPipeTile) {
|
||||
IPipeTile pipeTile = (IPipeTile) bcPower;
|
||||
return pipeTile.getPipeType() == PipeType.POWER;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr != null) {
|
||||
return (int)(pr.getEnergyStored() * 10);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection dir) {
|
||||
if(bcPower != null && !(bcPower instanceof IPowerEmitter)) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr != null) {
|
||||
return (int)(pr.getMaxEnergyStored() * 10);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPowerRequest(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr == null || pr.getType() == Type.ENGINE) {
|
||||
return 0;
|
||||
}
|
||||
return (int)( pr.powerRequest() * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinEnergyReceived(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (pr.getMinEnergyReceived() * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recieveEnergy(ForgeDirection opposite, int canOffer) {
|
||||
if(bcPower != null) {
|
||||
if(bcPower instanceof IPowerEmitter) {
|
||||
return 0;
|
||||
}
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(opposite);
|
||||
if(pr == null) {
|
||||
return 0;
|
||||
}
|
||||
double offer = Math.min(pr.powerRequest(), canOffer / 10f);
|
||||
double used = pr.receiveEnergy(Type.PIPE, offer, opposite);
|
||||
return (int) (used * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package crazypants.enderio.power;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.mj.IBatteryObject;
|
||||
|
||||
public class PowerInterfaceBC2 implements IPowerInterface {
|
||||
|
||||
private final IBatteryObject battery;
|
||||
|
||||
public PowerInterfaceBC2(IBatteryObject battery) {
|
||||
this.battery = battery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDelegate() {
|
||||
return battery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConduitConnect(ForgeDirection direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection dir) {
|
||||
return (int) (battery.getEnergyStored() * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection dir) {
|
||||
return (int) (battery.maxCapacity() * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPowerRequest(ForgeDirection dir) {
|
||||
return (int)( battery.getEnergyRequested() * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinEnergyReceived(ForgeDirection dir) {
|
||||
return (int) (battery.minimumConsumption() * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recieveEnergy(ForgeDirection opposite, int canOffer) {
|
||||
double offer = Math.min(battery.getEnergyRequested(), canOffer/10f);
|
||||
return (int) (battery.addEnergy(offer) * 10);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user