mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-25 14:34:24 +00:00
Fixed EU power for machines
This commit is contained in:
1 parent
7bd5c9c691
commit
906037683a
4 files changed
+16
-8
No files matched your search
@@ -10,7 +10,6 @@
|
||||
package net.bdew.gendustry.compat
|
||||
|
||||
import cpw.mods.fml.common.{ModAPIManager, ModContainer, Loader}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import java.util
|
||||
|
||||
@@ -19,7 +18,7 @@ object PowerProxy {
|
||||
final val BC_MOD_ID = "BuildCraftAPI|power"
|
||||
final val TE_MOD_ID = "CoFHCore"
|
||||
|
||||
lazy val lookup: collection.Map[String, ModContainer] = {
|
||||
lazy val lookup: collection.Map[String, ModContainer] = {
|
||||
val mods = new util.ArrayList[ModContainer]
|
||||
val nameLookup = new util.HashMap[String, ModContainer]
|
||||
|
||||
@@ -32,6 +31,7 @@ object PowerProxy {
|
||||
|
||||
lazy val haveBC = haveModVersion(BC_MOD_ID)
|
||||
lazy val haveIC2 = haveModVersion(IC2_MOD_ID)
|
||||
lazy val haveTE = haveModVersion(TE_MOD_ID)
|
||||
|
||||
def haveModVersion(modid: String) = lookup.contains(modid)
|
||||
|
||||
@@ -41,8 +41,15 @@ object PowerProxy {
|
||||
}
|
||||
|
||||
def logModVersions() {
|
||||
Gendustry.logInfo("BC Version: %s", getModVersion(BC_MOD_ID))
|
||||
if (!haveBC && !haveIC2 && !haveTE) {
|
||||
Gendustry.logWarn("No useable energy system detected")
|
||||
Gendustry.logWarn("This mod requires at least one of the following mods to function properly:")
|
||||
Gendustry.logWarn("* BuildCraft 4.2.0+ or any mod that properly bundles the BC API")
|
||||
Gendustry.logWarn("* IC2 Experimental")
|
||||
Gendustry.logWarn("* CoFHCore (Thermal Expansion)")
|
||||
}
|
||||
Gendustry.logInfo("BC API Version: %s", getModVersion(BC_MOD_ID))
|
||||
Gendustry.logInfo("IC2 Version: %s", getModVersion(IC2_MOD_ID))
|
||||
Gendustry.logInfo("CoFHCore Version: %s", getModVersion(TE_MOD_ID))
|
||||
Gendustry.logInfo("TE(CoFHCore) Version: %s", getModVersion(TE_MOD_ID))
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,4 @@ trait TilePoweredBase extends TileExtended {
|
||||
def configurePower(cfg: PoweredMachine) = power.configure(cfg)
|
||||
}
|
||||
|
||||
trait TilePowered extends TilePoweredBase with TilePoweredMJ with TilePoweredRF
|
||||
trait TilePowered extends TilePoweredBase with TilePoweredMJ with TilePoweredRF with TilePoweredEU
|
||||
@@ -21,13 +21,14 @@ import net.bdew.gendustry.Gendustry
|
||||
@Optional.Interface(modid = PowerProxy.IC2_MOD_ID, iface = "ic2.api.energy.tile.IEnergySink")
|
||||
trait TilePoweredEU extends TilePoweredBase with IEnergySink {
|
||||
var sentLoaded = false
|
||||
lazy val ratio = Tuning.getSection("Power").getFloat("IC2_MJ_Ratio")
|
||||
private lazy val ratio = Tuning.getSection("Power").getFloat("EU_MJ_Ratio")
|
||||
lazy val maxSafe = Tuning.getSection("Power").getSection("IC2").getInt("MaxSafeInput")
|
||||
|
||||
if (PowerProxy.haveIC2) {
|
||||
serverTick.listen(() => {
|
||||
if (!sentLoaded) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this))
|
||||
sentLoaded = true
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -42,7 +43,7 @@ trait TilePoweredEU extends TilePoweredBase with IEnergySink {
|
||||
def getMaxSafeInput = maxSafe
|
||||
def demandedEnergyUnits() = (power.capacity - power.stored) * ratio
|
||||
def injectEnergyUnits(directionFrom: ForgeDirection, amount: Double) = {
|
||||
val res = power.inject((amount / ratio).toFloat, false) * ratio
|
||||
val res = power.inject((amount / ratio).toFloat, false) * ratio
|
||||
Gendustry.logInfo("Recieved EU: %f", res)
|
||||
res
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.bdew.gendustry.Gendustry
|
||||
|
||||
@Optional.Interface(modid = PowerProxy.TE_MOD_ID, iface = "cofh.api.energy.IEnergyHandler")
|
||||
trait TilePoweredRF extends TilePoweredBase with IEnergyHandler {
|
||||
lazy val ratio = Tuning.getSection("Power").getFloat("RF_MJ_Ratio")
|
||||
private lazy val ratio = Tuning.getSection("Power").getFloat("RF_MJ_Ratio")
|
||||
|
||||
def receiveEnergy(from: ForgeDirection, maxReceive: Int, simulate: Boolean) = {
|
||||
val res = (power.inject(maxReceive / ratio, simulate) * ratio).floor.toInt
|
||||
|
||||
Reference in new issue
Block a user