Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into 1.8prep

Conflicts:
	build.properties
	src/main/scala/li/cil/oc/common/SaveHandler.scala
	src/main/scala/li/cil/oc/common/block/Delegator.scala
	src/main/scala/li/cil/oc/common/component/TextBuffer.scala
	src/main/scala/li/cil/oc/common/event/ChunkloaderUpgradeHandler.scala
	src/main/scala/li/cil/oc/common/item/Tablet.scala
	src/main/scala/li/cil/oc/common/template/TabletTemplate.scala
	src/main/scala/li/cil/oc/server/component/Geolyzer.scala
	src/main/scala/li/cil/oc/server/component/UpgradeInventoryController.scala
	src/main/scala/li/cil/oc/server/component/UpgradeSign.scala
	src/main/scala/li/cil/oc/server/component/UpgradeSolarGenerator.scala
	src/main/scala/li/cil/oc/server/component/WirelessNetworkCard.scala
This commit is contained in:
Florian Nücke 2014-09-25 13:18:04 +02:00
commit 54f5ef6df8
39 changed files with 400 additions and 135 deletions

View File

@ -75,6 +75,7 @@ configurations {
} }
dependencies { dependencies {
provided "appeng:appliedenergistics2:${config.ae2.version}:dev"
provided "codechicken:CodeChickenLib:${config.minecraft.version}-${config.ccl.version}:dev" provided "codechicken:CodeChickenLib:${config.minecraft.version}-${config.ccl.version}:dev"
provided "codechicken:ForgeMultipart:${config.minecraft.version}-${config.fmp.version}:dev" provided "codechicken:ForgeMultipart:${config.minecraft.version}-${config.fmp.version}:dev"
provided "codechicken:NotEnoughItems:${config.minecraft.version}-${config.nei.version}:dev" provided "codechicken:NotEnoughItems:${config.minecraft.version}-${config.nei.version}:dev"

View File

@ -1,11 +1,12 @@
minecraft.version=1.7.10 minecraft.version=1.7.10
forge.version=10.13.0.1180 forge.version=10.13.0.1208
oc.version=1.3.5 oc.version=1.3.5
oc.subversion=dev oc.subversion=dev
ccl.version=1.1.1.95 ccl.version=1.1.1.104
fmp.version=1.1.0.299 fmp.version=1.1.0.307
nei.version=1.0.3.51 nei.version=1.0.3.56
wrcbe.version=1.4.0.7 wrcbe.version=1.4.0.7
ae2.version=+
waila.version=1.5.4a waila.version=1.5.4a
bc.version=6.0.18 bc.version=6.0.18
ic2.version=2.2.+ ic2.version=2.2.+

View File

@ -616,6 +616,13 @@ opencomputers {
# each point of complexity. # each point of complexity.
robotAssemblyComplexity: 10000 robotAssemblyComplexity: 10000
# The base energy cost for assembling a tablet.
tabletAssemblyBase: 20000
# The additional amount of energy required to assemble a tablet for
# each point of complexity.
tabletAssemblyComplexity: 5000
# The amount of energy it takes to extract one ingredient from an # The amount of energy it takes to extract one ingredient from an
# item that is being disassembled. For example, if an item that was # item that is being disassembled. For example, if an item that was
# crafted from three other items gets disassembled, a total of 15000 # crafted from three other items gets disassembled, a total of 15000
@ -635,13 +642,14 @@ opencomputers {
# Power values for different power systems. # Power values for different power systems.
value { value {
AppliedEnergistics2: 100.0
BuildCraft: 500.0 BuildCraft: 500.0
Factorization: 6.5 Factorization: 6.5
Galacticraft: 24.0 Galacticraft: 24.0
IndustrialCraft2: 200.0 IndustrialCraft2: 200.0
Mekanism: 555.55555 Mekanism: 555.55555
RedstoneFlux: 35.0 RedstoneFlux: 35.0
UniversalElectricity: 1.0 UniversalElectricity: 1750.0
} }
} }

View File

@ -11,6 +11,11 @@ terminal {
["oc:circuitChip3", "oc:screen2", "oc:wlanCard"] ["oc:circuitChip3", "oc:screen2", "oc:wlanCard"]
[nuggetIron, "oc:keyboard", nuggetIron]] [nuggetIron, "oc:keyboard", nuggetIron]]
} }
tabletCase {
input: [[ingotGold, button, ingotGold]
["oc:componentBus1", "oc:screen2", "oc:circuitChip3"]
[ingotGold, "oc:materialCircuitBoardPrinted", ingotGold]]
}
server1 { server1 {
input: [[obsidian, "oc:ram4", obsidian] input: [[obsidian, "oc:ram4", obsidian]

View File

@ -238,10 +238,8 @@ object Items extends ItemAPI {
Recipes.addItem(new item.ComponentBus(multi, Tier.Three), "componentBus3", "oc:componentBus3") Recipes.addItem(new item.ComponentBus(multi, Tier.Three), "componentBus3", "oc:componentBus3")
registerItem(new item.DebugCard(multi), "debugCard") registerItem(new item.DebugCard(multi), "debugCard")
// 1.3.?
registerItem(new item.TabletCase(multi), "tabletCase")
// 1.3.5 // 1.3.5
Recipes.addItem(new item.TabletCase(multi), "tabletCase", "oc:tabletCase")
Recipes.addItem(new item.UpgradePiston(multi), "pistonUpgrade", "oc:pistonUpgrade") Recipes.addItem(new item.UpgradePiston(multi), "pistonUpgrade", "oc:pistonUpgrade")
} }
} }

View File

@ -161,11 +161,14 @@ class Settings(config: Config) {
val geolyzerScanCost = config.getDouble("power.cost.geolyzerScan") max 0 val geolyzerScanCost = config.getDouble("power.cost.geolyzerScan") max 0
val robotBaseCost = config.getDouble("power.cost.robotAssemblyBase") max 0 val robotBaseCost = config.getDouble("power.cost.robotAssemblyBase") max 0
val robotComplexityCost = config.getDouble("power.cost.robotAssemblyComplexity") max 0 val robotComplexityCost = config.getDouble("power.cost.robotAssemblyComplexity") max 0
val tabletBaseCost = config.getDouble("power.cost.tabletAssemblyBase") max 0
val tabletComplexityCost = config.getDouble("power.cost.tabletAssemblyComplexity") max 0
val disassemblerItemCost = config.getDouble("power.cost.disassemblerPerItem") max 0 val disassemblerItemCost = config.getDouble("power.cost.disassemblerPerItem") max 0
val chunkloaderCost = config.getDouble("power.cost.chunkloaderCost") max 0 val chunkloaderCost = config.getDouble("power.cost.chunkloaderCost") max 0
val pistonCost = config.getDouble("power.cost.pistonPush") max 0 val pistonCost = config.getDouble("power.cost.pistonPush") max 0
// power.value // power.value
private val valueAppliedEnergistics2 = config.getDouble("power.value.AppliedEnergistics2")
private val valueBuildCraft = config.getDouble("power.value.BuildCraft") private val valueBuildCraft = config.getDouble("power.value.BuildCraft")
private val valueFactorization = config.getDouble("power.value.Factorization") private val valueFactorization = config.getDouble("power.value.Factorization")
private val valueGalacticraft = config.getDouble("power.value.Galacticraft") private val valueGalacticraft = config.getDouble("power.value.Galacticraft")
@ -176,6 +179,7 @@ class Settings(config: Config) {
private val valueInternal = valueBuildCraft private val valueInternal = valueBuildCraft
val ratioAppliedEnergistics2 = valueAppliedEnergistics2 / valueInternal
val ratioBuildCraft = valueBuildCraft / valueInternal val ratioBuildCraft = valueBuildCraft / valueInternal
val ratioFactorization = valueFactorization / valueInternal val ratioFactorization = valueFactorization / valueInternal
val ratioGalacticraft = valueGalacticraft / valueInternal val ratioGalacticraft = valueGalacticraft / valueInternal

View File

@ -20,7 +20,9 @@ import net.minecraft.item.ItemStack
import net.minecraft.server.MinecraftServer import net.minecraft.server.MinecraftServer
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.event.world.WorldEvent
import universalelectricity.api.core.grid.electric.IEnergyNode
import scala.collection.mutable import scala.collection.mutable
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
@ -42,6 +44,15 @@ object EventHandler {
} }
} }
@Optional.Method(modid = Mods.IDs.UniversalElectricity)
def scheduleAE2Add(tileEntity: power.AppliedEnergistics2) {
if (SideTracker.isServer) pending.synchronized {
pending += (() => if (!tileEntity.isInvalid) {
tileEntity.getGridNode(ForgeDirection.UNKNOWN).updateState()
})
}
}
@Optional.Method(modid = Mods.IDs.IndustrialCraft2) @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
def scheduleIC2Add(tileEntity: power.IndustrialCraft2Experimental) { def scheduleIC2Add(tileEntity: power.IndustrialCraft2Experimental) {
if (SideTracker.isServer) pending.synchronized { if (SideTracker.isServer) pending.synchronized {
@ -62,6 +73,15 @@ object EventHandler {
} }
} }
@Optional.Method(modid = Mods.IDs.UniversalElectricity)
def scheduleUEAdd(tileEntity: power.UniversalElectricity) {
if (SideTracker.isServer) pending.synchronized {
pending += (() => if (!tileEntity.isInvalid) {
tileEntity.getNode(classOf[IEnergyNode], ForgeDirection.UNKNOWN).reconstruct()
})
}
}
def scheduleWirelessRedstone(rs: server.component.RedstoneWireless) { def scheduleWirelessRedstone(rs: server.component.RedstoneWireless) {
if (SideTracker.isServer) pending.synchronized { if (SideTracker.isServer) pending.synchronized {
pending += (() => if (!rs.owner.isInvalid) { pending += (() => if (!rs.owner.isInvalid) {

View File

@ -40,7 +40,7 @@ object SaveHandler {
} }
def scheduleSave(host: EnvironmentHost, nbt: NBTTagCompound, name: String, save: NBTTagCompound => Unit) { def scheduleSave(host: EnvironmentHost, nbt: NBTTagCompound, name: String, save: NBTTagCompound => Unit) {
scheduleSave(host.world, host.xPosition.toInt, host.zPosition, nbt, name, writeNBT(save)) scheduleSave(host.world, math.floor(host.xPosition).toInt, math.floor(host.zPosition).toInt, nbt, name, writeNBT(save))
} }
def scheduleSave(world: World, x: Double, z: Double, nbt: NBTTagCompound, name: String, data: Array[Byte]) { def scheduleSave(world: World, x: Double, z: Double, nbt: NBTTagCompound, name: String, data: Array[Byte]) {

View File

@ -18,14 +18,15 @@ class ClassTransformer extends IClassTransformer {
private val log = LogManager.getLogger("OpenComputers") private val log = LogManager.getLogger("OpenComputers")
private lazy val powerTypes = Map[Mod, Array[String]]( private lazy val powerTypes = Map[Mod, Array[String]](
Mods.AppliedEnergistics2 -> Array("appeng/api/networking/IGridHost"),
Mods.BuildCraftPower -> Array("buildcraft/api/power/IPowerReceptor"), Mods.BuildCraftPower -> Array("buildcraft/api/power/IPowerReceptor"),
Mods.Factorization -> Array("factorization/api/IChargeConductor"), Mods.Factorization -> Array("factorization/api/IChargeConductor"),
Mods.Galacticraft -> Array("micdoodle8/mods/galacticraft/api/power/IEnergyHandlerGC"), Mods.Galacticraft -> Array("micdoodle8/mods/galacticraft/api/power/IEnergyHandlerGC"),
Mods.IndustrialCraft2 -> Array("ic2/api/energy/tile/IEnergySink"), Mods.IndustrialCraft2 -> Array("ic2/api/energy/tile/IEnergySink"),
Mods.IndustrialCraft2Classic -> Array("ic2classic/api/energy/tile/IEnergySink"), Mods.IndustrialCraft2Classic -> Array("ic2classic/api/energy/tile/IEnergySink"),
Mods.Mekanism -> Array("mekanism/api/energy/IStrictEnergyAcceptor"), Mods.Mekanism -> Array("mekanism/api/energy/IStrictEnergyAcceptor"),
Mods.RedstoneFlux -> Array("cofh/api/energy/IEnergyHandler") Mods.RedstoneFlux -> Array("cofh/api/energy/IEnergyHandler"),
// Mods.UniversalElectricity -> Array("universalelectricity/api/core/grid/INodeProvider", "universalelectricity/api/core/grid/electric/IEnergyContainer") Mods.UniversalElectricity -> Array("universalelectricity/api/core/grid/INodeProvider")
) )
override def transform(name: String, transformedName: String, basicClass: Array[Byte]): Array[Byte] = { override def transform(name: String, transformedName: String, basicClass: Array[Byte]): Array[Byte] = {

View File

@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class Assembler extends SimpleBlock with SpecialBlock { class Assembler extends SimpleBlock with traits.SpecialBlock with traits.PowerAcceptor {
setLightLevel(0.34f) setLightLevel(0.34f)
override protected def customTextures = Array( override protected def customTextures = Array(

View File

@ -18,7 +18,7 @@ import net.minecraft.util.AxisAlignedBB
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class Cable extends SimpleBlock with SpecialBlock { class Cable extends SimpleBlock with traits.SpecialBlock {
setLightOpacity(0) setLightOpacity(0)
// For Immibis Microblock support. // For Immibis Microblock support.

View File

@ -14,7 +14,7 @@ import net.minecraft.util.IIcon
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class Case(val tier: Int) extends RedstoneAware { class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor {
private val iconsOn = new Array[IIcon](6) private val iconsOn = new Array[IIcon](6)
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //

View File

@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class Disassembler extends SimpleBlock { class Disassembler extends SimpleBlock with traits.PowerAcceptor {
override protected def customTextures = Array( override protected def customTextures = Array(
None, None,
Some("DisassemblerTop"), Some("DisassemblerTop"),

View File

@ -10,7 +10,7 @@ import net.minecraft.item.{EnumRarity, ItemStack}
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class Hologram(val tier: Int) extends SimpleBlock with SpecialBlock { class Hologram(val tier: Int) extends SimpleBlock with traits.SpecialBlock {
setLightLevel(1) setLightLevel(1)
setBlockBounds(0, 0, 0, 1, 0.5f, 1) setBlockBounds(0, 0, 0, 1, 0.5f, 1)

View File

@ -10,7 +10,7 @@ import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
class Keyboard extends SimpleBlock with SpecialBlock { class Keyboard extends SimpleBlock with traits.SpecialBlock {
setLightOpacity(0) setLightOpacity(0)
// For Immibis Microblock support. // For Immibis Microblock support.

View File

@ -11,7 +11,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.world.World import net.minecraft.world.World
class PowerConverter extends SimpleBlock { class PowerConverter extends SimpleBlock with traits.PowerAcceptor {
showInItemList = !Settings.get.ignorePower showInItemList = !Settings.get.ignorePower
private val formatter = new DecimalFormat("#.#") private val formatter = new DecimalFormat("#.#")

View File

@ -1,14 +1,13 @@
package li.cil.oc.common.block package li.cil.oc.common.block
import cpw.mods.fml.common.Optional import cpw.mods.fml.common.Optional
import li.cil.oc.common.tileentity.traits import li.cil.oc.common.tileentity
import li.cil.oc.common.tileentity.traits.BundledRedstoneAware
import li.cil.oc.util.mods.Mods import li.cil.oc.util.mods.Mods
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
import powercrystals.minefactoryreloaded.api.rednet.{IRedNetNetworkContainer, IRedNetOmniNode}
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType
import powercrystals.minefactoryreloaded.api.rednet.{IRedNetNetworkContainer, IRedNetOmniNode}
@Optional.Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet", modid = Mods.IDs.MineFactoryReloaded) @Optional.Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet", modid = Mods.IDs.MineFactoryReloaded)
abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode { abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
@ -20,7 +19,7 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
override def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = override def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case redstone: traits.RedstoneAware => redstone.isOutputEnabled case redstone: tileentity.traits.RedstoneAware => redstone.isOutputEnabled
case _ => false case _ => false
} }
@ -29,7 +28,7 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
override def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = override def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case redstone: traits.RedstoneAware => math.min(math.max(redstone.output(side), 0), 15) case redstone: tileentity.traits.RedstoneAware => math.min(math.max(redstone.output(side), 0), 15)
case _ => super.isProvidingWeakPower(world, x, y, z, side) case _ => super.isProvidingWeakPower(world, x, y, z, side)
} }
@ -38,7 +37,7 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) { override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) {
if (Mods.MineFactoryReloaded.isAvailable) { if (Mods.MineFactoryReloaded.isAvailable) {
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case t: BundledRedstoneAware => for (side <- ForgeDirection.VALID_DIRECTIONS) { case t: tileentity.traits.BundledRedstoneAware => for (side <- ForgeDirection.VALID_DIRECTIONS) {
world.getBlock(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match { world.getBlock(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match {
case block: IRedNetNetworkContainer => case block: IRedNetNetworkContainer =>
case _ => for (color <- 0 until 16) { case _ => for (color <- 0 until 16) {
@ -50,7 +49,7 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
} }
} }
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case redstone: traits.RedstoneAware => redstone.checkRedstoneInputChanged() case redstone: tileentity.traits.RedstoneAware => redstone.checkRedstoneInputChanged()
case _ => // Ignore. case _ => // Ignore.
} }
} }
@ -61,13 +60,13 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
override def getOutputValue(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, color: Int) = override def getOutputValue(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, color: Int) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case t: BundledRedstoneAware => t.bundledOutput(side, color) case t: tileentity.traits.BundledRedstoneAware => t.bundledOutput(side, color)
case _ => 0 case _ => 0
} }
override def getOutputValues(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) = override def getOutputValues(world: World, x: Int, y: Int, z: Int, side: ForgeDirection) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case t: BundledRedstoneAware => t.bundledOutput(side) case t: tileentity.traits.BundledRedstoneAware => t.bundledOutput(side)
case _ => Array.fill(16)(0) case _ => Array.fill(16)(0)
} }
@ -75,7 +74,7 @@ abstract class RedstoneAware extends SimpleBlock with IRedNetOmniNode {
override def onInputsChanged(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, inputValues: Array[Int]) = override def onInputsChanged(world: World, x: Int, y: Int, z: Int, side: ForgeDirection, inputValues: Array[Int]) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case t: BundledRedstoneAware => for (color <- 0 until 16) { case t: tileentity.traits.BundledRedstoneAware => for (color <- 0 until 16) {
t.rednetInput(side, color, inputValues(color)) t.rednetInput(side, color, inputValues(color))
} }
case _ => case _ =>

View File

@ -12,7 +12,7 @@ import net.minecraft.util.{IIcon, MovingObjectPosition}
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class RobotAfterimage extends SimpleBlock with SpecialBlock { class RobotAfterimage extends SimpleBlock with traits.SpecialBlock {
setLightOpacity(0) setLightOpacity(0)
showInItemList = false showInItemList = false

View File

@ -17,7 +17,7 @@ import net.minecraft.util.{AxisAlignedBB, IIcon, MovingObjectPosition, Vec3}
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class RobotProxy extends RedstoneAware with SpecialBlock { class RobotProxy extends RedstoneAware with traits.SpecialBlock {
setLightOpacity(0) setLightOpacity(0)
showInItemList = false showInItemList = false

View File

@ -9,7 +9,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
class ServerRack extends RedstoneAware with SpecialBlock { class ServerRack extends RedstoneAware with traits.SpecialBlock with traits.PowerAcceptor {
override protected def customTextures = Array( override protected def customTextures = Array(
None, None,
None, None,

View File

@ -0,0 +1,27 @@
package li.cil.oc.common.block.traits
import cpw.mods.fml.common.Optional
import li.cil.oc.common.tileentity.traits.power.UniversalElectricity
import li.cil.oc.util.mods.Mods
import net.minecraft.block.Block
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import universalelectricity.api.core.grid.electric.IEnergyNode
trait PowerAcceptor extends Block {
override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) {
super.onNeighborBlockChange(world, x, y, z, block)
if (Mods.UniversalElectricity.isAvailable) {
updateUENode(world.getTileEntity(x, y, z))
}
}
@Optional.Method(modid = Mods.IDs.UniversalElectricity)
private def updateUENode(tileEntity: TileEntity) {
tileEntity match {
case ue: UniversalElectricity => ue.getNode(classOf[IEnergyNode], ForgeDirection.UNKNOWN).reconstruct()
case _ =>
}
}
}

View File

@ -1,5 +1,6 @@
package li.cil.oc.common.block package li.cil.oc.common.block.traits
import li.cil.oc.common.block.SimpleBlock
import net.minecraft.world.IBlockAccess import net.minecraft.world.IBlockAccess
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection

View File

@ -423,7 +423,7 @@ object TextBuffer {
def onChunkUnload(e: ChunkEvent.Unload) { def onChunkUnload(e: ChunkEvent.Unload) {
val chunk = e.getChunk val chunk = e.getChunk
clientBuffers = clientBuffers.filter(t => { clientBuffers = clientBuffers.filter(t => {
val keep = t.host.world != e.world || !chunk.isAtLocation(math.round(t.host.xPosition - 0.5).toInt << 4, math.round(t.host.zPosition - 0.5).toInt << 4) val keep = t.host.world != e.world || !chunk.isAtLocation(math.floor(t.host.xPosition).toInt << 4, math.floor(t.host.zPosition).toInt << 4)
if (!keep) { if (!keep) {
ClientComponentTracker.remove(t.proxy.nodeAddress) ClientComponentTracker.remove(t.proxy.nodeAddress)
} }

View File

@ -59,7 +59,7 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
} }
def updateLoadedChunk(loader: UpgradeChunkloader) { def updateLoadedChunk(loader: UpgradeChunkloader) {
val robotChunk = new ChunkCoordIntPair(math.round(loader.host.xPosition - 0.5).toInt >> 4, math.round(loader.host.zPosition - 0.5).toInt >> 4) val robotChunk = new ChunkCoordIntPair(math.floor(loader.host.xPosition).toInt >> 4, math.floor(loader.host.zPosition).toInt >> 4)
loader.ticket.foreach(ticket => { loader.ticket.foreach(ticket => {
ticket.getChunkList.collect { ticket.getChunkList.collect {
case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk) case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk)

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.{Driver, Machine}
import li.cil.oc.common.inventory.ComponentInventory import li.cil.oc.common.inventory.ComponentInventory
import li.cil.oc.common.{GuiType, Slot} import li.cil.oc.common.{GuiType, Slot}
import li.cil.oc.server.component import li.cil.oc.server.component
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.ItemUtils.TabletData import li.cil.oc.util.ItemUtils.TabletData
import li.cil.oc.util.{ItemUtils, RotationHelper} import li.cil.oc.util.{ItemUtils, RotationHelper}
import li.cil.oc.{OpenComputers, Settings, api} import li.cil.oc.{OpenComputers, Settings, api}
@ -121,8 +122,8 @@ class TabletWrapper(var stack: ItemStack, var holder: EntityPlayer) extends Comp
val data = stack.getTagCompound val data = stack.getTagCompound
load(data) load(data)
if (!world.isRemote) { if (!world.isRemote) {
machine.load(data.getCompoundTag(Settings.namespace + "data"))
tablet.load(data.getCompoundTag(Settings.namespace + "component")) tablet.load(data.getCompoundTag(Settings.namespace + "component"))
machine.load(data.getCompoundTag(Settings.namespace + "data"))
} }
} }
} }
@ -136,8 +137,8 @@ class TabletWrapper(var stack: ItemStack, var holder: EntityPlayer) extends Comp
if (!data.hasKey(Settings.namespace + "data")) { if (!data.hasKey(Settings.namespace + "data")) {
data.setTag(Settings.namespace + "data", new NBTTagCompound()) data.setTag(Settings.namespace + "data", new NBTTagCompound())
} }
machine.save(data.getCompoundTag(Settings.namespace + "data")) data.setNewCompoundTag(Settings.namespace + "component", tablet.save)
tablet.save(data.getCompoundTag(Settings.namespace + "component")) data.setNewCompoundTag(Settings.namespace + "data", machine.save)
// Force tablets into stopped state to avoid errors when trying to // Force tablets into stopped state to avoid errors when trying to
// load deleted machine states. // load deleted machine states.
@ -237,13 +238,7 @@ class TabletWrapper(var stack: ItemStack, var holder: EntityPlayer) extends Comp
case _ => 0 case _ => 0
})) }))
override def maxComponents = items.foldLeft(0)((acc, itemOption) => acc + (itemOption match { override def maxComponents = 32
case Some(item) => Option(api.Driver.driverFor(item)) match {
case Some(driver: api.driver.Processor) => driver.supportedComponents(item)
case _ => 0
}
case _ => 0
}))
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address)) override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))

View File

@ -25,7 +25,7 @@ object RobotTemplate extends Template {
val data = new ItemUtils.RobotData() val data = new ItemUtils.RobotData()
data.tier = ItemUtils.caseTier(inventory.getStackInSlot(0)) data.tier = ItemUtils.caseTier(inventory.getStackInSlot(0))
data.name = ItemUtils.RobotData.randomName data.name = ItemUtils.RobotData.randomName
data.robotEnergy = 50000 data.robotEnergy = Settings.get.bufferRobot.toInt
data.totalEnergy = data.robotEnergy data.totalEnergy = data.robotEnergy
data.containers = items.slice(1, 4).filter(_ != null).toArray data.containers = items.slice(1, 4).filter(_ != null).toArray
data.components = items.drop(4).filter(_ != null).toArray data.components = items.drop(4).filter(_ != null).toArray
@ -33,7 +33,7 @@ object RobotTemplate extends Template {
data.save(stack) data.save(stack)
val energy = Settings.get.robotBaseCost + complexity(inventory) * Settings.get.robotComplexityCost val energy = Settings.get.robotBaseCost + complexity(inventory) * Settings.get.robotComplexityCost
Array(stack, energy: java.lang.Double) Array(stack, double2Double(energy))
} }
def register() { def register() {

View File

@ -1,7 +1,7 @@
package li.cil.oc.common.template package li.cil.oc.common.template
import cpw.mods.fml.common.event.FMLInterModComms import cpw.mods.fml.common.event.FMLInterModComms
import li.cil.oc.api import li.cil.oc.{Settings, api}
import li.cil.oc.common.{Slot, Tier} import li.cil.oc.common.{Slot, Tier}
import li.cil.oc.server.driver.item import li.cil.oc.server.driver.item
import li.cil.oc.util.ExtendedNBT._ import li.cil.oc.util.ExtendedNBT._
@ -23,22 +23,24 @@ object TabletTemplate extends Template {
def validateUpgrade(inventory: IInventory, slot: Int, tier: Int, stack: ItemStack): Boolean = Option(api.Driver.driverFor(stack)) match { def validateUpgrade(inventory: IInventory, slot: Int, tier: Int, stack: ItemStack): Boolean = Option(api.Driver.driverFor(stack)) match {
case Some(driver) if driver.slot(stack) == Slot.Upgrade => case Some(driver) if driver.slot(stack) == Slot.Upgrade =>
driver != item.Keyboard && driver != item.Screen && driver != item.Screen &&
driver.slot(stack) == Slot.Upgrade && driver.tier(stack) <= tier driver.slot(stack) == Slot.Upgrade && driver.tier(stack) <= tier
case _ => false case _ => false
} }
def assemble(inventory: IInventory): Array[AnyRef] = { def assemble(inventory: IInventory): Array[AnyRef] = {
val items = mutable.ArrayBuffer( val items = mutable.ArrayBuffer(
Option(api.Items.get("screen1").createItemStack(1)), Option(api.Items.get("screen1").createItemStack(1))
Option(api.Items.get("keyboard").createItemStack(1))
) ++ (1 until inventory.getSizeInventory).map(slot => Option(inventory.getStackInSlot(slot))) ) ++ (1 until inventory.getSizeInventory).map(slot => Option(inventory.getStackInSlot(slot)))
val data = new ItemUtils.TabletData() val data = new ItemUtils.TabletData()
data.items = items.filter(_.isDefined).toArray data.items = items.filter(_.isDefined).toArray
data.energy = Settings.get.bufferTablet
data.maxEnergy = data.energy
val stack = api.Items.get("tablet").createItemStack(1) val stack = api.Items.get("tablet").createItemStack(1)
data.save(stack) data.save(stack)
val energy = Settings.get.tabletBaseCost + complexity(inventory) * Settings.get.tabletComplexityCost
Array(stack) Array(stack, double2Double(energy))
} }
def register() { def register() {

View File

@ -83,6 +83,7 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
else if (api.Items.get(stack) == api.Items.get("server1")) enqueueServer(stack, 0) else if (api.Items.get(stack) == api.Items.get("server1")) enqueueServer(stack, 0)
else if (api.Items.get(stack) == api.Items.get("server2")) enqueueServer(stack, 1) else if (api.Items.get(stack) == api.Items.get("server2")) enqueueServer(stack, 1)
else if (api.Items.get(stack) == api.Items.get("server3")) enqueueServer(stack, 2) else if (api.Items.get(stack) == api.Items.get("server3")) enqueueServer(stack, 2)
else if (api.Items.get(stack) == api.Items.get("tablet")) enqueueTablet(stack)
else if (api.Items.get(stack) == api.Items.get("navigationUpgrade")) { else if (api.Items.get(stack) == api.Items.get("navigationUpgrade")) {
enqueueNavigationUpgrade(stack) enqueueNavigationUpgrade(stack)
} }
@ -115,6 +116,15 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
queue ++= getIngredients(server) queue ++= getIngredients(server)
} }
private def enqueueTablet(tablet: ItemStack) {
val info = new ItemUtils.TabletData(tablet)
queue += api.Items.get("tabletCase").createItemStack(1)
queue ++= info.items.collect {
case Some(stack) => stack
}.drop(1) // Screen.
node.changeBuffer(info.energy)
}
private def enqueueNavigationUpgrade(stack: ItemStack) { private def enqueueNavigationUpgrade(stack: ItemStack) {
val info = new ItemUtils.NavigationUpgradeData(stack) val info = new ItemUtils.NavigationUpgradeData(stack)
val parts = getIngredients(stack) val parts = getIngredients(stack)
@ -224,5 +234,6 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
override def isItemValidForSlot(i: Int, stack: ItemStack) = override def isItemValidForSlot(i: Int, stack: ItemStack) =
api.Items.get(stack) == api.Items.get("robot") || api.Items.get(stack) == api.Items.get("robot") ||
((Settings.get.disassembleAllTheThings || api.Items.get(stack) != null) && !getIngredients(stack).isEmpty) api.Items.get(stack) == api.Items.get("tablet") ||
((Settings.get.disassembleAllTheThings || api.Items.get(stack) != null) && getIngredients(stack).nonEmpty)
} }

View File

@ -2,6 +2,7 @@ package li.cil.oc.common.tileentity.traits
trait PowerAcceptor trait PowerAcceptor
extends power.Common extends power.Common
with power.AppliedEnergistics2
with power.BuildCraft with power.BuildCraft
with power.Factorization with power.Factorization
with power.Galacticraft with power.Galacticraft
@ -9,4 +10,4 @@ trait PowerAcceptor
with power.IndustrialCraft2Classic with power.IndustrialCraft2Classic
with power.Mekanism with power.Mekanism
with power.RedstoneFlux with power.RedstoneFlux
// with power.UniversalElectricity with power.UniversalElectricity

View File

@ -0,0 +1,128 @@
package li.cil.oc.common.tileentity.traits.power
import java.util
import appeng.api.AEApi
import appeng.api.config.{Actionable, PowerMultiplier}
import appeng.api.networking._
import appeng.api.networking.energy.IEnergyGrid
import appeng.api.util.{AECableType, AEColor, DimensionalCoord}
import cpw.mods.fml.common.Optional
import li.cil.oc.Settings
import li.cil.oc.common.EventHandler
import li.cil.oc.util.mods.Mods
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import scala.collection.convert.WrapAsJava._
trait AppliedEnergistics2 extends Common {
private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
// 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
private var node: Option[AnyRef] = None
override def updateEntity() {
super.updateEntity()
if (useAppliedEnergistics2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
updateEnergy()
}
}
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
private def updateEnergy() {
val grid = getGridNode(ForgeDirection.UNKNOWN).getGrid
if (grid != null) {
val cache = grid.getCache(classOf[IEnergyGrid]).asInstanceOf[IEnergyGrid]
if (cache != null) {
for (side <- ForgeDirection.VALID_DIRECTIONS) {
val demand = (globalBufferSize(side) - globalBuffer(side)) / Settings.get.ratioAppliedEnergistics2
if (demand > 1) {
val power = cache.extractAEPower(demand, Actionable.MODULATE, PowerMultiplier.CONFIG)
tryChangeBuffer(side, power * Settings.get.ratioAppliedEnergistics2)
}
}
}
}
}
override def validate() {
super.validate()
if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
}
override def invalidate() {
super.invalidate()
if (useAppliedEnergistics2Power) securityBreak()
}
override def onChunkUnload() {
super.onChunkUnload()
if (useAppliedEnergistics2Power) securityBreak()
}
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
if (useAppliedEnergistics2Power) loadNode(nbt)
}
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
private def loadNode(nbt: NBTTagCompound): Unit = {
getGridNode(ForgeDirection.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
if (useAppliedEnergistics2Power) saveNode(nbt)
}
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
private def saveNode(nbt: NBTTagCompound): Unit = {
getGridNode(ForgeDirection.UNKNOWN).saveToNBT(Settings.namespace + "ae2power", nbt)
}
// ----------------------------------------------------------------------- //
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
def getGridNode(side: ForgeDirection) = node match {
case Some(gridNode: IGridNode) => gridNode
case _ =>
val gridNode = AEApi.instance.createGridNode(new AppliedEnergistics2GridBlock(this))
node = Option(gridNode)
gridNode
}
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
def getCableConnectionType(side: ForgeDirection) = AECableType.SMART
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
def securityBreak() {
getGridNode(ForgeDirection.UNKNOWN).destroy()
}
}
class AppliedEnergistics2GridBlock(val tileEntity: AppliedEnergistics2) extends IGridBlock {
override def getIdlePowerUsage = 0.0
override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
override def isWorldAccessable = true
override def getLocation = new DimensionalCoord(tileEntity)
override def getGridColor = AEColor.Transparent
override def onGridNotification(p1: GridNotification) {}
override def setNetworkStatus(p1: IGrid, p2: Int) {}
override def getConnectableSides = util.EnumSet.copyOf(ForgeDirection.VALID_DIRECTIONS.filter(tileEntity.canConnectPower).toList)
override def getMachine = tileEntity.asInstanceOf[IGridHost]
override def gridChanged() {}
override def getMachineRepresentation = null
}

View File

@ -2,8 +2,10 @@ package li.cil.oc.common.tileentity.traits.power
import buildcraft.api.power.{IPowerReceptor, PowerHandler} import buildcraft.api.power.{IPowerReceptor, PowerHandler}
import cpw.mods.fml.common.Optional import cpw.mods.fml.common.Optional
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.mods.Mods import li.cil.oc.util.mods.Mods
import li.cil.oc.{OpenComputers, Settings} import li.cil.oc.{OpenComputers, Settings}
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
trait BuildCraft extends Common { trait BuildCraft extends Common {
@ -16,6 +18,12 @@ trait BuildCraft extends Common {
override def updateEntity() { override def updateEntity() {
super.updateEntity() super.updateEntity()
if (useBuildCraftPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) { if (useBuildCraftPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
updateEnergy()
}
}
@Optional.Method(modid = Mods.IDs.BuildCraftPower)
private def updateEnergy() {
for (side <- ForgeDirection.VALID_DIRECTIONS) { for (side <- ForgeDirection.VALID_DIRECTIONS) {
val demand = (globalBufferSize(side) - globalBuffer(side)) / Settings.get.ratioBuildCraft val demand = (globalBufferSize(side) - globalBuffer(side)) / Settings.get.ratioBuildCraft
if (demand > 1) { if (demand > 1) {
@ -24,6 +32,27 @@ trait BuildCraft extends Common {
} }
} }
} }
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
if (useBuildCraftPower) loadHandler(nbt)
}
@Optional.Method(modid = Mods.IDs.BuildCraftPower)
private def loadHandler(nbt: NBTTagCompound): Unit = {
Option(getPowerProvider).foreach(_.readFromNBT(nbt.getCompoundTag(Settings.namespace + "bcpower")))
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
if (useBuildCraftPower) saveHandler(nbt)
}
@Optional.Method(modid = Mods.IDs.BuildCraftPower)
private def saveHandler(nbt: NBTTagCompound): Unit = {
Option(getPowerProvider).foreach(h => nbt.setNewCompoundTag(Settings.namespace + "bcpower", h.writeToNBT))
} }
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //

View File

@ -1,52 +1,77 @@
//package li.cil.oc.common.tileentity.traits.power package li.cil.oc.common.tileentity.traits.power
//
//import cpw.mods.fml.common.Optional import cpw.mods.fml.common.Optional
//import li.cil.oc.Settings import li.cil.oc.{OpenComputers, Settings}
//import li.cil.oc.util.mods.Mods import li.cil.oc.common.EventHandler
//import net.minecraftforge.common.util.ForgeDirection import li.cil.oc.util.mods.Mods
//import universalelectricity.api.core.grid.electric.{IElectricNode, IEnergyContainer} import net.minecraftforge.common.util.ForgeDirection
//import universalelectricity.api.core.grid.{INode, INodeProvider} import universalelectricity.api.core.grid.electric.IEnergyNode
// import universalelectricity.api.core.grid.{INode, INodeProvider}
//@Optional.InterfaceList(Array( import universalelectricity.core.grid.node.NodeEnergy
// new Optional.Interface(iface = "universalelectricity.api.core.grid.INodeProvider", modid = Mods.IDs.UniversalElectricity),
// new Optional.Interface(iface = "universalelectricity.api.core.grid.electric.IEnergyContainer", modid = Mods.IDs.UniversalElectricity) trait UniversalElectricity extends Common {
//)) private var node: Option[AnyRef] = None
//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 && Mods.UniversalElectricity.isAvailable
//
// private lazy val useUniversalElectricityPower = isServer && !Settings.get.ignorePower && Mods.BuildCraftPower.isAvailable // ----------------------------------------------------------------------- //
//
// // ----------------------------------------------------------------------- // override def updateEntity() {
// super.updateEntity()
// override def updateEntity() { if (useUniversalElectricityPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
// super.updateEntity() updateEnergy()
// 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.ratioUniversalElectricity @Optional.Method(modid = Mods.IDs.UniversalElectricity)
// val power = math.min(demand, electric.getEnergy) private def updateEnergy() {
// if (power > 1) { node match {
// electric.removeEnergy(power, true) case Some(energyNode: NodeEnergy) =>
// tryChangeBuffer(side, power * Settings.ratioUniversalElectricity) for (side <- ForgeDirection.VALID_DIRECTIONS) {
// } val demand = (globalBufferSize(side) - globalBuffer(side)) / Settings.get.ratioUniversalElectricity
// } if (demand > 1) {
// } val power = energyNode.buffer.extractEnergy(demand, doExtract = true)
// } tryChangeBuffer(side, power * Settings.get.ratioUniversalElectricity)
// }
// // ----------------------------------------------------------------------- // }
// case _ =>
// @Optional.Method(modid = Mods.IDs.UniversalElectricity) }
// 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 = Mods.IDs.UniversalElectricity)
// @Optional.Method(modid = Mods.IDs.UniversalElectricity) def getNode(nodeType: Class[_ <: INode], side: ForgeDirection): INode = {
// override def setEnergy(from: ForgeDirection, energy: Double) {} if (nodeType != null && classOf[IEnergyNode].isAssignableFrom(nodeType)) node match {
// case Some(energyNode: NodeEnergy) => energyNode
// @Optional.Method(modid = Mods.IDs.UniversalElectricity) case _ =>
// override def getEnergy(from: ForgeDirection) = globalBuffer(from) / Settings.ratioUniversalElectricity this match {
// case nodeProvider: INodeProvider =>
// @Optional.Method(modid = Mods.IDs.UniversalElectricity) val energyNode = new NodeEnergy(nodeProvider, 500, 500, 500) {
// override def getEnergyCapacity(from: ForgeDirection) = globalBufferSize(from) / Settings.ratioUniversalElectricity override def canConnect(from: ForgeDirection) = canConnectPower(from) && super.canConnect(from)
//} }
node = Option(energyNode)
energyNode
case _ =>
OpenComputers.log.warn("Failed setting up UniversalElectricity power, which most likely means the class transformer did not run. You're probably running in an incorrectly configured development environment. Try adding `-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader` to the VM options of your run configuration.")
null
}
}
else null
}
override def validate() {
super.validate()
if (useUniversalElectricityPower) EventHandler.scheduleUEAdd(this)
}
override def invalidate() {
super.invalidate()
if (useUniversalElectricityPower) deconstructNode()
}
@Optional.Method(modid = Mods.IDs.UniversalElectricity)
private def deconstructNode() {
getNode(classOf[IEnergyNode], ForgeDirection.UNKNOWN).deconstruct()
}
}

View File

@ -22,7 +22,7 @@ class Geolyzer(val host: EnvironmentHost) extends component.ManagedComponent {
if (math.abs(rx) > Settings.get.geolyzerRange || math.abs(rz) > Settings.get.geolyzerRange) { if (math.abs(rx) > Settings.get.geolyzerRange || math.abs(rz) > Settings.get.geolyzerRange) {
throw new IllegalArgumentException("location out of bounds") throw new IllegalArgumentException("location out of bounds")
} }
val (x, y, z) = ((host.xPosition - 0.5).toInt, (host.yPosition - 0.5).toInt, (host.zPosition - 0.5).toInt) val (x, y, z) = (math.floor(host.xPosition).toInt, math.floor(host.yPosition).toInt, math.floor(host.zPosition).toInt)
val bx = x + rx val bx = x + rx
val bz = z + rz val bz = z + rz

View File

@ -23,7 +23,7 @@ class UpgradeInventoryController(val host: EnvironmentHost with Robot) extends c
def getInventorySize(context: Context, args: Arguments): Array[AnyRef] = { def getInventorySize(context: Context, args: Arguments): Array[AnyRef] = {
val facing = checkSideForInventory(args, 0) val facing = checkSideForInventory(args, 0)
if (facing == host.facing.getOpposite) result(host.inventorySize) if (facing == host.facing.getOpposite) result(host.inventorySize)
else InventoryUtils.inventoryAt(host.world, math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) match { else InventoryUtils.inventoryAt(host.world, math.floor(host.xPosition).toInt + facing.offsetX, math.floor(host.yPosition).toInt + facing.offsetY, math.floor(host.zPosition).toInt + facing.offsetZ) match {
case Some(inventory) => result(inventory.getSizeInventory) case Some(inventory) => result(inventory.getSizeInventory)
case _ => result(Unit, "no inventory") case _ => result(Unit, "no inventory")
} }
@ -37,7 +37,7 @@ class UpgradeInventoryController(val host: EnvironmentHost with Robot) extends c
if (slot < 0 || slot >= host.inventorySize) result(Unit) if (slot < 0 || slot >= host.inventorySize) result(Unit)
else result(host.getStackInSlot(slot + 1 + host.containerCount)) else result(host.getStackInSlot(slot + 1 + host.containerCount))
} }
else InventoryUtils.inventoryAt(host.world, math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) match { else InventoryUtils.inventoryAt(host.world, math.floor(host.xPosition).toInt + facing.offsetX, math.floor(host.yPosition).toInt + facing.offsetY, math.floor(host.zPosition).toInt + facing.offsetZ) match {
case Some(inventory) => case Some(inventory) =>
if (slot < 0 || slot > inventory.getSizeInventory) result(Unit) if (slot < 0 || slot > inventory.getSizeInventory) result(Unit)
else result(inventory.getStackInSlot(slot)) else result(inventory.getStackInSlot(slot))
@ -52,7 +52,7 @@ class UpgradeInventoryController(val host: EnvironmentHost with Robot) extends c
val selectedSlot = host.selectedSlot val selectedSlot = host.selectedSlot
val stack = host.getStackInSlot(selectedSlot) val stack = host.getStackInSlot(selectedSlot)
if (stack != null && stack.stackSize > 0) { if (stack != null && stack.stackSize > 0) {
InventoryUtils.inventoryAt(host.world, math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) match { InventoryUtils.inventoryAt(host.world, math.floor(host.xPosition).toInt + facing.offsetX, math.floor(host.yPosition).toInt + facing.offsetY, math.floor(host.zPosition).toInt + facing.offsetZ) match {
case Some(inventory) if inventory.isUseableByPlayer(host.player) => case Some(inventory) if inventory.isUseableByPlayer(host.player) =>
val slot = args.checkSlot(inventory, 1) val slot = args.checkSlot(inventory, 1)
if (!InventoryUtils.insertIntoInventorySlot(stack, inventory, facing.getOpposite, slot, count)) { if (!InventoryUtils.insertIntoInventorySlot(stack, inventory, facing.getOpposite, slot, count)) {
@ -82,7 +82,7 @@ class UpgradeInventoryController(val host: EnvironmentHost with Robot) extends c
val facing = checkSideForAction(args, 0) val facing = checkSideForAction(args, 0)
val count = args.optionalItemCount(2) val count = args.optionalItemCount(2)
InventoryUtils.inventoryAt(host.world, math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) match { InventoryUtils.inventoryAt(host.world, math.floor(host.xPosition).toInt + facing.offsetX, math.floor(host.yPosition).toInt + facing.offsetY, math.floor(host.zPosition).toInt + facing.offsetZ) match {
case Some(inventory) if inventory.isUseableByPlayer(host.player) => case Some(inventory) if inventory.isUseableByPlayer(host.player) =>
val slot = args.checkSlot(inventory, 1) val slot = args.checkSlot(inventory, 1)
if (InventoryUtils.extractFromInventorySlot(host.player.inventory.addItemStackToInventory, inventory, facing.getOpposite, slot, count)) { if (InventoryUtils.extractFromInventorySlot(host.player.inventory.addItemStackToInventory, inventory, facing.getOpposite, slot, count)) {

View File

@ -18,9 +18,8 @@ class UpgradeSign(val host: EnvironmentHost with Rotatable) extends component.Ma
@Callback(doc = """function():string -- Get the text on the sign in front of the robot.""") @Callback(doc = """function():string -- Get the text on the sign in front of the robot.""")
def getValue(context: Context, args: Arguments): Array[AnyRef] = { def getValue(context: Context, args: Arguments): Array[AnyRef] = {
val facing = host.facing findSign match {
host.world.getTileEntity(math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) match { case Some(sign) => result(sign.signText.mkString("\n"))
case sign: TileEntitySign => result(sign.signText.mkString("\n"))
case _ => result(Unit, "no sign") case _ => result(Unit, "no sign")
} }
} }
@ -28,14 +27,23 @@ class UpgradeSign(val host: EnvironmentHost with Rotatable) extends component.Ma
@Callback(doc = """function(value:string):string -- Set the text on the sign in front of the robot.""") @Callback(doc = """function(value:string):string -- Set the text on the sign in front of the robot.""")
def setValue(context: Context, args: Arguments): Array[AnyRef] = { def setValue(context: Context, args: Arguments): Array[AnyRef] = {
val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line) val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line)
val facing = host.facing findSign match {
val (sx, sy, sz) = (math.round(host.xPosition - 0.5).toInt + facing.offsetX, math.round(host.yPosition - 0.5).toInt + facing.offsetY, math.round(host.zPosition - 0.5).toInt + facing.offsetZ) case Some(sign) =>
host.world.getTileEntity(sx, sy, sz) match {
case sign: TileEntitySign =>
text.copyToArray(sign.signText) text.copyToArray(sign.signText)
host.world.markBlockForUpdate(sx, sy, sz) host.world.markBlockForUpdate(sign.xCoord, sign.yCoord, sign.zCoord)
result(sign.signText.mkString("\n")) result(sign.signText.mkString("\n"))
case _ => result(Unit, "no sign") case _ => result(Unit, "no sign")
} }
} }
private def findSign = {
val (x, y, z) = (math.floor(host.xPosition).toInt, math.floor(host.yPosition).toInt, math.floor(host.zPosition).toInt)
host.world.getTileEntity(x, y, z) match {
case sign: TileEntitySign => Option(sign)
case _ => host.world.getTileEntity(x + host.facing.offsetX, y + host.facing.offsetY, z + host.facing.offsetZ) match {
case sign: TileEntitySign => Option(sign)
case _ => None
}
}
}
} }

View File

@ -27,7 +27,7 @@ class UpgradeSolarGenerator(val host: EnvironmentHost) extends component.Managed
ticksUntilCheck -= 1 ticksUntilCheck -= 1
if (ticksUntilCheck <= 0) { if (ticksUntilCheck <= 0) {
ticksUntilCheck = 100 ticksUntilCheck = 100
isSunShining = isSunVisible(host.world, math.round(host.xPosition - 0.5).toInt, math.round(host.yPosition - 0.5).toInt + 1, math.round(host.zPosition - 0.5).toInt) isSunShining = isSunVisible(host.world, math.floor(host.xPosition).toInt, math.floor(host.yPosition).toInt + 1, math.floor(host.zPosition).toInt)
} }
if (isSunShining) { if (isSunShining) {
node.changeBuffer(Settings.get.solarGeneratorEfficiency) node.changeBuffer(Settings.get.solarGeneratorEfficiency)

View File

@ -21,11 +21,11 @@ class WirelessNetworkCard(val host: EnvironmentHost) extends NetworkCard with Wi
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
override def x = math.round(host.xPosition - 0.5).toInt override def x = math.floor(host.xPosition).toInt
override def y = math.round(host.yPosition - 0.5).toInt override def y = math.floor(host.yPosition).toInt
override def z = math.round(host.zPosition - 0.5).toInt override def z = math.floor(host.zPosition).toInt
override def world = host.world override def world = host.world

View File

@ -9,6 +9,7 @@ import scala.collection.mutable
object Mods { object Mods {
object IDs { object IDs {
final val AppliedEnergistics2 = "appliedenergistics2"
final val BattleGear2 = "battlegear2" final val BattleGear2 = "battlegear2"
final val BuildCraftPower = "BuildCraftAPI|power" final val BuildCraftPower = "BuildCraftAPI|power"
final val ComputerCraft = "ComputerCraft" final val ComputerCraft = "ComputerCraft"
@ -41,6 +42,7 @@ object Mods {
lazy val isPowerProvidingModPresent = knownMods.exists(mod => mod.providesPower && mod.isAvailable) lazy val isPowerProvidingModPresent = knownMods.exists(mod => mod.providesPower && mod.isAvailable)
val AppliedEnergistics2 = new SimpleMod(IDs.AppliedEnergistics2)
val BattleGear2 = new SimpleMod(IDs.BattleGear2) val BattleGear2 = new SimpleMod(IDs.BattleGear2)
val BuildCraftPower = new SimpleMod(IDs.BuildCraftPower, providesPower = true) val BuildCraftPower = new SimpleMod(IDs.BuildCraftPower, providesPower = true)
val ComputerCraft = new SimpleMod(IDs.ComputerCraft) val ComputerCraft = new SimpleMod(IDs.ComputerCraft)
@ -72,7 +74,7 @@ object Mods {
} }
val ThermalExpansion = new SimpleMod(IDs.ThermalExpansion, providesPower = true) val ThermalExpansion = new SimpleMod(IDs.ThermalExpansion, providesPower = true)
val TinkersConstruct = new SimpleMod(IDs.TinkersConstruct) val TinkersConstruct = new SimpleMod(IDs.TinkersConstruct)
val UniversalElectricity = new SimpleMod(IDs.UniversalElectricity + "@[3.1,)", providesPower = true) val UniversalElectricity = new SimpleMod(IDs.UniversalElectricity, providesPower = true)
val VersionChecker = new SimpleMod(IDs.VersionChecker) val VersionChecker = new SimpleMod(IDs.VersionChecker)
val Waila = new SimpleMod(IDs.Waila) val Waila = new SimpleMod(IDs.Waila)
val WirelessRedstoneCBE = new SimpleMod(IDs.WirelessRedstoneCBE) val WirelessRedstoneCBE = new SimpleMod(IDs.WirelessRedstoneCBE)

View File

@ -1,14 +1,13 @@
package li.cil.oc.util.mods package li.cil.oc.util.mods
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraftforge.common.util.ForgeDirection
// TODO Upgrade to UE 1.7 once it's available. import universalelectricity.compatibility.Compatibility
//import universalelectricity.api.CompatibilityModule
object UniversalElectricity { object UniversalElectricity {
def isEnergyItem(stack: ItemStack) = false // CompatibilityModule.isHandler(stack.getItem) def isEnergyItem(stack: ItemStack) = Compatibility.isHandler(stack.getItem, ForgeDirection.UNKNOWN)
def getEnergyInItem(stack: ItemStack) = 0 // CompatibilityModule.getEnergyItem(stack) def getEnergyInItem(stack: ItemStack) = Compatibility.getEnergyItem(stack)
def chargeItem(stack: ItemStack, value: Long): Unit = {} // CompatibilityModule.chargeItem(stack, value, true) def chargeItem(stack: ItemStack, value: Double) = Compatibility.chargeItem(stack, value, true)
} }