diff --git a/gradle.properties b/gradle.properties index da17ede91..2abf55124 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ MAJORVERSION = 1 MINORVERSION = 16 -REVISION = 16 +REVISION = 17 GROUP = 'net.electricalage.eln' ARCHIVE_NAME = 'ElectricalAge-jrddunbr' diff --git a/src/main/java/mods/eln/Eln.java b/src/main/java/mods/eln/Eln.java index 3aa297e93..bdd456aa2 100644 --- a/src/main/java/mods/eln/Eln.java +++ b/src/main/java/mods/eln/Eln.java @@ -178,6 +178,7 @@ import java.util.*; +import static jdk.nashorn.internal.objects.NativeMath.max; import static mods.eln.i18n.I18N.*; @SuppressWarnings({"SameParameterValue", "PointlessArithmeticExpression"}) @@ -338,6 +339,8 @@ public class Eln { public static boolean verticalIronCableCrafting = false; + public static Double flywheelMass = 0.0; + @EventHandler public void preInit(FMLPreInitializationEvent event) { @@ -423,10 +426,9 @@ public void preInit(FMLPreInitializationEvent event) { fuelHeatFurnacePowerFactor = config.get("balancing", "fuelHeatFurnacePowerFactor", 1.0).getDouble(); autominerRange = config.get("balancing", "autominerRange", 10, "Maximum horizontal distance from autominer that will be mined").getInt(10); - Other.ElnToIc2ConversionRatio = config.get("balancing", "ElnToIndustrialCraftConversionRatio", 1.0 / 3.0).getDouble(1.0 / 3.0); - Other.ElnToOcConversionRatio = config.get("balancing", "ElnToOpenComputerConversionRatio", 1.0 / 3.0 / 2.5).getDouble(1.0 / 3.0 / 2.5); - Other.ElnToTeConversionRatio = config.get("balancing", "ElnToThermalExpansionConversionRatio", 1.0 / 3.0 * 4).getDouble(1.0 / 3.0 * 4); - // Other.ElnToBuildcraftConversionRatio = config.get("balancing", "ElnToBuildcraftConversionRatio", 1.0 / 3.0 / 5 * 2).getDouble(1.0 / 3.0 / 5 * 2); + Other.wattsToEu = config.get("balancing", "ElnToIndustrialCraftConversionRatio", 1.0 / 3.0).getDouble(1.0 / 3.0); + Other.wattsToOC = config.get("balancing", "ElnToOpenComputerConversionRatio", 1.0 / 3.0 / 2.5).getDouble(1.0 / 3.0 / 2.5); + Other.wattsToRf = config.get("balancing", "ElnToThermalExpansionConversionRatio", 1.0 / 3.0 * 4).getDouble(1.0 / 3.0 * 4); plateConversionRatio = config.get("balancing", "platesPerIngot", 1).getInt(1); shaftEnergyFactor = config.get("balancing", "shaftEnergyFactor", 0.05).getDouble(0.05); @@ -436,7 +438,7 @@ public void preInit(FMLPreInitializationEvent event) { ComputerProbeEnable = config.get("compatibility", "ComputerProbeEnable", true).getBoolean(true); ElnToOtherEnergyConverterEnable = config.get("compatibility", "ElnToOtherEnergyConverterEnable", true).getBoolean(true); - replicatorPop = config.get("entity", "replicatorPop", true).getBoolean(true); + replicatorPop = config.get("entity", "replicatorPop", false).getBoolean(false); ReplicatorPopProcess.popPerSecondPerPlayer = config.get("entity", "replicatorPopWhenThunderPerSecond", 1.0 / 120).getDouble(1.0 / 120); replicatorRegistrationId = config.get("entity", "replicatorId", -1).getInt(-1); killMonstersAroundLamps = config.get("entity", "killMonstersAroundLamps", true).getBoolean(true); @@ -501,6 +503,8 @@ public void preInit(FMLPreInitializationEvent event) { Eln.maxSoundDistance = config.get("debug", "maxSoundDistance", 16.0).getDouble(); + Eln.flywheelMass = Math.min(Math.max(config.get("balancing", "flywheelMass", 50.0).getDouble(), 1.0), 1000.0); + config.save(); eventChannel = NetworkRegistry.INSTANCE.newEventDrivenChannel(channelName); @@ -587,7 +591,7 @@ public void preInit(FMLPreInitializationEvent event) { SixNode.sixNodeCacheList.add(new SixNodeCacheStd()); registerTestBlock(); - //registerEnergyConverter(); + registerEnergyConverter(); registerComputer(); registerArmor(); @@ -833,7 +837,7 @@ public void load(FMLInitializationEvent event) { registerReplicator(); // - //recipeEnergyConverter(); + recipeEnergyConverter(); recipeComputerProbe(); recipeArmor(); @@ -957,7 +961,7 @@ private void registerEnergyConverter() { new EnergyConverterElnToOtherDescriptor("EnergyConverterElnToOtherLVU", ELN_CONVERTER_MAX_POWER); elnToOtherBlockConverter = new EnergyConverterElnToOtherBlock(desc); elnToOtherBlockConverter.setCreativeTab(creativeTab).setBlockName(blockName); - //GameRegistry.registerBlock(elnToOtherBlockConverter, SimpleNodeItem.class, blockName); + GameRegistry.registerBlock(elnToOtherBlockConverter, SimpleNodeItem.class, blockName); } } } diff --git a/src/main/java/mods/eln/Other.java b/src/main/java/mods/eln/Other.java index 650ef0c05..cc86d58c1 100644 --- a/src/main/java/mods/eln/Other.java +++ b/src/main/java/mods/eln/Other.java @@ -9,9 +9,9 @@ public class Other { public static boolean ccLoaded = false; public static boolean teLoaded = false; - public static double ElnToIc2ConversionRatio; - public static double ElnToOcConversionRatio; - public static double ElnToTeConversionRatio; + public static double wattsToEu; + public static double wattsToOC; + public static double wattsToRf; public static final String modIdIc2 = "IC2"; public static final String modIdOc = "OpenComputers"; @@ -25,15 +25,15 @@ public static void check() { teLoaded = Loader.isModLoaded(modIdTe); } - public static double getElnToIc2ConversionRatio() { - return ElnToIc2ConversionRatio; + public static double getWattsToEu() { + return wattsToEu; } - public static double getElnToOcConversionRatio() { - return ElnToOcConversionRatio; + public static double getWattsToOC() { + return wattsToOC; } - public static double getElnToTeConversionRatio() { - return ElnToTeConversionRatio; + public static double getWattsToRf() { + return wattsToRf; } } diff --git a/src/main/java/mods/eln/mechanical/Flywheel.kt b/src/main/java/mods/eln/mechanical/Flywheel.kt index 68f251113..5290cdc00 100644 --- a/src/main/java/mods/eln/mechanical/Flywheel.kt +++ b/src/main/java/mods/eln/mechanical/Flywheel.kt @@ -1,5 +1,6 @@ package mods.eln.mechanical +import mods.eln.Eln import mods.eln.misc.Direction import mods.eln.misc.LinearFunction import mods.eln.misc.Obj3D @@ -21,7 +22,7 @@ class FlywheelDescriptor(baseName: String, obj: Obj3D) : SimpleShaftDescriptor(b } class FlyWheelElement(node: TransparentNode, desc_: TransparentNodeDescriptor) : StraightJointElement(node, desc_) { - override val shaftMass = 10.0 + override val shaftMass = Eln.flywheelMass?: 50.0 inner class FlyWheelFlingProcess : IProcess { val interval = 0.05 diff --git a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherEntity.kt b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherEntity.kt index 1a0fc9e40..c1e395738 100644 --- a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherEntity.kt +++ b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherEntity.kt @@ -19,7 +19,6 @@ import net.minecraft.tileentity.TileEntity import net.minecraftforge.common.util.ForgeDirection import java.io.DataInputStream import java.io.IOException -import kotlin.math.min @InterfaceList(Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = Other.modIdIc2), Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = Other.modIdTe), Optional.Interface(iface = "li.cil.oc.api.network.Environment", modid = Other.modIdOc)) class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Environment, IEnergyHandler { @@ -30,6 +29,7 @@ class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Envir var ocEnergy: EnergyConverterElnToOtherFireWallOc? = null @JvmField var addedToEnet = false + var ic2tier = 1 @SideOnly(Side.CLIENT) override fun newGuiDraw(side: Direction, player: EntityPlayer): GuiScreen { @@ -40,6 +40,7 @@ class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Envir super.serverPublishUnserialize(stream) try { selectorPower = stream.readDouble() + ic2tier = stream.readInt() hasChanges = true } catch (e: IOException) { e.printStackTrace() @@ -63,10 +64,7 @@ class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Envir if (worldObj.isRemote) return 0.0 if (node == null) return 0.0 val node = node as EnergyConverterElnToOtherNode - //val offered = node.getOtherModEnergyBuffer(Other.ElnToIc2ConversionRatio) - val offered = node.getOtherModOutMax(node.energyBuffer, Other.getElnToIc2ConversionRatio()) - println("offering: $offered of ${node.energyBuffer}") - return offered + return node.availableEnergyInModUnitsWithLimit(IC2Tiers.values().first { it.tier == node.ic2tier }.euPerTick.toDouble(), Other.getWattsToEu()) } @Optional.Method(modid = Other.modIdIc2) @@ -74,8 +72,7 @@ class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Envir if (worldObj.isRemote) return if (node == null) return val node = node as EnergyConverterElnToOtherNode - val draw = node.drawEnergy(amount, Other.getElnToIc2ConversionRatio()) - println("drawing $draw") + node.drawEnergy(amount, Other.getWattsToEu()) } @Optional.Method(modid = Other.modIdIc2) @@ -146,8 +143,8 @@ class EnergyConverterElnToOtherEntity : SimpleNodeEntity(), IEnergySource, Envir if (worldObj.isRemote) return 0 if (node == null) return 0 val node = node as EnergyConverterElnToOtherNode - val extract = Math.max(0, Math.min(maxExtract, node.getOtherModEnergyBuffer(Other.getElnToTeConversionRatio()).toInt())) - if (!simulate) node.drawEnergy(extract.toDouble(), Other.getElnToTeConversionRatio()) + val extract = Math.max(0, Math.min(maxExtract, node.availableEnergyInModUnits(Other.getWattsToRf()).toInt())) + if (!simulate) node.drawEnergy(extract.toDouble(), Other.getWattsToRf()) return extract } diff --git a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallOc.kt b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallOc.kt index 79f34fc7e..41fa8acc0 100644 --- a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallOc.kt +++ b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallOc.kt @@ -28,10 +28,10 @@ class EnergyConverterElnToOtherFireWallOc(var e: EnergyConverterElnToOtherEntity if (e.node == null) return val c = node as Connector val node = e.node as EnergyConverterElnToOtherNode - var eMax = node.getOtherModEnergyBuffer(Other.getElnToOcConversionRatio()) + var eMax = node.availableEnergyInModUnits(Other.getWattsToOC()) eMax = Math.min(Math.min(eMax, c.globalBufferSize() - c.globalBuffer()), node.descriptor!!.maxPower) if (c.tryChangeBuffer(eMax)) { - node.drawEnergy(eMax, Other.getElnToOcConversionRatio()) + node.drawEnergy(eMax, Other.getWattsToOC()) } } } diff --git a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallRf.kt b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallRf.kt index d9fd52ccc..1fc3bb90b 100644 --- a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallRf.kt +++ b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherFireWallRf.kt @@ -3,7 +3,6 @@ package mods.eln.simplenode.energyconverter import cofh.api.energy.IEnergyHandler import mods.eln.Other import mods.eln.misc.Direction -import mods.eln.node.simple.SimpleNode object EnergyConverterElnToOtherFireWallRf { @@ -17,11 +16,12 @@ object EnergyConverterElnToOtherFireWallRf { .filter{ it.first is IEnergyHandler } .map { Pair(it.first as IEnergyHandler, it.second) } if (energySinkList.isEmpty()) return - val pMax = node.getOtherModEnergyBuffer(Other.getElnToTeConversionRatio()) - - val energyUsed = energySinkList.map { - it.first.receiveEnergy(it.second.toForge(), pMax.toInt() / energySinkList.size, false).toDouble() + val rfUsed = energySinkList.map { + val rfAvailable = (node.availableEnergyInModUnits(Other.getWattsToRf()) / energySinkList.size) + // receiveEnergy takes RF in, gives out RF + val rfUsed = it.first.receiveEnergy(it.second.toForge(), rfAvailable.toInt(), false).toDouble() + rfUsed }.sum() - node.drawEnergy(energyUsed, Other.getElnToTeConversionRatio()) + node.drawEnergy(rfUsed, Other.getWattsToRf()) } } diff --git a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherGui.kt b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherGui.kt index 317355271..fe967f82a 100644 --- a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherGui.kt +++ b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherGui.kt @@ -8,50 +8,42 @@ import mods.eln.gui.GuiTextFieldEln import mods.eln.gui.GuiVerticalTrackBar import mods.eln.gui.IGuiObject import mods.eln.i18n.I18N -import java.lang.Math.pow -import java.text.DecimalFormat import kotlin.math.log -import kotlin.math.max import kotlin.math.pow -import kotlin.math.roundToInt class EnergyConverterElnToOtherGui(var render: EnergyConverterElnToOtherEntity) : GuiScreenEln() { var powerSelector: GuiVerticalTrackBar? = null - //var ic2tier1: GuiButtonEln? = null - //var ic2tier2: GuiButtonEln? = null - //var ic2tier3: GuiButtonEln? = null - //var ic2tier4: GuiButtonEln? = null - //var ic2tier5: GuiButtonEln? = null + var ic2tier1: GuiButtonEln? = null + var ic2tier2: GuiButtonEln? = null + var ic2tier3: GuiButtonEln? = null + var ic2tier4: GuiButtonEln? = null var powerEntry: GuiTextFieldEln? = null - val maxPower = Eln.instance.ELN_CONVERTER_MAX_POWER + private val maxPower = Eln.instance.ELN_CONVERTER_MAX_POWER - //var ic2tierList: List? = null + var ic2tierList: List? = null override fun initGui() { super.initGui() - powerSelector = newGuiVerticalTrackBar(6, 6 + 2, 20, 100) + powerSelector = newGuiVerticalTrackBar(6, 6 + 2, 20, 82) powerSelector!!.setStepIdMax(100) powerSelector!!.setEnable(true) powerSelector!!.setRange(0f, 1f) - //ic2tier1 = newGuiButton(35, 6, 40,"IC2 T1") - //ic2tier2 = newGuiButton(35, 28, 40,"IC2 T2") - //ic2tier3 = newGuiButton(35, 50, 40,"IC2 T3") - //ic2tier4 = newGuiButton(35, 72, 40,"IC2 T4") - //ic2tier5 = newGuiButton(35, 94, 40, "IC2 T5") - //ic2tierList = listOfNotNull(ic2tier1, ic2tier2, ic2tier3, ic2tier4, ic2tier5) - //ic2tier1!!.enabled = true - //ic2tier1!!.setComment(0, "Set output to 32 EU/t max") - //ic2tier2!!.enabled = true - //ic2tier2!!.setComment(0, "Set output to 128 EU/t max") - //ic2tier3!!.enabled = true - //ic2tier3!!.setComment(0, "Set output to 512 EU/t max") - //ic2tier4!!.enabled = true - //ic2tier4!!.setComment(0, "Set output to 2048 EU/t max") - //ic2tier5!!.enabled = true - //ic2tier5!!.setComment(0, "Set output to 8192 EU/t max") - powerEntry = newGuiTextField(6, 112, 55) + ic2tier1 = newGuiButton(30, 6, 47,"IC2 T1") + ic2tier2 = newGuiButton(30, 28, 47,"IC2 T2") + ic2tier3 = newGuiButton(30, 50, 47,"IC2 T3") + ic2tier4 = newGuiButton(30, 72, 47,"IC2 T4") + ic2tierList = listOfNotNull(ic2tier1, ic2tier2, ic2tier3, ic2tier4) + ic2tier1!!.enabled = true + ic2tier1!!.setComment(0, "Set output to 32 EU/t max") + ic2tier2!!.enabled = true + ic2tier2!!.setComment(0, "Set output to 128 EU/t max") + ic2tier3!!.enabled = true + ic2tier3!!.setComment(0, "Set output to 512 EU/t max") + ic2tier4!!.enabled = true + ic2tier4!!.setComment(0, "Set output to 2048 EU/t max") + powerEntry = newGuiTextField(6, 96, 70) powerEntry!!.enabled powerEntry!!.setComment(listOf("Select the maximum export power").toTypedArray()) syncVoltage() @@ -60,19 +52,24 @@ class EnergyConverterElnToOtherGui(var render: EnergyConverterElnToOtherEntity) fun syncVoltage() { powerSelector!!.value = selectedPowerToSlider(render.selectorPower) powerEntry!!.text = render.selectorPower.toInt().toString() + ic2tierList!!.forEachIndexed { + index, button -> + val tier = index + 1 + button.displayString = if (tier == render.ic2tier) { + "[IC2 T$tier]" + } else { + "IC2 T$tier" + } + } render.hasChanges = false } fun selectedPowerToSlider(selectedPower: Double): Float { return log(selectedPower / 100 + 1, (maxPower / 100) + 1).toFloat() - //return log(selectedPower + 1, Eln.instance.ELN_CONVERTER_MAX_POWER + 1).toFloat() - //return log(selectedPower, Eln.instance.ELN_CONVERTER_MAX_POWER).toFloat() } fun sliderToSelectedPower(slider: Float): Double { - return 100 * (pow((maxPower / 100) + 1, slider.toDouble()) - 1) - //return pow(Eln.instance.ELN_CONVERTER_MAX_POWER + 1, slider.toDouble()) - 1 - //return Eln.instance.ELN_CONVERTER_MAX_POWER.pow(slider.toDouble()) + return 100 * (((maxPower / 100) + 1).pow(slider.toDouble()) - 1) } override fun guiObjectEvent(guiObject: IGuiObject) { @@ -86,26 +83,24 @@ class EnergyConverterElnToOtherGui(var render: EnergyConverterElnToOtherEntity) render.selectorPower = powerEntry!!.text.toDoubleOrNull()?: render.selectorPower render.sender.clientSendDouble(NetworkType.SET_POWER.id, render.selectorPower) } - //guiObject === ic2tier1 -> - // render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 1) - //guiObject === ic2tier2 -> - // render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 2) - //guiObject === ic2tier3 -> - // render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 3) - //guiObject === ic2tier4 -> - // render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 4) - //guiObject === ic2tier5 -> - // render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 5) + guiObject === ic2tier1 -> + render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 1) + guiObject === ic2tier2 -> + render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 2) + guiObject === ic2tier3 -> + render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 3) + guiObject === ic2tier4 -> + render.sender.clientSendInt(NetworkType.SET_IC2_TIER.id, 4) } } override fun preDraw(f: Float, x: Int, y: Int) { super.preDraw(f, x, y) if (render.hasChanges) syncVoltage() - powerSelector!!.setComment(0, I18N.tr("Input power is limited to %1\$W", sliderToSelectedPower(powerSelector!!.value).toInt())) + powerSelector!!.setComment(0, I18N.tr("Input power is limited to %1\$W", render.selectorPower)) } override fun newHelper(): GuiHelper { - return GuiHelper(this, 67, 140) + return GuiHelper(this, 82, 115) } } diff --git a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherNode.kt b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherNode.kt index 7e7d2488a..7ad50d193 100644 --- a/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherNode.kt +++ b/src/main/java/mods/eln/simplenode/energyconverter/EnergyConverterElnToOtherNode.kt @@ -1,7 +1,6 @@ package mods.eln.simplenode.energyconverter import mods.eln.Eln -import mods.eln.Other import mods.eln.misc.Direction import mods.eln.misc.LRDU import mods.eln.node.simple.SimpleNode @@ -11,13 +10,13 @@ import mods.eln.sim.ThermalLoad import mods.eln.sim.mna.misc.MnaConst import mods.eln.sim.nbt.NbtElectricalLoad import mods.eln.sim.nbt.NbtResistor -import net.minecraft.client.renderer.texture.ITickable import net.minecraft.entity.player.EntityPlayerMP import net.minecraft.nbt.NBTTagCompound import java.io.DataInputStream import java.io.DataOutputStream import java.io.IOException import kotlin.math.max +import kotlin.math.min class EnergyConverterElnToOtherNode : SimpleNode() { var descriptor: EnergyConverterElnToOtherDescriptor? = null @@ -71,46 +70,59 @@ class EnergyConverterElnToOtherNode : SimpleNode() { timeout -= time if (timeout < 0) { timeout = 0.05 - val energyMiss = energyBufferMax - energyBuffer - if (energyMiss <= 0) { + if (energyBufferMax - energyBuffer <= 0) { powerInResistor.highImpedance() } else { - val inP = selectedPower - if (inP <= 0.0) { + if (selectedPower <= 0.0) { powerInResistor.r = MnaConst.highImpedance } else { - powerInResistor.r = max(Eln.getSmallRs(), load.u * load.u / inP) + powerInResistor.r = max(Eln.getSmallRs(), load.u * load.u / selectedPower) } } } - println("Energy buffer: $energyBuffer/$energyBufferMax") } } - fun getOtherModEnergyBuffer(conversionRatio: Double): Double { + /** + * @param conversionRatio Conversion Ratio (Input mod conversion ratio here) + * @return energy buffer in that mod unit (Units are RF/EU/OC, etc.) + */ + fun availableEnergyInModUnits(conversionRatio: Double): Double { return energyBuffer * conversionRatio } + /** + * @param otherModEnergy Energy from other mod (RF/EU/OC, etc.) to draw + * @param conversionRatio Conversion Ratio (Input mod conversion ratio here) + * @return Watts drawn from the energy buffer + */ fun drawEnergy(otherModEnergy: Double, conversionRatio: Double): Double { val drawEnergy = otherModEnergy / conversionRatio energyBuffer -= drawEnergy return drawEnergy } - fun getOtherModOutMax(otherOutMax: Double, conversionRatio: Double): Double { - return Math.min(getOtherModEnergyBuffer(conversionRatio), otherOutMax) + /** + * @param maximumModUnits The maximum number of mod units (EU/RF/OC/etc.) that can be drawn + * @param conversionRatio Conversion Ratio (Input mod conversion ratio here) + * @return maximum Mod Units that can be drawn + */ + fun availableEnergyInModUnitsWithLimit(maximumModUnits: Double, conversionRatio: Double): Double { + return min(availableEnergyInModUnits(conversionRatio), maximumModUnits * conversionRatio) / conversionRatio } override fun writeToNBT(nbt: NBTTagCompound) { super.writeToNBT(nbt) nbt.setDouble("energyBuffer", energyBuffer) nbt.setDouble("selectedPower", selectedPower) + nbt.setInteger("ic2tier", ic2tier) } override fun readFromNBT(nbt: NBTTagCompound) { super.readFromNBT(nbt) energyBuffer = nbt.getDouble("energyBuffer") selectedPower = nbt.getDouble("selectedPower") + ic2tier = nbt.getInteger("ic2tier") } override fun hasGui(side: Direction): Boolean { @@ -121,6 +133,7 @@ class EnergyConverterElnToOtherNode : SimpleNode() { super.publishSerialize(stream) try { stream.writeDouble(selectedPower) + stream.writeInt(ic2tier) } catch (e: IOException) { e.printStackTrace() } @@ -130,21 +143,16 @@ class EnergyConverterElnToOtherNode : SimpleNode() { try { when (stream.readByte()) { NetworkType.SET_POWER.id -> { - selectedPower = stream.readDouble() + val power = stream.readDouble() + if (power in 0.0 .. 120_000.0) { + selectedPower = power + } needPublish() } NetworkType.SET_IC2_TIER.id -> { val tier = stream.readInt() - if (tier in 1..5) { - val tierLimit = when(tier) { - 1 -> 32 - 2 -> 128 - 3 -> 512 - 4 -> 2048 - 5 -> 8192 - else -> 32 - } - selectedPower = tierLimit * (1 / Other.getElnToIc2ConversionRatio()) + if (tier in 1..4) { + ic2tier = tier needPublish() } } @@ -169,3 +177,12 @@ enum class NetworkType(val id: Byte) { SET_POWER(1), SET_IC2_TIER(2) } + +enum class IC2Tiers(val tier: Int, val euPerTick: Int) { + TIER_1(1, 32), + TIER_2(2, 128), + TIER_3(3, 512), + TIER_4(4, 2048) + // Yes, there is a Tier 5, no it does not work. + // It caps at around 2kEU/t with an infinite energy sink, after that it voids energy +} diff --git a/src/main/java/mods/eln/transparentnode/themralheatexchanger/ThermalHeatExchanger.kt b/src/main/java/mods/eln/transparentnode/themralheatexchanger/ThermalHeatExchanger.kt index 26c543a45..6664f3ec6 100644 --- a/src/main/java/mods/eln/transparentnode/themralheatexchanger/ThermalHeatExchanger.kt +++ b/src/main/java/mods/eln/transparentnode/themralheatexchanger/ThermalHeatExchanger.kt @@ -69,6 +69,11 @@ class ThermalHeatExchangerDescriptor( list.add(I18N.tr("Ejects out ic2:coolant")) list.add(Utils.plotCelsius(I18N.tr(" Max. temperature: "), thermal.warmLimit)) } + + override fun mustHaveFloor() = false + override fun mustHaveCeiling() = false + override fun mustHaveWall() = false + override fun mustHaveWallFrontInverse() = false } data class ThermalPairing(val input: Fluid, val output: Fluid, val joulesPerMb: Double, val maxMbInputPerTick: Int, val ratio: Double = 1.0, val reversible: Boolean = false, val minTemp: Double? = null, val maxTemp: Double? = null) diff --git a/src/main/resources/assets/eln/lang/en_US.lang b/src/main/resources/assets/eln/lang/en_US.lang index 39b4d727e..d11858934 100644 --- a/src/main/resources/assets/eln/lang/en_US.lang +++ b/src/main/resources/assets/eln/lang/en_US.lang @@ -122,7 +122,7 @@ Electrical_Light_Sensor.name=Electrical Light Sensor Electrical_Motor.name=Electrical Motor Electrical_Probe.name=Electrical Probe Electrical_Probe_Chip.name=Electrical Probe Chip -Electrical_Source.name=Electrical Source +Electrical_Source.name=Voltage Source Electrical_Timer.name=Electrical Timer Electrical_Weather_Sensor.name=Electrical Weather Sensor Electrical_age_wrench,\nCan_be_used_to_turn\nsmall_wall_blocks=Electrical age wrench,\nCan be used to turn\nsmall wall blocks @@ -333,9 +333,7 @@ mod.meta.desc=Electricity in your base! tile.arc_clay_block.name=Arc Clay Block tile.arc_metal_block.name=Arc Metal Block tile.eln.ElnProbe.name=Eln Computer Probe -tile.eln.EnergyConverterElnToOtherHVUBlock.name=800V Electrical Age to other energy exporter -tile.eln.EnergyConverterElnToOtherLVUBlock.name=50V Electrical Age to other energy exporter -tile.eln.EnergyConverterElnToOtherMVUBlock.name=200V Electrical Age to other energy exporter +tile.eln.EnergyConverter.name=Energy Exporter # ./src/main/java/mods/eln/i18n/I18N.java You_have_%1$_lives_left=You have %1$ lives left