mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Merge branch '1.2' into servers
Conflicts: li/cil/oc/common/tileentity/Computer.scala
This commit is contained in:
commit
f0a900a014
@ -4,14 +4,26 @@ import cpw.mods.fml.common.{Loader, Optional}
|
|||||||
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
||||||
import li.cil.oc.api.network.Node
|
import li.cil.oc.api.network.Node
|
||||||
import li.cil.oc.server.{PacketSender => ServerPacketSender, component}
|
import li.cil.oc.server.{PacketSender => ServerPacketSender, component}
|
||||||
|
import li.cil.oc.util.mods.StargateTech2
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraftforge.common.MinecraftForge
|
|
||||||
import stargatetech2.api.StargateTechAPI
|
import stargatetech2.api.StargateTechAPI
|
||||||
import stargatetech2.api.bus.{BusEvent, IBusDevice}
|
import stargatetech2.api.bus.{IBusInterface, IBusDevice}
|
||||||
|
|
||||||
@Optional.Interface(iface = "stargatetech2.api.bus.IBusDevice", modid = "StargateTech2")
|
// IMPORTANT: for some reason that is beyond me we cannot implement the
|
||||||
trait AbstractBusAware extends TileEntity with ComponentInventory with IBusDevice {
|
// IBusDevice here directly, since we'll get an error if the interface is not
|
||||||
|
// provided (i.e. if SGT2 isn't installed), even if we tell FML to strip it.
|
||||||
|
// Assuming FML properly strips the interface (and it looks like it does, when
|
||||||
|
// inspecting it in the debugger, i.e. getInterfaces() doesn't contain it), it
|
||||||
|
// probably is something derping up in the class loader... the thing that
|
||||||
|
// confuses me the most, though, is that it apparently works for redstone and
|
||||||
|
// the CC interface, so... yeah. I'm out of ideas.
|
||||||
|
trait AbstractBusAware extends TileEntity with ComponentInventory { self: IBusDevice =>
|
||||||
|
protected var _isAbstractBusAvailable: Boolean = _
|
||||||
|
|
||||||
|
protected lazy val fakeInterface = Array[AnyRef](StargateTechAPI.api.getFactory.getIBusInterface(this, null))
|
||||||
|
|
||||||
|
@Optional.Method(modid = "StargateTech2")
|
||||||
def getInterfaces(side: Int) =
|
def getInterfaces(side: Int) =
|
||||||
if (isAbstractBusAvailable) {
|
if (isAbstractBusAvailable) {
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
@ -19,14 +31,10 @@ trait AbstractBusAware extends TileEntity with ComponentInventory with IBusDevic
|
|||||||
case Some(abstractBus: component.AbstractBus) => abstractBus.busInterface
|
case Some(abstractBus: component.AbstractBus) => abstractBus.busInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else fakeInterface
|
else fakeInterface.map(_.asInstanceOf[IBusInterface])
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
|
|
||||||
protected var _isAbstractBusAvailable = false
|
|
||||||
|
|
||||||
private lazy val fakeInterface = Array(StargateTechAPI.api.getFactory.getIBusInterface(this, null))
|
|
||||||
|
|
||||||
def getWorld = world
|
def getWorld = world
|
||||||
|
|
||||||
def getXCoord = x
|
def getXCoord = x
|
||||||
@ -84,22 +92,24 @@ trait AbstractBusAware extends TileEntity with ComponentInventory with IBusDevic
|
|||||||
removeAbstractBus()
|
removeAbstractBus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMPORTANT: all the Loader.isModLoaded checks are there to a void class
|
||||||
|
// not found errors! Also, don't try to move them further down in the logic
|
||||||
|
// (e.g. into StargateTech2) since that would not help avoid the error anymore.
|
||||||
|
|
||||||
protected def addAbstractBus() {
|
protected def addAbstractBus() {
|
||||||
// Mod loaded check to avoid class not found errors.
|
|
||||||
if (isServer && Loader.isModLoaded("StargateTech2")) {
|
if (isServer && Loader.isModLoaded("StargateTech2")) {
|
||||||
MinecraftForge.EVENT_BUS.post(new BusEvent.AddToNetwork(world, x, y, z))
|
StargateTech2.addDevice(world, x, y, z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def removeAbstractBus() {
|
protected def removeAbstractBus() {
|
||||||
// Mod loaded check to avoid class not found errors.
|
|
||||||
if (isServer && Loader.isModLoaded("StargateTech2")) {
|
if (isServer && Loader.isModLoaded("StargateTech2")) {
|
||||||
MinecraftForge.EVENT_BUS.post(new BusEvent.RemoveFromNetwork(world, x, y, z))
|
StargateTech2.removeDevice(world, x, y, z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def hasAbstractBusCard = components exists {
|
protected def hasAbstractBusCard = Loader.isModLoaded("StargateTech2") && (components exists {
|
||||||
case Some(_: component.AbstractBus) => true
|
case Some(_: component.AbstractBus) => true
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package li.cil.oc.common.tileentity
|
package li.cil.oc.common.tileentity
|
||||||
|
|
||||||
import cpw.mods.fml.common.Optional.Interface
|
|
||||||
import cpw.mods.fml.common.{Optional, Loader}
|
import cpw.mods.fml.common.{Optional, Loader}
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
@ -13,9 +12,9 @@ import powercrystals.minefactoryreloaded.api.rednet.IRedNetNetworkContainer
|
|||||||
import scala.Array
|
import scala.Array
|
||||||
|
|
||||||
@Optional.InterfaceList(Array(
|
@Optional.InterfaceList(Array(
|
||||||
new Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledEmitter", modid = "RedLogic"),
|
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledEmitter", modid = "RedLogic"),
|
||||||
new Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledUpdatable", modid = "RedLogic"),
|
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IBundledUpdatable", modid = "RedLogic"),
|
||||||
new Interface(iface = "mrtjp.projectred.api.IBundledTile", modid = "ProjRed|Transmission")
|
new Optional.Interface(iface = "mrtjp.projectred.api.IBundledTile", modid = "ProjRed|Transmission")
|
||||||
))
|
))
|
||||||
trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBundledUpdatable with IBundledTile {
|
trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBundledUpdatable with IBundledTile {
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package li.cil.oc.common.tileentity
|
package li.cil.oc.common.tileentity
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional
|
||||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api.network._
|
import li.cil.oc.api.network._
|
||||||
@ -10,8 +11,11 @@ import net.minecraft.nbt.{NBTTagString, NBTTagCompound}
|
|||||||
import net.minecraftforge.common.ForgeDirection
|
import net.minecraftforge.common.ForgeDirection
|
||||||
import scala.Some
|
import scala.Some
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
import stargatetech2.api.bus.IBusDevice
|
||||||
|
|
||||||
abstract class Computer(isRemote: Boolean) extends Environment with ComponentInventory with Rotatable with BundledRedstoneAware with AbstractBusAware with Analyzable with Context with component.Computer.Owner {
|
// See AbstractBusAware as to why we have to define the IBusDevice here.
|
||||||
|
@Optional.Interface(iface = "stargatetech2.api.bus.IBusDevice", modid = "StargateTech2")
|
||||||
|
abstract class Computer(isRemote: Boolean) extends Environment with ComponentInventory with Rotatable with BundledRedstoneAware with AbstractBusAware with IBusDevice with Analyzable with Context with component.Computer.Owner {
|
||||||
protected val _computer = if (isRemote) null else new component.Computer(this)
|
protected val _computer = if (isRemote) null else new component.Computer(this)
|
||||||
|
|
||||||
def computer = _computer
|
def computer = _computer
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package li.cil.oc.common.tileentity
|
package li.cil.oc.common.tileentity
|
||||||
|
|
||||||
import cpw.mods.fml.common.Optional.Interface
|
|
||||||
import cpw.mods.fml.common.{Loader, Optional}
|
import cpw.mods.fml.common.{Loader, Optional}
|
||||||
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
@ -13,9 +12,9 @@ import net.minecraft.nbt.NBTTagCompound
|
|||||||
import net.minecraftforge.common.ForgeDirection
|
import net.minecraftforge.common.ForgeDirection
|
||||||
|
|
||||||
@Optional.InterfaceList(Array(
|
@Optional.InterfaceList(Array(
|
||||||
new Interface(iface = "mods.immibis.redlogic.api.wiring.IConnectable", modid = "RedLogic"),
|
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IConnectable", modid = "RedLogic"),
|
||||||
new Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneEmitter", modid = "RedLogic"),
|
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneEmitter", modid = "RedLogic"),
|
||||||
new Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneUpdatable", modid = "RedLogic")
|
new Optional.Interface(iface = "mods.immibis.redlogic.api.wiring.IRedstoneUpdatable", modid = "RedLogic")
|
||||||
))
|
))
|
||||||
trait RedstoneAware extends RotationAware with network.Environment with Persistable with IConnectable with IRedstoneEmitter with IRedstoneUpdatable {
|
trait RedstoneAware extends RotationAware with network.Environment with Persistable with IConnectable with IRedstoneEmitter with IRedstoneUpdatable {
|
||||||
protected val _input = Array.fill(6)(-1)
|
protected val _input = Array.fill(6)(-1)
|
||||||
|
11
li/cil/oc/util/mods/StargateTech2.scala
Normal file
11
li/cil/oc/util/mods/StargateTech2.scala
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package li.cil.oc.util.mods
|
||||||
|
|
||||||
|
import net.minecraft.world.World
|
||||||
|
import net.minecraftforge.common.MinecraftForge
|
||||||
|
import stargatetech2.api.bus.BusEvent.{RemoveFromNetwork, AddToNetwork}
|
||||||
|
|
||||||
|
object StargateTech2 {
|
||||||
|
def addDevice(world: World, x: Int, y: Int, z: Int) = MinecraftForge.EVENT_BUS.post(new AddToNetwork(world, x, y, z))
|
||||||
|
|
||||||
|
def removeDevice(world: World, x: Int, y: Int, z: Int) = MinecraftForge.EVENT_BUS.post(new RemoveFromNetwork(world, x, y, z))
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
"modid": "OpenComputers",
|
"modid": "OpenComputers",
|
||||||
"name": "OpenComputers",
|
"name": "OpenComputers",
|
||||||
"description": "This mod adds modular computers and robots that can be programmed in Lua.",
|
"description": "This mod adds modular computers and robots that can be programmed in Lua.",
|
||||||
"version": "1.1.2",
|
"version": "1.1.2a",
|
||||||
"mcversion": "1.6.4",
|
"mcversion": "1.6.4",
|
||||||
"url": "https://github.com/MightyPirates/OpenComputers/wiki",
|
"url": "https://github.com/MightyPirates/OpenComputers/wiki",
|
||||||
"authors": ["Florian 'Sangar' Nücke", "Johannes 'Lord Joda' Lohrer"],
|
"authors": ["Florian 'Sangar' Nücke", "Johannes 'Lord Joda' Lohrer"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user