From 8fe921eebe0ef28bfd7f9ff079c4f9b567a07417 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Sun, 3 Nov 2013 10:26:43 +0000 Subject: [PATCH] Add config option to allow powering Railcraft and other MJ machines without BC loaded. Hopefully won't cause bugs... --- common/mekanism/common/CommonProxy.java | 1 + common/mekanism/common/EnergyNetwork.java | 7 ++++--- common/mekanism/common/Mekanism.java | 1 + common/mekanism/common/util/CableUtils.java | 6 +++--- common/mekanism/common/util/MekanismUtils.java | 6 ++++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 6291303dd..f8a381afe 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -150,6 +150,7 @@ public class CommonProxy Mekanism.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(true); Mekanism.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(true); Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); + Mekanism.forceBuildcraft = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ForceBuildcraftPower", false).getBoolean(false); Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); diff --git a/common/mekanism/common/EnergyNetwork.java b/common/mekanism/common/EnergyNetwork.java index 3213faf9c..b2229054b 100644 --- a/common/mekanism/common/EnergyNetwork.java +++ b/common/mekanism/common/EnergyNetwork.java @@ -16,6 +16,7 @@ import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.ITransmitter; import mekanism.api.transmitters.TransmissionType; import mekanism.common.util.CableUtils; +import mekanism.common.util.MekanismUtils; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; @@ -77,7 +78,7 @@ public class EnergyNetwork extends DynamicNetwork { totalNeeded += Math.min((((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2), (((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2)); } - else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded) + else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft()) { totalNeeded += (((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()).powerRequest()*Mekanism.FROM_BC); } @@ -124,7 +125,7 @@ public class EnergyNetwork extends DynamicNetwork double toSend = Math.min(currentSending, (((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2)); energyToSend -= (toSend - (((IEnergySink)acceptor).injectEnergyUnits(acceptorDirections.get(acceptor).getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2)); } - else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded) + else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft()) { PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()); double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC; @@ -175,7 +176,7 @@ public class EnergyNetwork extends DynamicNetwork } } } - else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded) + else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft()) { if(((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()) != null) { diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index a8bb806c8..e58ca54fc 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -217,6 +217,7 @@ public class Mekanism public static boolean logPackets = false; public static boolean dynamicTankEasterEgg = false; public static boolean voiceServerEnabled = true; + public static boolean forceBuildcraft = false; public static int obsidianTNTBlastRadius = 12; public static int obsidianTNTDelay = 100; public static int UPDATE_DELAY = 10; diff --git a/common/mekanism/common/util/CableUtils.java b/common/mekanism/common/util/CableUtils.java index 025341dfb..2cdbf77ee 100644 --- a/common/mekanism/common/util/CableUtils.java +++ b/common/mekanism/common/util/CableUtils.java @@ -45,7 +45,7 @@ public final class CableUtils if(acceptor instanceof IStrictEnergyAcceptor || acceptor instanceof IEnergySink || - (acceptor instanceof IPowerReceptor && !(acceptor instanceof ITransmitter) && Mekanism.hooks.BuildCraftLoaded) || + (acceptor instanceof IPowerReceptor && !(acceptor instanceof ITransmitter) && MekanismUtils.useBuildcraft()) || acceptor instanceof IElectrical) { acceptors[orientation.ordinal()] = acceptor; @@ -177,7 +177,7 @@ public final class CableUtils return true; } - if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof ITransmitter) && Mekanism.hooks.BuildCraftLoaded) + if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof ITransmitter) && MekanismUtils.useBuildcraft()) { if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, side.getOpposite())) { @@ -281,7 +281,7 @@ public final class CableUtils double toSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); emitter.setEnergy(emitter.getEnergy() - (toSend - acceptor.transferEnergyToAcceptor(toSend))); } - else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded) + else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildcraft()) { PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(emitter.getOutputtingSide().getOpposite()); diff --git a/common/mekanism/common/util/MekanismUtils.java b/common/mekanism/common/util/MekanismUtils.java index b06671727..23fc7b898 100644 --- a/common/mekanism/common/util/MekanismUtils.java +++ b/common/mekanism/common/util/MekanismUtils.java @@ -23,6 +23,7 @@ import mekanism.common.IModule; import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl; import mekanism.common.Mekanism; +import mekanism.common.MekanismHooks; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.Teleporter; @@ -1005,6 +1006,11 @@ public final class MekanismUtils return false; } + public static boolean useBuildcraft() + { + return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft; + } + public static enum ResourceType { GUI("gui"),