diff --git a/README.md b/README.md index d04bd5d..cc12cfe 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ See CONTRIBUTING.md in the root of the project repository. ##Licenses The MIT License (MIT) -Copyright (c) 2013 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6) +Copyright (c) 2013 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/src/mantle/core/MantleCore.scala b/src/mantle/Mantle.scala similarity index 86% rename from src/mantle/core/MantleCore.scala rename to src/mantle/Mantle.scala index 6b4b7b8..3873a1c 100644 --- a/src/mantle/core/MantleCore.scala +++ b/src/mantle/Mantle.scala @@ -1,22 +1,24 @@ -package mantle.core +package mantle import cpw.mods.fml.common.{FMLCommonHandler, Mod} import cpw.mods.fml.common.event.{FMLPostInitializationEvent, FMLInitializationEvent, FMLPreInitializationEvent} import cpw.mods.fml.common.Mod.EventHandler - -import mantle.core.lib.CoreRepo._ import net.minecraftforge.common.Configuration -import mantle.core.lib.CoreConfig + +import mantle.lib.CoreRepo._ +import mantle.lib.CoreConfig +import cpw.mods.fml.common.network.NetworkMod /** - * Mantle-Core + * Mantle * - * Central mod object for Mantle (Core Module) + * Central mod object for Mantle * * @author Sunstrike */ @Mod(modid = modId, name = modName, version = modName, modLanguage = "scala") -object MantleCore { +@NetworkMod(clientSideRequired = true, serverSideRequired = false) +object Mantle { /** * FML preinitialisation handler diff --git a/src/mantle/compat/MantleCompat.scala b/src/mantle/compat/MantleCompat.scala deleted file mode 100644 index 4f4d65b..0000000 --- a/src/mantle/compat/MantleCompat.scala +++ /dev/null @@ -1,63 +0,0 @@ -package mantle.compat - -import cpw.mods.fml.common.{FMLCommonHandler, Mod} -import cpw.mods.fml.common.event.{FMLPostInitializationEvent, FMLInitializationEvent, FMLPreInitializationEvent} -import cpw.mods.fml.common.Mod.EventHandler - -import mantle.compat.lib.CompatRepo._ -import mantle.compat.plugins.{PluginDebug, PluginManager} -import mantle.compat.lib.CompatConfig -import net.minecraftforge.common.Configuration - -/** - * Mantle-Compat - * - * Central mod object for Mantle (Compat Module) - * - * @author Sunstrike - */ -@Mod(modid = modId, name = modName, version = modName, dependencies = "required-after:Mantle-Core; required-after:Mantle-Router", modLanguage = "scala") -object MantleCompat { - - /** - * FML preinitialisation handler - * - * This is where we load our configs and related data, preparing for main load. - * - * @param evt The FMLPreInitializationEvent from FML - */ - @EventHandler - def preInit(evt:FMLPreInitializationEvent) { - logger.setParent(FMLCommonHandler.instance().getFMLLogger) - - CompatConfig.loadConfiguration(new Configuration(evt.getSuggestedConfigurationFile)) - - if (debugCompatPlugins) PluginManager.registerPluginCandidate(PluginDebug) - PluginManager.preInitPlugins() - } - - /** - * FML preinitialisation handler - * - * This is where we handle basic loading and populating any missing data in the Repo - * - * @param evt The FMLInitializationEvent from FML - */ - @EventHandler - def init(evt:FMLInitializationEvent) { - PluginManager.initPlugins() - } - - /** - * FML preinitialisation handler - * - * Final chance for cleanup before main game launch - * - * @param evt The FMLPostInitializationEvent from FML - */ - @EventHandler - def postInit(evt:FMLPostInitializationEvent) { - PluginManager.postInitPlugins() - } - -} diff --git a/src/mantle/compat/lib/CompatConfig.scala b/src/mantle/compat/lib/CompatConfig.scala deleted file mode 100644 index 8836ee6..0000000 --- a/src/mantle/compat/lib/CompatConfig.scala +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.compat.lib - -import net.minecraftforge.common.Configuration - -import mantle.core.lib.CoreRepo._ - -/** - * Mantle-Compat configuration handler - * - * Stores configuration data for Mantle-Compat, and handles save/load. - * - * @author Sunstrike - */ -object CompatConfig { - - /** - * Loads state from a Forge configuration object, or saves a new file if it doesn't already exist. - * - * @param config Configuration object (usually from a location given by FML in preinit) - */ - def loadConfiguration(config:Configuration) { - logger.info("Loading configuration from disk.") - config.load() - - // TODO: Config vars get/set here - - config.save() - logger.info("Configuration load completed.") - } - -} diff --git a/src/mantle/compat/lib/CompatRepo.scala b/src/mantle/compat/lib/CompatRepo.scala deleted file mode 100644 index f23d18f..0000000 --- a/src/mantle/compat/lib/CompatRepo.scala +++ /dev/null @@ -1,23 +0,0 @@ -package mantle.compat.lib - -import java.util.logging.Logger - -/** - * Mantle-Compat object repository - * - * Storage area for objects accessible throughout Compat, such as loggers - * - * @author Sunstrike - */ -object CompatRepo { - - final val modId = "Mantle-Compat" - final val modName = "Mantle Compat" - final val modVersion = "@VERSION@" - - val logger = Logger.getLogger(modName) - - // Debug flags - val debugCompatPlugins = System.getenv("MANTLE_COMPAT") != null - -} diff --git a/src/mantle/compat/minecraft/crash/CallableSuppConfig.scala b/src/mantle/compat/minecraft/crash/CallableSuppConfig.scala deleted file mode 100644 index 92c7d2b..0000000 --- a/src/mantle/compat/minecraft/crash/CallableSuppConfig.scala +++ /dev/null @@ -1,17 +0,0 @@ -package mantle.compat.minecraft.crash - -import cpw.mods.fml.common.ICrashCallable - -/** - * ICrashCallable for mods to report a supported environment during crashes - * - * @param modLabel The name of the mod creating the callable - * @param message A message to show this is a supported environment e.g. "Environment clean." - */ -class CallableSuppConfig(modLabel:String, message:String) extends ICrashCallable { - - def getLabel = modLabel - - def call = message - -} \ No newline at end of file diff --git a/src/mantle/compat/minecraft/crash/CallableUnsuppConfig.scala b/src/mantle/compat/minecraft/crash/CallableUnsuppConfig.scala deleted file mode 100644 index a8896ea..0000000 --- a/src/mantle/compat/minecraft/crash/CallableUnsuppConfig.scala +++ /dev/null @@ -1,25 +0,0 @@ -package mantle.compat.minecraft.crash - -import cpw.mods.fml.common.ICrashCallable - -/** - * ICrashCallable for mods to report an unsupported environment during crashes - * - * @param modIds List of guilty mod IDs - * @param modLabel The name of the mod creating the callable - */ -class CallableUnsuppConfig(modIds:List[String], modLabel:String) extends ICrashCallable { - - def getLabel = modLabel - - def call = { - var str: String = "DO NOT REPORT THIS CRASH! Unsupported mods in environment: " - var firstEntry: Boolean = true - for (id <- modIds) { - str = str + (if (firstEntry) id else ", " + id) - firstEntry = false - } - str - } - -} \ No newline at end of file diff --git a/src/mantle/compat/minecraft/misc/RecipeRemover.scala b/src/mantle/compat/minecraft/misc/RecipeRemover.scala deleted file mode 100644 index d859fe4..0000000 --- a/src/mantle/compat/minecraft/misc/RecipeRemover.scala +++ /dev/null @@ -1,61 +0,0 @@ -package mantle.compat.minecraft.misc - -import scala.collection.JavaConversions._ -import java.util -import net.minecraft.item.ItemStack -import net.minecraft.item.crafting.CraftingManager -import net.minecraft.item.crafting.IRecipe -import net.minecraft.item.crafting.ShapedRecipes -import net.minecraft.item.crafting.ShapelessRecipes - -/** - * Utility to remove recipes from the vanilla crafting handler - * - * @author mDiyo - * @author Sunstrike - */ -object RecipeRemover { - - /** - * Removes recipes of any type that return the given itemstack - * - * @param resultItem The result to find and remove - */ - def removeAnyRecipe(resultItem: ItemStack) { - val recipes: util.List[IRecipe] = CraftingManager.getInstance.getRecipeList.asInstanceOf - for (recipe: IRecipe <- recipes) { - val res = recipe.getRecipeOutput - if (ItemStack.areItemStacksEqual(resultItem, res)) recipes.remove(recipe) - } - } - - /** - * Removes shaped recipes that return the given itemstack - * - * @param resultItem The result to find and remove - */ - def removeShapedRecipe(resultItem: ItemStack) { - val recipes: util.List[IRecipe] = CraftingManager.getInstance.getRecipeList.asInstanceOf - for (recipe: IRecipe <- recipes) { - recipe match { - case rec:ShapedRecipes => - if (ItemStack.areItemStacksEqual(rec.getRecipeOutput, resultItem)) recipes.remove(recipe) - } - } - } - - /** - * Removes shapeless recipes that return the given itemstack - * - * @param resultItem The result to find and remove - */ - def removeShapelessRecipe(resultItem: ItemStack) { - val recipes: util.List[IRecipe] = CraftingManager.getInstance.getRecipeList.asInstanceOf - for (recipe: IRecipe <- recipes) { - recipe match { - case rec:ShapelessRecipes => - if (ItemStack.areItemStacksEqual(rec.getRecipeOutput, resultItem)) recipes.remove(recipe) - } - } - } -} diff --git a/src/mantle/compat/package.scala b/src/mantle/compat/package.scala deleted file mode 100644 index 3bf5c49..0000000 --- a/src/mantle/compat/package.scala +++ /dev/null @@ -1,11 +0,0 @@ -package mantle - -/** - * Mantle Compat - * - * Provides a plugin framework for modules that handle interaction with 'the outside world', - * such as mod APIs and certain Minecraft functions. - * - * @author Sunstrike - */ -package object compat {} diff --git a/src/mantle/compat/plugins/ICompatPlugin.scala b/src/mantle/compat/plugins/ICompatPlugin.scala deleted file mode 100644 index cd57185..0000000 --- a/src/mantle/compat/plugins/ICompatPlugin.scala +++ /dev/null @@ -1,44 +0,0 @@ -package mantle.compat.plugins - -/** - * Trait defining a Mantle-Compat plugin. - * - * Any plugins providing compatibility support for externals mods must follow this to be loadable. - * - * @note Do not implement any functionality in the constructor! Do your setup during preInit() - * @author Sunstrike - */ -trait ICompatPlugin { - - /** - * Mod ID this plugin should be loaded for. - * - * @return A mod ID string - */ - def providedMod: String - - /** - * Called when plugin is accepted by the manager - * - * Use this for any critical early-stage setup. - */ - def accept() - - /** - * Called during Mantle-Compat preinit - */ - def preInit() - - /** - * Called during Mantle-Compat init - */ - def init() - - /** - * Called during Mantle-Compat postinit - */ - def postInit() - - override def toString:String = s"MantleCompatPlugin(${this.getClass.getName} :: $providedMod)" - -} \ No newline at end of file diff --git a/src/mantle/compat/plugins/PluginDebug.scala b/src/mantle/compat/plugins/PluginDebug.scala deleted file mode 100644 index 78b5a9c..0000000 --- a/src/mantle/compat/plugins/PluginDebug.scala +++ /dev/null @@ -1,34 +0,0 @@ -package mantle.compat.plugins - -import mantle.compat.lib.CompatRepo._ - -/** - * Debug info plugin - * - * @author Sunstrike - */ -object PluginDebug extends ICompatPlugin { - - def providedMod: String = "Mantle-Compat" - - def accept() { - log("Accepted by manager.") - } - - def preInit() { - log("Reached preinit.") - } - - def init() { - log("Reached init.") - } - - def postInit() { - log("Reached postinit.") - } - - private def log(msg:String) { - logger.info(s"[PluginDebug] $msg") - } - -} diff --git a/src/mantle/compat/plugins/PluginManager.scala b/src/mantle/compat/plugins/PluginManager.scala deleted file mode 100644 index 80d63b7..0000000 --- a/src/mantle/compat/plugins/PluginManager.scala +++ /dev/null @@ -1,80 +0,0 @@ -package mantle.compat.plugins - -import scala.collection.mutable.MutableList -import cpw.mods.fml.common.Loader - -import mantle.compat.lib.CompatRepo._ - -/** - * Mantle-Compat Plugin Manager - * - * Coordinates all compat plugins in the Mantle-Compat framework. - * - * @author Sunstrike - */ -object PluginManager { - - private val activePlugins = MutableList[ICompatPlugin]() - - /** - * Register a candidate compat plugin - * - * Tests if the candidate's provided mod is actually running in the environment before adding to the active plugins list. - * - * @param candidate The plugin to attempt to load. - * @return True if plugin was loaded, False if plugin was rejected. - */ - def registerPluginCandidate(candidate:ICompatPlugin):Boolean = { - if (!Loader.isModLoaded(candidate.providedMod)) { - debug(s"Rejecting: $candidate") - return false - } - - debug(s"Accepting: $candidate") - candidate.accept() - activePlugins += candidate - true - } - - /** - * Called during Compat preinit - * - * @note For internal use only! - */ - def preInitPlugins() { - debug(s"Performing preinit (plugins = $activePlugins)") - activePlugins map { x => x.preInit() } - } - - /** - * Called during Compat init - * - * @note For internal use only! - */ - def initPlugins() { - debug(s"Performing init (plugins = $activePlugins)") - activePlugins map { x => x.init() } - } - - /** - * Called during Compat postinit - * - * @note For internal use only! - */ - def postInitPlugins() { - debug(s"Performing postinit (plugins = $activePlugins)") - activePlugins map { x => x.postInit() } - } - - /** - * Internal logging helper - * - * Prepends appropriate tag and only logs if debug flag MANTLE_COMPAT is active. - * - * @param msg String to log. - */ - private def debug(msg:String) { - if (debugCompatPlugins) logger.info(s"[PluginManager] $msg") - } - -} diff --git a/src/mantle/compat/plugins/builtin/PluginAppEng.scala b/src/mantle/compat/plugins/builtin/PluginAppEng.scala deleted file mode 100644 index dc6b740..0000000 --- a/src/mantle/compat/plugins/builtin/PluginAppEng.scala +++ /dev/null @@ -1,32 +0,0 @@ -package mantle.compat.plugins.builtin - -import mantle.compat.plugins.ICompatPlugin -import mantle.router.routing.RouterCoordinator -import mantle.router.routing.builtin.UnitAppEng - -/** - * Applied Energistics compatibility plugin - * - * @author Sunstrike - */ -object PluginAppEng extends ICompatPlugin { - - def providedMod: String = "AppliedEnergistics" - - def accept() { - RouterCoordinator.registerPipelineUnit(UnitAppEng) // Register AE pipeline object - } - - def preInit() { - - } - - def init() { - - } - - def postInit() { - - } - -} diff --git a/src/mantle/compat/plugins/builtin/PluginBCTransport.scala b/src/mantle/compat/plugins/builtin/PluginBCTransport.scala deleted file mode 100644 index d08095e..0000000 --- a/src/mantle/compat/plugins/builtin/PluginBCTransport.scala +++ /dev/null @@ -1,31 +0,0 @@ -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 - */ -object PluginBCTransport extends ICompatPlugin { - - def providedMod = "BuildCraft|Transport" - - def accept() { - RouterCoordinator.registerPipelineUnit(UnitBCTransport) - } - - def preInit() { - - } - - def init() { - - } - - def postInit() { - - } -} diff --git a/src/mantle/compat/plugins/builtin/PluginMystcraft.scala b/src/mantle/compat/plugins/builtin/PluginMystcraft.scala deleted file mode 100644 index 63ef13c..0000000 --- a/src/mantle/compat/plugins/builtin/PluginMystcraft.scala +++ /dev/null @@ -1,32 +0,0 @@ -package mantle.compat.plugins.builtin - -import mantle.compat.plugins.ICompatPlugin -import mantle.router.routing.RouterCoordinator -import mantle.router.routing.builtin.UnitMystcraft - -/** - * Mystcraft compatibility plugin - * - * @author Sunstrike - */ -object PluginMystcraft extends ICompatPlugin { - - def providedMod: String = "Mystcraft" - - def accept() { - RouterCoordinator.registerPipelineUnit(UnitMystcraft) // Register AE pipeline object - } - - def preInit() { - - } - - def init() { - - } - - def postInit() { - - } - - } diff --git a/src/mantle/core/lib/CoreRepo.scala b/src/mantle/core/lib/CoreRepo.scala deleted file mode 100644 index ec28629..0000000 --- a/src/mantle/core/lib/CoreRepo.scala +++ /dev/null @@ -1,20 +0,0 @@ -package mantle.core.lib - -import java.util.logging.Logger - -/** - * Mantle-Core object repository - * - * Storage area for objects accessible throughout Core, such as loggers - * - * @author Sunstrike - */ -object CoreRepo { - - final val modId = "Mantle-Core" - final val modName = "Mantle Core" - final val modVersion = "@VERSION@" - - val logger = Logger.getLogger(modName) - -} diff --git a/src/mantle/core/package.scala b/src/mantle/core/package.scala deleted file mode 100644 index f9ccef7..0000000 --- a/src/mantle/core/package.scala +++ /dev/null @@ -1,11 +0,0 @@ -package mantle - -/** - * Mantle Core - * - * Provides the base framework for all of the other Mantle modules in addition - * to some basic functions of it's own. - * - * @author Sunstrike - */ -package object core {} diff --git a/src/mantle/core/lib/CoreConfig.scala b/src/mantle/lib/CoreConfig.scala similarity index 77% rename from src/mantle/core/lib/CoreConfig.scala rename to src/mantle/lib/CoreConfig.scala index f8344d4..09022b9 100644 --- a/src/mantle/core/lib/CoreConfig.scala +++ b/src/mantle/lib/CoreConfig.scala @@ -1,13 +1,13 @@ -package mantle.core.lib +package mantle.lib import net.minecraftforge.common.Configuration -import mantle.core.lib.CoreRepo._ +import mantle.lib.CoreRepo._ /** - * Mantle-Core configuration handler + * Mantle configuration handler * - * Stores configuration data for Mantle-Core, and handles save/load. + * Stores configuration data for Mantle, and handles save/load. * * @author Sunstrike */ diff --git a/src/mantle/lib/CoreRepo.scala b/src/mantle/lib/CoreRepo.scala new file mode 100644 index 0000000..0084bca --- /dev/null +++ b/src/mantle/lib/CoreRepo.scala @@ -0,0 +1,20 @@ +package mantle.lib + +import java.util.logging.Logger + +/** + * Mantle object repository + * + * Storage area for objects accessible throughout Mantle, such as loggers + * + * @author Sunstrike + */ +object CoreRepo { + + final val modId = "Mantle" + final val modName = "Mantle" + final val modVersion = "@VERSION@" + + val logger = Logger.getLogger(modName) + +} diff --git a/src/mantle/core/math/Dozenal.scala b/src/mantle/math/Dozenal.scala similarity index 97% rename from src/mantle/core/math/Dozenal.scala rename to src/mantle/math/Dozenal.scala index b486a7c..fbb60f0 100644 --- a/src/mantle/core/math/Dozenal.scala +++ b/src/mantle/math/Dozenal.scala @@ -1,4 +1,4 @@ -package mantle.core.math +package mantle.math import scala.collection.mutable.MutableList diff --git a/src/mantle/router/MantleRouter.scala b/src/mantle/router/MantleRouter.scala deleted file mode 100644 index 3574be0..0000000 --- a/src/mantle/router/MantleRouter.scala +++ /dev/null @@ -1,72 +0,0 @@ -package mantle.router - -import cpw.mods.fml.common.{FMLCommonHandler, Mod} -import cpw.mods.fml.common.event.{FMLPostInitializationEvent, FMLInitializationEvent, FMLPreInitializationEvent} -import cpw.mods.fml.common.Mod.EventHandler - -import mantle.router.lib.RouterRepo._ -import mantle.router.routing.{UnitDebugLogger, RouterCoordinator} -import mantle.router.lib.RouterConfig -import net.minecraftforge.common.Configuration - -/** - * Mantle-Router - * - * Central mod object for Mantle (Router Module) - * - * @author Sunstrike - */ -@Mod(modid = modId, name = modName, version = modName, dependencies = "required-after:Mantle-Core", modLanguage = "scala") -object MantleRouter { - - /** - * FML preinitialisation handler - * - * This is where we load our configs and related data, preparing for main load. - * - * @param evt The FMLPreInitializationEvent from FML - */ - @EventHandler - def preInit(evt:FMLPreInitializationEvent) { - logger.setParent(FMLCommonHandler.instance().getFMLLogger) - - RouterConfig.loadConfiguration(new Configuration(evt.getSuggestedConfigurationFile)) - - registerStandardUnits() - } - - /** - * FML preinitialisation handler - * - * This is where we handle basic loading and populating any missing data in the Repo. - * The Router also processes events here. - * - * @param evt The FMLInitializationEvent from FML - */ - @EventHandler - def init(evt:FMLInitializationEvent) { - registerStandardUnits() - RouterCoordinator.processQueue() - } - - /** - * Registrar for built-in Router pipeline objects - */ - private def registerStandardUnits() { - if (debugMessageSys) RouterCoordinator.registerPipelineUnit(UnitDebugLogger) - } - - /** - * FML preinitialisation handler - * - * Final chance for cleanup before main game launch. - * The Router also processes events here. - * - * @param evt The FMLPostInitializationEvent from FML - */ - @EventHandler - def postInit(evt:FMLPostInitializationEvent) { - RouterCoordinator.processQueue() - } - -} diff --git a/src/mantle/router/lib/RouterConfig.scala b/src/mantle/router/lib/RouterConfig.scala deleted file mode 100644 index 5b3f012..0000000 --- a/src/mantle/router/lib/RouterConfig.scala +++ /dev/null @@ -1,30 +0,0 @@ -package mantle.router.lib - -import net.minecraftforge.common.Configuration -import mantle.router.lib.RouterRepo._ - -/** - * Mantle-Router configuration handler - * - * Stores configuration data for Mantle-Router, and handles save/load. - * - * @author Sunstrike - */ -object RouterConfig { - - /** - * Loads state from a Forge configuration object, or saves a new file if it doesn't already exist. - * - * @param config Configuration object (usually from a location given by FML in preinit) - */ - def loadConfiguration(config:Configuration) { - logger.info("Loading configuration from disk.") - config.load() - - // TODO: Config vars get/set here - - config.save() - logger.info("Configuration load completed.") - } - - } diff --git a/src/mantle/router/lib/RouterRepo.scala b/src/mantle/router/lib/RouterRepo.scala deleted file mode 100644 index 3466672..0000000 --- a/src/mantle/router/lib/RouterRepo.scala +++ /dev/null @@ -1,23 +0,0 @@ -package mantle.router.lib - -import java.util.logging.Logger - -/** - * Mantle-Router object repository - * - * Storage area for objects accessible throughout Router, such as loggers - * - * @author Sunstrike - */ -object RouterRepo { - - final val modId = "Mantle-Router" - final val modName = "Mantle Router" - final val modVersion = "@VERSION@" - - val logger = Logger.getLogger(modName) - - // Debug flags - val debugMessageSys = System.getenv("MANTLE_MSG_SYS") != null - - } diff --git a/src/mantle/router/package.scala b/src/mantle/router/package.scala deleted file mode 100644 index d253ad6..0000000 --- a/src/mantle/router/package.scala +++ /dev/null @@ -1,15 +0,0 @@ -package mantle - -/** - * Mantle Router - * - * Provides advanced IMC message routing functionality to other mods for more convenient - * registration with external modules. - * - * Planned modules/helpers: - * * BuildCraft Transport (Facades) - * * Forge Multipart (Microblocks) - * * Fluid blacklist helper (Mystcraft et al.) - * * TConstruct dimension blacklisting - */ -package object router {} diff --git a/src/mantle/router/routing/IPipelineUnit.scala b/src/mantle/router/routing/IPipelineUnit.scala deleted file mode 100644 index aa8d3c1..0000000 --- a/src/mantle/router/routing/IPipelineUnit.scala +++ /dev/null @@ -1,29 +0,0 @@ -package mantle.router.routing - -/** - * Message pipeline unit interface - * - * Defines the interface for objects that can be inserted into the IMCHandler pipeline. - * - * @author Sunstrike - */ -trait IPipelineUnit { - - /** - * Getter for the name of this unit - * - * @example def unitName: String = "FMP Compat" - * @return The name of this unit (something descriptive) - */ - def unitName:String - - /** - * Handles an incoming Mantle message - * - * @param msg The Mantle message from Router. - */ - def handleMessage(msg:MantleMessage) - - override def toString: String = s"MantlePipelineUnit($unitName)" - -} \ No newline at end of file diff --git a/src/mantle/router/routing/MantleMessage.scala b/src/mantle/router/routing/MantleMessage.scala deleted file mode 100644 index fb04900..0000000 --- a/src/mantle/router/routing/MantleMessage.scala +++ /dev/null @@ -1,44 +0,0 @@ -package mantle.router.routing - -/** - * IMCMessage analogue for Mantle Router pipeline - * - * Instances of this are used to send messages to the Coordinator for processing through the Router pipeline. - * - * @param origin The mod ID the message is from - * @param msg The message to be sent, in IMC-style form e.g. `registerDecorativeBlock` - * @param obj (Optional) An object to attach to the message. - * - * @author Sunstrike - */ -class MantleMessage(origin:String, msg:String, obj:Any) { - - private val modId = origin - private val message = msg - private val attachment = obj - - /** - * Get the source mods modID. - * - * @return Mod ID of sender - */ - def getOrigin = modId - - /** - * Get the message this object contains. - * - * @return The message string - */ - def getMessage = message - - /** - * Get the object attached to the message. - * - * @note This must be null-checked as the field is permitted to be null at instantiation. - * @return The attachment or null. - */ - def getAttachment = attachment - - override def toString: String = s"(($origin) $message :: $obj)" - -} diff --git a/src/mantle/router/routing/RouterCoordinator.scala b/src/mantle/router/routing/RouterCoordinator.scala deleted file mode 100644 index 4023331..0000000 --- a/src/mantle/router/routing/RouterCoordinator.scala +++ /dev/null @@ -1,85 +0,0 @@ -package mantle.router.routing - -import cpw.mods.fml.common.event.FMLInterModComms.{IMCMessage, IMCEvent} -import scala.collection.mutable.{MutableList, Queue} - -import mantle.router.lib.RouterRepo._ - -/** - * Router Message handler - * - * Handles all incoming Mantle messages and their processing. - * - * Reserved Mantle messages: - * * registerDecorativeBlock (Int[] - bID & meta OR tuple(bID, meta)) -- Used for FMP/BC Facades. May be hooked by other units. - * * movableTile (String (full class path)) -- Used for AE SpatialIO. May be hooked by other units. - * * myst_fluidSymbol (Tuple(FluidName, rarity, grammarWeight, blockInstability) OR a prebuilt NBT tag compound) -- Mystcraft fluid symbol. Should not be hooked. - * - * @author Sunstrike - */ -object RouterCoordinator { - - private val messagePipeline:MutableList[IPipelineUnit] = MutableList() - private val messageQueue:Queue[MantleMessage] = Queue[MantleMessage]() - - /** - * Send a message - * - * Adds a given MantleMessage to the message queue to be processed next round. - * - * @note This should be completed before Mantle-Router init! - * @param msg The MantleMessage to queue. - */ - def queueMessage(msg:MantleMessage) { - debug(s"Queue accept: $msg") - messageQueue.enqueue(msg) - } - - /** - * Processing hook - * - * Runs all current events through the pipeline. This is called at Router init and postinit. - * - * @note This should be considered an internal call; other mods should not call this! - */ - def processQueue() { - debug(s"Preparing for message processing; pipeline = $messagePipeline, queue: $messageQueue") - for ( msg <- messageQueue; handler <- messagePipeline ) { - handler.handleMessage(msg) - } - - messageQueue.clear() - debug("Message processsing completed.") - } - - /** - * Register a Pipeline unit - * - * Whenever Router receives an IMC message, it'll pass the message to all registered units. - * This allows mods to register new units. - * - * @note Units must be registered in preinit or the Unit may miss the first processing round. - * - * @param unit The unit to register into the pipeline - * @return True if successful, False if registration failed. - */ - def registerPipelineUnit(unit:IPipelineUnit):Boolean = { - if (messagePipeline.contains(unit)) - return false - - messagePipeline += unit - true - } - - /** - * Internal log helper - * - * Logs input (with prepended tag) only if message system debug flag (MANTLE_MSG_SYS) is active. - * - * @param msg String to log. - */ - private def debug(msg:String) { - if (debugMessageSys) logger.info(s"[RouterCoordinator] $msg") - } - -} diff --git a/src/mantle/router/routing/UnitDebugLogger.scala b/src/mantle/router/routing/UnitDebugLogger.scala deleted file mode 100644 index 18c0d1e..0000000 --- a/src/mantle/router/routing/UnitDebugLogger.scala +++ /dev/null @@ -1,20 +0,0 @@ -package mantle.router.routing - -import mantle.router.lib.RouterRepo._ - -/** - * Debug logging pipeline unit - * - * Logs all Mantle messages to console during debug runs. - * - * @author Sunstrike - */ -object UnitDebugLogger extends IPipelineUnit { - - def unitName: String = "Message Debug Unit" - - def handleMessage(msg: MantleMessage) { - logger.info(s"[UnitDebugLogger] Recv: $msg") - } - -} diff --git a/src/mantle/router/routing/builtin/UnitAppEng.scala b/src/mantle/router/routing/builtin/UnitAppEng.scala deleted file mode 100644 index 07447d7..0000000 --- a/src/mantle/router/routing/builtin/UnitAppEng.scala +++ /dev/null @@ -1,23 +0,0 @@ -package mantle.router.routing.builtin - -import mantle.router.routing.{MantleMessage, IPipelineUnit} -import cpw.mods.fml.common.event.FMLInterModComms - -/** - * Applied Energistics pipeline unit - * - * @author Sunstrike - */ -object UnitAppEng extends IPipelineUnit { - - def unitName: String = "AppEng Compat" - - def handleMessage(msg: MantleMessage) { - if (msg.getMessage.equals("movableTile")) { - msg.getAttachment match { - case s:String => FMLInterModComms.sendMessage("AppliedEnergistics", "movabletile", s) - } - } - } - -} diff --git a/src/mantle/router/routing/builtin/UnitBCTransport.scala b/src/mantle/router/routing/builtin/UnitBCTransport.scala deleted file mode 100644 index 7cff5bb..0000000 --- a/src/mantle/router/routing/builtin/UnitBCTransport.scala +++ /dev/null @@ -1,43 +0,0 @@ -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 - */ -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) { - if (msg.getMessage.equals("registerDecorativeBlock")) { - 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") - } - -} diff --git a/src/mantle/router/routing/builtin/UnitMystcraft.scala b/src/mantle/router/routing/builtin/UnitMystcraft.scala deleted file mode 100644 index 21954ce..0000000 --- a/src/mantle/router/routing/builtin/UnitMystcraft.scala +++ /dev/null @@ -1,36 +0,0 @@ -package mantle.router.routing.builtin - -import mantle.router.routing.{MantleMessage, IPipelineUnit} -import net.minecraft.nbt.NBTTagCompound -import cpw.mods.fml.common.event.FMLInterModComms - -/** - * Mystcraft pipeline unit - * - * @author Sunstrike - */ -object UnitMystcraft extends IPipelineUnit { - - def unitName = "Mystcraft Compat" - - def handleMessage(msg: MantleMessage) { - if (msg.getMessage.equals("myst_fluidSymbol")) { - msg.getAttachment match { - case (fName:String, rarity:Float, grammarWeight:Float, blockInstability:Float) => - val nbt = new NBTTagCompound() - val fluidSym = new NBTTagCompound() - fluidSym.setString("fluidname", fName) - fluidSym.setFloat("rarity", rarity) - fluidSym.setFloat("grammarweight", grammarWeight) - fluidSym.setFloat("instabilityPerBlock", blockInstability) - nbt.setCompoundTag("fluidsymbol", fluidSym) - sendMystMessage("fluidsymbol", nbt) - } - } - } - - private def sendMystMessage(msg: String, nbt: NBTTagCompound) { - FMLInterModComms.sendMessage("Mystcraft", msg, nbt) - } - -}