blob: d2802eb9eaa579c253e15404bbeb6a447845b847 [file] [log] [blame] [raw]
package li.cil.oc.common
import cpw.mods.fml.common.event._
import cpw.mods.fml.common.network.NetworkRegistry
import cpw.mods.fml.common.registry.LanguageRegistry
import li.cil.oc.api
import li.cil.oc.server.component.Computer
import li.cil.oc.server.driver
import li.cil.oc.server.network
import li.cil.oc.{OpenComputers, Items, Blocks, Config}
import net.minecraftforge.common.MinecraftForge
class Proxy {
def preInit(e: FMLPreInitializationEvent): Unit = {
Config.load(e.getSuggestedConfigurationFile)
LanguageRegistry.instance.loadLocalization(
"/assets/opencomputers/lang/en_US.lang", "en_US", false)
api.Driver.registry = Some(driver.Registry)
api.Network.network = Some(network.Network)
}
def init(e: FMLInitializationEvent): Unit = {
Blocks.init()
Items.init()
NetworkRegistry.instance.registerGuiHandler(OpenComputers, GuiHandler)
api.Driver.add(driver.Disk)
api.Driver.add(driver.GraphicsCard)
api.Driver.add(driver.Keyboard)
api.Driver.add(driver.Memory)
api.Driver.add(driver.Redstone)
MinecraftForge.EVENT_BUS.register(Computer)
MinecraftForge.EVENT_BUS.register(network.Network)
}
def postInit(e: FMLPostInitializationEvent): Unit = {
// Lock the driver registry to avoid drivers being added after computers
// may have already started up. This makes sure the driver API won't change
// over the course of a game, since that could lead to weird effects.
driver.Registry.locked = true
}
}