mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Added 1.7 UE API. No idea if this implementation is correct, tho.
This commit is contained in:
parent
2f03b932f5
commit
9a41e9a506
@ -3,11 +3,16 @@ repositories {
|
||||
name = "ic2"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
maven {
|
||||
name = "ue"
|
||||
url = "http://calclavia.com/maven/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compile "codechicken:CodeChickenLib:${config.cc.mc.version}-${config.ccl.version}:dev"
|
||||
compile "codechicken:ForgeMultipart:${config.cc.mc.version}-${config.fmp.version}:dev"
|
||||
compile "net.industrial-craft:industrialcraft-2:2.2.509-experimental:api"
|
||||
compile "dev.calclavia.universalelectricity:universal-electricity:+:dev"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
@ -240,9 +240,9 @@ object Settings {
|
||||
|
||||
// Power conversion values. These are the same values used by Universal
|
||||
// Electricity to provide global power support.
|
||||
val valueBC = 56280.0
|
||||
val valueIC2 = 22512.0
|
||||
val valueTE = 5628.0
|
||||
val valueBC = 500.0
|
||||
val valueIC2 = 200.0
|
||||
val valueTE = 50.0
|
||||
val valueUE = 1.0
|
||||
|
||||
val valueOC = valueBC
|
||||
|
@ -5,4 +5,4 @@ trait PowerAcceptor
|
||||
with power.BuildCraft
|
||||
with power.IndustrialCraft2
|
||||
with power.ThermalExpansion
|
||||
// with power.UniversalElectricity
|
||||
with power.UniversalElectricity
|
@ -1,39 +1,51 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import cpw.mods.fml.common.Optional
|
||||
//import li.cil.oc.Settings
|
||||
//import net.minecraftforge.common.util.ForgeDirection
|
||||
//import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
//import universalelectricity.api.core.grid.electric.{IElectricNode, IEnergyContainer}
|
||||
//
|
||||
//@Optional.InterfaceList(Array(
|
||||
// new Optional.Interface(iface = "universalelectricity.api.core.grid.INodeProvider", modid = "UniversalElectricity"),
|
||||
// new Optional.Interface(iface = "universalelectricity.api.core.grid.electric.IEnergyContainer", modid = "UniversalElectricity")
|
||||
//))
|
||||
//trait UniversalElectricity extends Common with INodeProvider with IEnergyContainer {
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def canConnect(direction: ForgeDirection, source: AnyRef) = canConnectPower(direction)
|
||||
//
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def onReceiveEnergy(from: ForgeDirection, receive: Long, doReceive: Boolean) =
|
||||
// (tryChangeBuffer(from, receive * Settings.ratioUE, doReceive) / Settings.ratioUE).toLong
|
||||
//
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def onExtractEnergy(from: ForgeDirection, extract: Long, doExtract: Boolean) = 0
|
||||
//
|
||||
// override def getNode[N <: INode](nodeType: Class[N], from: ForgeDirection) = {
|
||||
// if (canConnectPower(from) && nodeType == classOf[IElectricNode]) {
|
||||
//
|
||||
// }
|
||||
// else null
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def setEnergy(from: ForgeDirection, energy: Double) {}
|
||||
//
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def getEnergy(from: ForgeDirection) = globalBuffer(from) / Settings.ratioUE
|
||||
//
|
||||
// @Optional.Method(modid = "UniversalElectricity")
|
||||
// override def getEnergyCapacity(from: ForgeDirection) = globalBufferSize(from) / Settings.ratioUE
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.util.mods.Mods
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import universalelectricity.api.core.grid.electric.{IElectricNode, IEnergyContainer}
|
||||
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
|
||||
@Optional.InterfaceList(Array(
|
||||
new Optional.Interface(iface = "universalelectricity.api.core.grid.INodeProvider", modid = "UniversalElectricity"),
|
||||
new Optional.Interface(iface = "universalelectricity.api.core.grid.electric.IEnergyContainer", modid = "UniversalElectricity")
|
||||
))
|
||||
trait UniversalElectricity extends Common with INodeProvider with IEnergyContainer {
|
||||
private lazy val ueNode: AnyRef = universalelectricity.api.core.grid.NodeRegistry.get(this, classOf[IElectricNode])
|
||||
|
||||
private lazy val useUniversalElectricityPower = isServer && !Settings.get.ignorePower && Mods.BuildCraftPower.isAvailable
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (useUniversalElectricityPower && world.getWorldTime % Settings.get.tickFrequency == 0) {
|
||||
val electric = ueNode.asInstanceOf[IElectricNode]
|
||||
for (side <- ForgeDirection.VALID_DIRECTIONS) {
|
||||
val demand = (globalBufferSize(side) - globalBuffer(side)) / Settings.ratioUE
|
||||
val power = math.min(demand, electric.getEnergy(100))
|
||||
if (power > 1) {
|
||||
electric.drawPower(power)
|
||||
tryChangeBuffer(side, power * Settings.ratioUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def getNode[N <: INode](nodeType: Class[N], from: ForgeDirection) = {
|
||||
if (canConnectPower(from) && nodeType == classOf[IElectricNode]) ueNode.asInstanceOf[N]
|
||||
else null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "UniversalElectricity")
|
||||
override def setEnergy(from: ForgeDirection, energy: Double) {}
|
||||
|
||||
@Optional.Method(modid = "UniversalElectricity")
|
||||
override def getEnergy(from: ForgeDirection) = globalBuffer(from) / Settings.ratioUE
|
||||
|
||||
@Optional.Method(modid = "UniversalElectricity")
|
||||
override def getEnergyCapacity(from: ForgeDirection) = globalBufferSize(from) / Settings.ratioUE
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user