BC Transport plugin + unit

This commit is contained in:
Sunstrike committed 2013-11-03 11:23:05 +00:00
1 parent b090f0a0a0
commit ab5c3e34c3
2 files changed
+70

No files matched your search

@@ -0,0 +1,31 @@
package mantle.compat.plugins.builtin
import mantle.compat.plugins.ICompatPlugin
import mantle.router.routing.RouterCoordinator
import mantle.router.routing.builtin.UnitBCTransport
/**
* Buildcraft Transport plugin
*
* @author Sunstrike <[email protected]>
*/
object PluginBCTransport extends ICompatPlugin {
def providedMod = "BuildCraft|Transport"
def accept() {
RouterCoordinator.registerPipelineUnit(UnitBCTransport)
}
def preInit() {
}
def init() {
}
def postInit() {
}
}
@@ -0,0 +1,39 @@
package mantle.router.routing.builtin
import mantle.router.routing.{MantleMessage, IPipelineUnit}
import mantle.router.lib.RouterRepo._
import cpw.mods.fml.common.event.FMLInterModComms
/**
* Buildcraft Transport pipeline unit
*
* @author Sunstrike <[email protected]>
*/
object UnitBCTransport extends IPipelineUnit {
/**
* Getter for the name of this unit
*
* @example def unitName: String = "FMP Compat"
* @return The name of this unit (something descriptive)
*/
def unitName = "BC Transport Compat"
/**
* Handles an incoming Mantle message
*
* @param msg The Mantle message from Router.
*/
def handleMessage(msg: MantleMessage) = msg.getAttachment match {
case (bID:Int, meta:Int) => sendBCFacadeMessage(bID, meta)
case il:Array[Int] => try { sendBCFacadeMessage(il(0), il(1)) } catch { case e:Exception => logWarn("Invalid Int array received.") }
}
private def sendBCFacadeMessage(bID: Int, meta: Int) {
FMLInterModComms.sendMessage("BuildCraft|Transport", "add-facade", s"$bID@$meta")
}
private def logWarn(str:String) {
logger.warning(s"[$unitName] $str")
}
}