mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
fixed gui breaking pure servers
This commit is contained in:
parent
7b4e15c2f2
commit
14bdba937d
@ -29,7 +29,7 @@ object OpenComputers {
|
||||
// http://docs.scala-lang.org/overviews/reflection/thread-safety.html
|
||||
val mirror = ru.runtimeMirror(OpenComputers.getClass.getClassLoader)
|
||||
|
||||
@SidedProxy(clientSide = "li.cil.oc.client.Proxy", serverSide = "li.cil.oc.common.Proxy")
|
||||
@SidedProxy(clientSide = "li.cil.oc.client.Proxy", serverSide = "li.cil.oc.server.Proxy")
|
||||
var proxy: Proxy = null
|
||||
|
||||
@EventHandler
|
||||
|
17
li/cil/oc/client/GuiHandler.scala
Normal file
17
li/cil/oc/client/GuiHandler.scala
Normal file
@ -0,0 +1,17 @@
|
||||
package li.cil.oc.client
|
||||
|
||||
import li.cil.oc.common.tileentity.{Screen, Computer}
|
||||
import li.cil.oc.common.{GuiHandler => CommonGuiHandler, GuiType}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.world.World
|
||||
|
||||
object GuiHandler extends CommonGuiHandler {
|
||||
override def getClientGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int) =
|
||||
world.getBlockTileEntity(x, y, z) match {
|
||||
case tileEntity: Computer if id == GuiType.Computer.id =>
|
||||
new gui.Computer(player.inventory, tileEntity)
|
||||
case tileEntity: Screen if id == GuiType.Screen.id =>
|
||||
new gui.Screen(tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
}
|
@ -2,8 +2,10 @@ package li.cil.oc.client
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent
|
||||
import cpw.mods.fml.common.network.NetworkRegistry
|
||||
import cpw.mods.fml.common.registry.TickRegistry
|
||||
import cpw.mods.fml.relauncher.Side
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.common.tileentity.Computer
|
||||
import li.cil.oc.common.tileentity.Screen
|
||||
import li.cil.oc.common.{Proxy => CommonProxy}
|
||||
@ -12,6 +14,8 @@ private[oc] class Proxy extends CommonProxy {
|
||||
override def init(e: FMLInitializationEvent) = {
|
||||
super.init(e)
|
||||
|
||||
NetworkRegistry.instance.registerGuiHandler(OpenComputers, GuiHandler)
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[Screen], ScreenRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[Computer], ComputerRenderer)
|
||||
|
||||
|
@ -1,31 +1,15 @@
|
||||
package li.cil.oc.common
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler
|
||||
import li.cil.oc.client.gui
|
||||
import li.cil.oc.common.tileentity.Computer
|
||||
import li.cil.oc.common.tileentity.Screen
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.world.World
|
||||
|
||||
object GuiType extends Enumeration {
|
||||
val Computer = Value("Computer")
|
||||
val Screen = Value("Screen")
|
||||
}
|
||||
|
||||
object GuiHandler extends IGuiHandler {
|
||||
abstract class GuiHandler extends IGuiHandler {
|
||||
override def getServerGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int) =
|
||||
world.getBlockTileEntity(x, y, z) match {
|
||||
case tileEntity: Computer =>
|
||||
new container.Computer(player.inventory, tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
override def getClientGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int) =
|
||||
world.getBlockTileEntity(x, y, z) match {
|
||||
case tileEntity: Computer if id == GuiType.Computer.id =>
|
||||
new gui.Computer(player.inventory, tileEntity)
|
||||
case tileEntity: Screen if id == GuiType.Screen.id =>
|
||||
new gui.Screen(tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
}
|
6
li/cil/oc/common/GuiType.scala
Normal file
6
li/cil/oc/common/GuiType.scala
Normal file
@ -0,0 +1,6 @@
|
||||
package li.cil.oc.common
|
||||
|
||||
object GuiType extends Enumeration {
|
||||
val Computer = Value("Computer")
|
||||
val Screen = Value("Screen")
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
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._
|
||||
import li.cil.oc.server.component.Computer
|
||||
@ -29,8 +28,6 @@ class Proxy {
|
||||
Blocks.init()
|
||||
Items.init()
|
||||
|
||||
NetworkRegistry.instance.registerGuiHandler(OpenComputers, GuiHandler)
|
||||
|
||||
api.Driver.add(driver.FileSystem)
|
||||
api.Driver.add(driver.GraphicsCard)
|
||||
api.Driver.add(driver.Keyboard)
|
||||
|
9
li/cil/oc/server/GuiHandler.scala
Normal file
9
li/cil/oc/server/GuiHandler.scala
Normal file
@ -0,0 +1,9 @@
|
||||
package li.cil.oc.server
|
||||
|
||||
import li.cil.oc.common.{GuiHandler => CommonGuiHandler}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.world.World
|
||||
|
||||
object GuiHandler extends CommonGuiHandler {
|
||||
override def getClientGuiElement(id: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int) = null
|
||||
}
|
14
li/cil/oc/server/Proxy.scala
Normal file
14
li/cil/oc/server/Proxy.scala
Normal file
@ -0,0 +1,14 @@
|
||||
package li.cil.oc.server
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent
|
||||
import cpw.mods.fml.common.network.NetworkRegistry
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.common.{Proxy => CommonProxy}
|
||||
|
||||
private[oc] class Proxy extends CommonProxy {
|
||||
override def init(e: FMLInitializationEvent) = {
|
||||
super.init(e)
|
||||
|
||||
NetworkRegistry.instance.registerGuiHandler(OpenComputers, GuiHandler)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user