From c1fd2c0144f6c80ca056b653ddc272fd518d0535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 29 Sep 2013 14:57:05 +0200 Subject: [PATCH] refactor run for tile entities --- li/cil/oc/Blocks.scala | 2 +- li/cil/oc/Config.scala | 12 +++++--- li/cil/oc/client/ComputerRenderer.scala | 4 +-- li/cil/oc/client/PacketHandler.scala | 20 ++++++------- li/cil/oc/client/PacketSender.scala | 12 ++++---- li/cil/oc/client/Proxy.scala | 8 +++--- li/cil/oc/client/ScreenRenderer.scala | 4 +-- .../{computer => component}/Computer.scala | 2 +- li/cil/oc/client/gui/Computer.scala | 4 +-- li/cil/oc/client/gui/Screen.scala | 8 +++--- li/cil/oc/common/GuiHandler.scala | 10 +++---- li/cil/oc/common/Proxy.scala | 28 +++++++++---------- li/cil/oc/common/block/Computer.scala | 14 +++++----- li/cil/oc/common/block/Delegate.scala | 6 ++-- li/cil/oc/common/block/Delegator.scala | 26 ++++++++--------- .../{ItemBlockMulti.scala => Item.scala} | 6 ++-- li/cil/oc/common/block/Keyboard.scala | 6 ++-- li/cil/oc/common/block/Screen.scala | 14 +++++----- ...cialMulti.scala => SpecialDelegator.scala} | 2 +- li/cil/oc/common/container/Computer.scala | 4 +-- li/cil/oc/common/item/Delegate.scala | 2 +- li/cil/oc/common/item/Delegator.scala | 4 +-- ...ntProxy.scala => ComponentInventory.scala} | 10 +++---- ...ileEntityComputer.scala => Computer.scala} | 10 ++++--- ...ileEntityKeyboard.scala => Keyboard.scala} | 2 +- ...eEntityRotatable.scala => Rotatable.scala} | 2 +- .../{TileEntityScreen.scala => Screen.scala} | 14 +++++----- li/cil/oc/server/PacketHandler.scala | 12 ++++---- li/cil/oc/server/PacketSender.scala | 4 +-- li/cil/oc/server/component/Computer.scala | 14 +++++----- li/cil/oc/util/ExtendedLuaState.scala | 14 +++------- 31 files changed, 139 insertions(+), 141 deletions(-) rename li/cil/oc/client/{computer => component}/Computer.scala (93%) rename li/cil/oc/common/block/{ItemBlockMulti.scala => Item.scala} (88%) rename li/cil/oc/common/block/{SpecialMulti.scala => SpecialDelegator.scala} (95%) rename li/cil/oc/common/tileentity/{ItemComponentProxy.scala => ComponentInventory.scala} (96%) rename li/cil/oc/common/tileentity/{TileEntityComputer.scala => Computer.scala} (91%) rename li/cil/oc/common/tileentity/{TileEntityKeyboard.scala => Keyboard.scala} (96%) rename li/cil/oc/common/tileentity/{TileEntityRotatable.scala => Rotatable.scala} (99%) rename li/cil/oc/common/tileentity/{TileEntityScreen.scala => Screen.scala} (87%) diff --git a/li/cil/oc/Blocks.scala b/li/cil/oc/Blocks.scala index 45ac51e1e..3b084bdc8 100644 --- a/li/cil/oc/Blocks.scala +++ b/li/cil/oc/Blocks.scala @@ -14,7 +14,7 @@ object Blocks { // try to register with it. Also, the order the sub blocks are created in // must not be changed since that order determines their actual IDs. blockSimple = new Delegator(Config.blockId) - blockSpecial = new SpecialMulti(Config.blockSpecialId) + blockSpecial = new SpecialDelegator(Config.blockSpecialId) computer = new Computer(blockSimple) screen = new Screen(blockSimple) diff --git a/li/cil/oc/Config.scala b/li/cil/oc/Config.scala index 75849b8b4..162e5f56e 100644 --- a/li/cil/oc/Config.scala +++ b/li/cil/oc/Config.scala @@ -19,15 +19,19 @@ object Config { val config = new net.minecraftforge.common.Configuration(file) Config.blockId = config.getBlock("block", Config.blockId, - "The block ID used for simple blocks.").getInt(Config.blockId) + "The block ID used for simple blocks."). + getInt(Config.blockId) Config.blockSpecialId = config.getBlock("blockSpecial", Config.blockSpecialId, - "The block ID used for special blocks.").getInt(Config.blockSpecialId) + "The block ID used for special blocks."). + getInt(Config.blockSpecialId) Config.itemId = config.getItem("item", Config.itemId, - "The item ID used for all items.").getInt(Config.itemId) + "The item ID used for all non-stackable items."). + getInt(Config.itemId) Config.threads = config.get("config", "threads", Config.threads, - "The overall number of threads to use to driver computers.").getInt(Config.threads) + "The overall number of threads to use to driver computers."). + getInt(Config.threads) if (config.hasChanged) config.save() diff --git a/li/cil/oc/client/ComputerRenderer.scala b/li/cil/oc/client/ComputerRenderer.scala index ddc246a32..c5c4914b5 100644 --- a/li/cil/oc/client/ComputerRenderer.scala +++ b/li/cil/oc/client/ComputerRenderer.scala @@ -1,6 +1,6 @@ package li.cil.oc.client -import li.cil.oc.common.tileentity.TileEntityComputer +import li.cil.oc.common.tileentity.Computer import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer @@ -13,7 +13,7 @@ object ComputerRenderer extends TileEntitySpecialRenderer { private val frontOn = new ResourceLocation("opencomputers", "textures/blocks/computer_front_on.png") override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = { - val computer = tileEntity.asInstanceOf[TileEntityComputer] + val computer = tileEntity.asInstanceOf[Computer] if (computer.isOn) { GL11.glPushAttrib(0xFFFFFF) GL11.glPushMatrix() diff --git a/li/cil/oc/client/PacketHandler.scala b/li/cil/oc/client/PacketHandler.scala index e9f9789e9..3720e6b93 100644 --- a/li/cil/oc/client/PacketHandler.scala +++ b/li/cil/oc/client/PacketHandler.scala @@ -2,9 +2,9 @@ package li.cil.oc.client import cpw.mods.fml.common.network.Player import li.cil.oc.common.PacketType -import li.cil.oc.common.tileentity.TileEntityComputer -import li.cil.oc.common.tileentity.TileEntityRotatable -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity.Computer +import li.cil.oc.common.tileentity.Rotatable +import li.cil.oc.common.tileentity.Screen import li.cil.oc.common.{PacketHandler => CommonPacketHandler} import net.minecraft.entity.player.EntityPlayer @@ -28,7 +28,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenResolutionChange(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => { val w = p.readInt() @@ -38,7 +38,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenSet(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => { val col = p.readInt() @@ -49,7 +49,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenFill(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => { val col = p.readInt() @@ -62,7 +62,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenCopy(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => { val col = p.readInt() @@ -76,7 +76,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenBufferResponse(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => p.readUTF.split('\n').zipWithIndex.foreach { @@ -85,7 +85,7 @@ class PacketHandler extends CommonPacketHandler { } def onComputerStateResponse(p: PacketParser) = - p.readTileEntity[TileEntityComputer]() match { + p.readTileEntity[Computer]() match { case None => // Invalid packet. case Some(t) => { t.isOn = p.readBoolean() @@ -93,7 +93,7 @@ class PacketHandler extends CommonPacketHandler { } def onRotatableStateResponse(p: PacketParser) = - p.readTileEntity[TileEntityRotatable]() match { + p.readTileEntity[Rotatable]() match { case None => // Invalid packet. case Some(t) => t.pitch = p.readDirection() diff --git a/li/cil/oc/client/PacketSender.scala b/li/cil/oc/client/PacketSender.scala index 67e374802..88b46acbe 100644 --- a/li/cil/oc/client/PacketSender.scala +++ b/li/cil/oc/client/PacketSender.scala @@ -3,25 +3,25 @@ package li.cil.oc.client import li.cil.oc.api.network.Node import li.cil.oc.common.PacketBuilder import li.cil.oc.common.PacketType -import li.cil.oc.common.tileentity.TileEntityComputer -import li.cil.oc.common.tileentity.TileEntityRotatable -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity.Computer +import li.cil.oc.common.tileentity.Rotatable +import li.cil.oc.common.tileentity.Screen import net.minecraft.tileentity.TileEntity object PacketSender { - def sendScreenBufferRequest(t: TileEntityScreen) = { + def sendScreenBufferRequest(t: Screen) = { val pb = new PacketBuilder(PacketType.ScreenBufferRequest) pb.writeTileEntity(t) pb.sendToServer() } - def sendComputerStateRequest(t: TileEntityComputer) = { + def sendComputerStateRequest(t: Computer) = { val pb = new PacketBuilder(PacketType.ComputerStateRequest) pb.writeTileEntity(t) pb.sendToServer() } - def sendRotatableStateRequest(t: TileEntityRotatable) = { + def sendRotatableStateRequest(t: Rotatable) = { val pb = new PacketBuilder(PacketType.RotatableStateRequest) pb.writeTileEntity(t) pb.sendToServer() diff --git a/li/cil/oc/client/Proxy.scala b/li/cil/oc/client/Proxy.scala index e26194dd9..25b87f4f7 100644 --- a/li/cil/oc/client/Proxy.scala +++ b/li/cil/oc/client/Proxy.scala @@ -2,15 +2,15 @@ package li.cil.oc.client import cpw.mods.fml.client.registry.ClientRegistry import cpw.mods.fml.common.event.FMLInitializationEvent -import li.cil.oc.common.tileentity.TileEntityComputer -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity.Computer +import li.cil.oc.common.tileentity.Screen import li.cil.oc.common.{Proxy => CommonProxy} private[oc] class Proxy extends CommonProxy { override def init(e: FMLInitializationEvent) = { super.init(e) - ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileEntityScreen], ScreenRenderer) - ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileEntityComputer], ComputerRenderer) + ClientRegistry.bindTileEntitySpecialRenderer(classOf[Screen], ScreenRenderer) + ClientRegistry.bindTileEntitySpecialRenderer(classOf[Computer], ComputerRenderer) } } \ No newline at end of file diff --git a/li/cil/oc/client/ScreenRenderer.scala b/li/cil/oc/client/ScreenRenderer.scala index 965b2e533..5b60a5af2 100644 --- a/li/cil/oc/client/ScreenRenderer.scala +++ b/li/cil/oc/client/ScreenRenderer.scala @@ -1,7 +1,7 @@ package li.cil.oc.client import li.cil.oc.client.gui.MonospaceFontRenderer -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity.Screen import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -10,7 +10,7 @@ import org.lwjgl.opengl.GL11 object ScreenRenderer extends TileEntitySpecialRenderer { override def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float) = { - val tileEntity = t.asInstanceOf[TileEntityScreen] + val tileEntity = t.asInstanceOf[Screen] GL11.glPushAttrib(0xFFFFFF) GL11.glPushMatrix() diff --git a/li/cil/oc/client/computer/Computer.scala b/li/cil/oc/client/component/Computer.scala similarity index 93% rename from li/cil/oc/client/computer/Computer.scala rename to li/cil/oc/client/component/Computer.scala index 95bbf1b71..480498871 100644 --- a/li/cil/oc/client/computer/Computer.scala +++ b/li/cil/oc/client/component/Computer.scala @@ -1,4 +1,4 @@ -package li.cil.oc.client.computer +package li.cil.oc.client.component import li.cil.oc.common.component import net.minecraft.nbt.NBTTagCompound diff --git a/li/cil/oc/client/gui/Computer.scala b/li/cil/oc/client/gui/Computer.scala index bdc099a67..ca4bdb311 100644 --- a/li/cil/oc/client/gui/Computer.scala +++ b/li/cil/oc/client/gui/Computer.scala @@ -1,7 +1,7 @@ package li.cil.oc.client.gui import li.cil.oc.common.container -import li.cil.oc.common.tileentity.TileEntityComputer +import li.cil.oc.common.tileentity import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer @@ -10,7 +10,7 @@ import net.minecraft.util.ResourceLocation import net.minecraft.util.StatCollector import org.lwjgl.opengl.GL11 -class Computer(inventory: InventoryPlayer, val tileEntity: TileEntityComputer) extends GuiContainer(new container.Computer(inventory, tileEntity)) { +class Computer(inventory: InventoryPlayer, val tileEntity: tileentity.Computer) extends GuiContainer(new container.Computer(inventory, tileEntity)) { private val background = new ResourceLocation("opencomputers", "textures/gui/computer.png") private val iconPsu = new ResourceLocation("opencomputers", "textures/gui/icon_psu.png") diff --git a/li/cil/oc/client/gui/Screen.scala b/li/cil/oc/client/gui/Screen.scala index 285412c26..7c3be4022 100644 --- a/li/cil/oc/client/gui/Screen.scala +++ b/li/cil/oc/client/gui/Screen.scala @@ -1,7 +1,7 @@ package li.cil.oc.client.gui import li.cil.oc.client.PacketSender -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity import net.minecraft.client.gui.{GuiScreen => MCGuiScreen} import net.minecraft.client.renderer.GLAllocation import net.minecraft.client.renderer.Tessellator @@ -21,8 +21,8 @@ import org.lwjgl.opengl.GL11 * called whenever the text actually changes, otherwise there will be no change * in the text displayed in the GUI. */ -class Screen(val tileEntity: TileEntityScreen) extends MCGuiScreen { - tileEntity.gui = Some(this) +class Screen(val tileEntity: tileentity.Screen) extends MCGuiScreen { + tileEntity.guiScreen = Some(this) var (x, y, innerWidth, innerHeight, scale) = (0, 0, 0, 0, 0.0) @@ -71,7 +71,7 @@ class Screen(val tileEntity: TileEntityScreen) extends MCGuiScreen { override def onGuiClosed() = { super.onGuiClosed() - tileEntity.gui = None + tileEntity.guiScreen = None } override def drawScreen(mouseX: Int, mouseY: Int, dt: Float): Unit = { diff --git a/li/cil/oc/common/GuiHandler.scala b/li/cil/oc/common/GuiHandler.scala index 1a35351b4..152eee71a 100644 --- a/li/cil/oc/common/GuiHandler.scala +++ b/li/cil/oc/common/GuiHandler.scala @@ -2,8 +2,8 @@ package li.cil.oc.common import cpw.mods.fml.common.network.IGuiHandler import li.cil.oc.client.gui -import li.cil.oc.common.tileentity.TileEntityComputer -import li.cil.oc.common.tileentity.TileEntityScreen +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 @@ -15,16 +15,16 @@ object GuiType extends Enumeration { object 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: TileEntityComputer => + 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: TileEntityComputer if id == GuiType.Computer.id => + case tileEntity: Computer if id == GuiType.Computer.id => new gui.Computer(player.inventory, tileEntity) - case tileEntity: TileEntityScreen if id == GuiType.Screen.id => + case tileEntity: Screen if id == GuiType.Screen.id => new gui.Screen(tileEntity) case _ => null } diff --git a/li/cil/oc/common/Proxy.scala b/li/cil/oc/common/Proxy.scala index 891edbf98..d2802eb9e 100644 --- a/li/cil/oc/common/Proxy.scala +++ b/li/cil/oc/common/Proxy.scala @@ -3,14 +3,12 @@ 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.api.Driver -import li.cil.oc.api.Network -import li.cil.oc.server.driver -import li.cil.oc.server.driver.Registry -import li.cil.oc.server.network -import net.minecraftforge.common.MinecraftForge +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 = { @@ -19,8 +17,8 @@ class Proxy { LanguageRegistry.instance.loadLocalization( "/assets/opencomputers/lang/en_US.lang", "en_US", false) - Driver.registry = Some(driver.Registry) - Network.network = Some(network.Network) + api.Driver.registry = Some(driver.Registry) + api.Network.network = Some(network.Network) } def init(e: FMLInitializationEvent): Unit = { @@ -29,11 +27,11 @@ class Proxy { NetworkRegistry.instance.registerGuiHandler(OpenComputers, GuiHandler) - Driver.add(driver.GraphicsCard) - Driver.add(driver.Keyboard) - Driver.add(driver.Memory) - Driver.add(driver.Redstone) - Driver.add(driver.Disk) + 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) @@ -43,6 +41,6 @@ class Proxy { // 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. - Registry.locked = true + driver.Registry.locked = true } } \ No newline at end of file diff --git a/li/cil/oc/common/block/Computer.scala b/li/cil/oc/common/block/Computer.scala index fe4382bb6..401d340ba 100644 --- a/li/cil/oc/common/block/Computer.scala +++ b/li/cil/oc/common/block/Computer.scala @@ -3,7 +3,7 @@ package li.cil.oc.common.block import cpw.mods.fml.common.registry.GameRegistry import li.cil.oc.OpenComputers import li.cil.oc.common.GuiType -import li.cil.oc.common.tileentity.TileEntityComputer +import li.cil.oc.common.tileentity import net.minecraft.client.renderer.texture.IconRegister import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.Icon @@ -12,7 +12,7 @@ import net.minecraft.world.World import net.minecraftforge.common.ForgeDirection class Computer(val parent: Delegator) extends Delegate { - GameRegistry.registerTileEntity(classOf[TileEntityComputer], "oc.computer") + GameRegistry.registerTileEntity(classOf[tileentity.Computer], "oc.computer") val unlocalizedName = "Computer" @@ -27,7 +27,7 @@ class Computer(val parent: Delegator) extends Delegate { override def getBlockTextureFromSide(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) = { getIcon(localSide, world.getBlockTileEntity(x, y, z) match { - case computer: TileEntityComputer => computer.isOn + case computer: tileentity.Computer => computer.isOn case _ => false }) } @@ -35,7 +35,7 @@ class Computer(val parent: Delegator) extends Delegate { override def icon(side: ForgeDirection) = getIcon(side, isOn = false) private def getIcon(side: ForgeDirection, isOn: Boolean) = - if (isOn) Icons.on(side.ordinal) else Icons.off(side.ordinal) + Some(if (isOn) Icons.on(side.ordinal) else Icons.off(side.ordinal)) override def registerIcons(iconRegister: IconRegister) = { Icons.off(ForgeDirection.DOWN.ordinal) = iconRegister.registerIcon("opencomputers:computer_top") @@ -61,14 +61,14 @@ class Computer(val parent: Delegator) extends Delegate { override def hasTileEntity = true - override def createTileEntity(world: World, metadata: Int) = new TileEntityComputer(world.isRemote) + override def createTileEntity(world: World, metadata: Int) = Some(new tileentity.Computer(world.isRemote)) // ----------------------------------------------------------------------- // // Destruction / Interaction // ----------------------------------------------------------------------- // override def breakBlock(world: World, x: Int, y: Int, z: Int, blockId: Int, metadata: Int) = { - world.getBlockTileEntity(x, y, z).asInstanceOf[TileEntityComputer].turnOff() + world.getBlockTileEntity(x, y, z).asInstanceOf[tileentity.Computer].turnOff() super.breakBlock(world, x, y, z, blockId, metadata) } @@ -76,7 +76,7 @@ class Computer(val parent: Delegator) extends Delegate { side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = { if (!player.isSneaking) { // Start the computer if it isn't already running and open the GUI. - world.getBlockTileEntity(x, y, z).asInstanceOf[TileEntityComputer].turnOn() + world.getBlockTileEntity(x, y, z).asInstanceOf[tileentity.Computer].turnOn() player.openGui(OpenComputers, GuiType.Computer.id, world, x, y, z) true } diff --git a/li/cil/oc/common/block/Delegate.scala b/li/cil/oc/common/block/Delegate.scala index 38c479284..7986b8087 100644 --- a/li/cil/oc/common/block/Delegate.scala +++ b/li/cil/oc/common/block/Delegate.scala @@ -29,14 +29,14 @@ trait Delegate { def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false - def createTileEntity(world: World, metadata: Int): TileEntity = null + def createTileEntity(world: World, metadata: Int): Option[TileEntity] = None - def getBlockTextureFromSide(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection): Icon = icon(localSide) + def getBlockTextureFromSide(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection): Option[Icon] = icon(localSide) def getCollisionBoundingBoxFromPool(world: World, x: Int, y: Int, z: Int) = AxisAlignedBB.getAABBPool.getAABB(x, y, z, x + 1, y + 1, z + 1) - def icon(side: ForgeDirection): Icon = null + def icon(side: ForgeDirection): Option[Icon] = None def getLightOpacity(world: World, x: Int, y: Int, z: Int) = 255 diff --git a/li/cil/oc/common/block/Delegator.scala b/li/cil/oc/common/block/Delegator.scala index 310994207..11a58d719 100644 --- a/li/cil/oc/common/block/Delegator.scala +++ b/li/cil/oc/common/block/Delegator.scala @@ -6,7 +6,7 @@ import li.cil.oc.Config import li.cil.oc.CreativeTab import li.cil.oc.api.Network import li.cil.oc.api.network.Node -import li.cil.oc.common.tileentity.TileEntityRotatable +import li.cil.oc.common.tileentity.Rotatable import net.minecraft.block.Block import net.minecraft.block.material.Material import net.minecraft.client.renderer.texture.IconRegister @@ -41,7 +41,7 @@ import scala.collection.mutable class Delegator(id: Int) extends Block(id, Material.iron) { setHardness(2f) setCreativeTab(CreativeTab) - GameRegistry.registerBlock(this, classOf[ItemBlockMulti], "oc.block." + id) + GameRegistry.registerBlock(this, classOf[Item], "oc.block." + id) // ----------------------------------------------------------------------- // // SubBlock @@ -71,27 +71,27 @@ class Delegator(id: Int) extends Block(id, Material.iron) { def getFacing(world: IBlockAccess, x: Int, y: Int, z: Int) = world.getBlockTileEntity(x, y, z) match { - case tileEntity: TileEntityRotatable => tileEntity.facing + case tileEntity: Rotatable => tileEntity.facing case _ => ForgeDirection.UNKNOWN } def setFacing(world: World, x: Int, y: Int, z: Int, value: ForgeDirection) = world.getBlockTileEntity(x, y, z) match { - case rotatable: TileEntityRotatable => + case rotatable: Rotatable => rotatable.setFromFacing(value); true case _ => false } def setRotationFromEntityPitchAndYaw(world: World, x: Int, y: Int, z: Int, value: Entity) = world.getBlockTileEntity(x, y, z) match { - case rotatable: TileEntityRotatable => + case rotatable: Rotatable => rotatable.setFromEntityPitchAndYaw(value); true case _ => false } private def toLocal(world: IBlockAccess, x: Int, y: Int, z: Int, value: ForgeDirection) = world.getBlockTileEntity(x, y, z) match { - case rotatable: TileEntityRotatable => rotatable.translate(value) + case rotatable: Rotatable => rotatable.translate(value) case _ => value } @@ -128,7 +128,7 @@ class Delegator(id: Int) extends Block(id, Material.iron) { override def createTileEntity(world: World, metadata: Int): TileEntity = subBlock(metadata) match { case None => null - case Some(subBlock) => subBlock.createTileEntity(world, metadata) + case Some(subBlock) => subBlock.createTileEntity(world, metadata).orNull } override def getCollisionBoundingBoxFromPool(world: World, x: Int, y: Int, z: Int) = @@ -143,8 +143,8 @@ class Delegator(id: Int) extends Block(id, Material.iron) { case None => super.getBlockTexture(world, x, y, z, side) case Some(subBlock) => subBlock.getBlockTextureFromSide( world, x, y, z, ForgeDirection.getOrientation(side), toLocal(world, x, y, z, ForgeDirection.getOrientation(side))) match { - case null => super.getBlockTexture(world, x, y, z, side) - case icon => icon + case None => super.getBlockTexture(world, x, y, z, side) + case Some(icon) => icon } } @@ -152,8 +152,8 @@ class Delegator(id: Int) extends Block(id, Material.iron) { subBlock(metadata) match { case None => super.getIcon(side, metadata) case Some(subBlock) => subBlock.icon(ForgeDirection.getOrientation(side)) match { - case null => super.getIcon(side, metadata) - case icon => icon + case None => super.getIcon(side, metadata) + case Some(icon) => icon } } @@ -166,7 +166,7 @@ class Delegator(id: Int) extends Block(id, Material.iron) { override def getRenderType = Config.blockRenderId override def getSubBlocks(itemId: Int, creativeTab: CreativeTabs, list: util.List[_]) = { - // Workaround for MC's untyped lists... I'm too tired to rage anymore. + // Workaround for MC's untyped lists... def add[T](list: util.List[T], value: Any) = list.add(value.asInstanceOf[T]) (0 until subBlocks.length). foreach(id => add(list, new ItemStack(this, 1, id))) @@ -225,7 +225,7 @@ class Delegator(id: Int) extends Block(id, Material.iron) { val valid = getValidRotations(world, x, y, z) if (valid.length > 1 && canWrench) world.getBlockTileEntity(x, y, z) match { - case rotatable: TileEntityRotatable => { + case rotatable: Rotatable => { if (player.isSneaking) { // Rotate pitch. Get the valid pitch rotations. val validPitch = valid.collect { diff --git a/li/cil/oc/common/block/ItemBlockMulti.scala b/li/cil/oc/common/block/Item.scala similarity index 88% rename from li/cil/oc/common/block/ItemBlockMulti.scala rename to li/cil/oc/common/block/Item.scala index 46a51a59b..7ee4e6067 100644 --- a/li/cil/oc/common/block/ItemBlockMulti.scala +++ b/li/cil/oc/common/block/Item.scala @@ -1,6 +1,6 @@ package li.cil.oc.common.block -import li.cil.oc.common.tileentity.TileEntityRotatable +import li.cil.oc.common.tileentity.Rotatable import net.minecraft.block.Block import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemBlock @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack import net.minecraft.world.World /** Used to represent multiblocks when in item form. */ -class ItemBlockMulti(id: Int) extends ItemBlock(id) { +class Item(id: Int) extends ItemBlock(id) { setHasSubtypes(true) override def getMetadata(itemDamage: Int) = itemDamage @@ -27,7 +27,7 @@ class ItemBlockMulti(id: Int) extends ItemBlock(id) { if (super.placeBlockAt(item, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) { // If it's a rotatable block try to make it face the player. world.getBlockTileEntity(x, y, z) match { - case rotatable: TileEntityRotatable => + case rotatable: Rotatable => rotatable.setFromEntityPitchAndYaw(player).invertRotation() } true diff --git a/li/cil/oc/common/block/Keyboard.scala b/li/cil/oc/common/block/Keyboard.scala index 2520c4b21..88be2e424 100644 --- a/li/cil/oc/common/block/Keyboard.scala +++ b/li/cil/oc/common/block/Keyboard.scala @@ -1,12 +1,12 @@ package li.cil.oc.common.block import cpw.mods.fml.common.registry.GameRegistry -import li.cil.oc.common.tileentity.TileEntityKeyboard +import li.cil.oc.common.tileentity import net.minecraft.world.World import net.minecraftforge.common.ForgeDirection class Keyboard(val parent: Delegator) extends Delegate { - GameRegistry.registerTileEntity(classOf[TileEntityKeyboard], "oc.keyboard") + GameRegistry.registerTileEntity(classOf[tileentity.Keyboard], "oc.keyboard") val unlocalizedName = "Keyboard" @@ -16,7 +16,7 @@ class Keyboard(val parent: Delegator) extends Delegate { override def hasTileEntity = true - override def createTileEntity(world: World, metadata: Int) = new TileEntityKeyboard + override def createTileEntity(world: World, metadata: Int) = Some(new tileentity.Keyboard) // ----------------------------------------------------------------------- // // Block rotation diff --git a/li/cil/oc/common/block/Screen.scala b/li/cil/oc/common/block/Screen.scala index 9e4e2f3b5..6469dd347 100644 --- a/li/cil/oc/common/block/Screen.scala +++ b/li/cil/oc/common/block/Screen.scala @@ -3,7 +3,7 @@ package li.cil.oc.common.block import cpw.mods.fml.common.registry.GameRegistry import li.cil.oc.OpenComputers import li.cil.oc.common.GuiType -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity import net.minecraft.client.renderer.texture.IconRegister import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.Icon @@ -12,7 +12,7 @@ import net.minecraft.world.World import net.minecraftforge.common.ForgeDirection class Screen(val parent: Delegator) extends Delegate { - GameRegistry.registerTileEntity(classOf[TileEntityScreen], "oc.screen") + GameRegistry.registerTileEntity(classOf[tileentity.Screen], "oc.screen") val unlocalizedName = "Screen" @@ -29,17 +29,17 @@ class Screen(val parent: Delegator) extends Delegate { override def getBlockTextureFromSide(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) = { worldSide match { case f if f == parent.getFacing(world, x, y, z) => icon(ForgeDirection.SOUTH) - case ForgeDirection.DOWN | ForgeDirection.UP => Icons.top - case _ => Icons.side + case ForgeDirection.DOWN | ForgeDirection.UP => Some(Icons.top) + case _ => Some(Icons.side) } } override def icon(side: ForgeDirection) = - side match { + Some(side match { case ForgeDirection.SOUTH => Icons.front case ForgeDirection.DOWN | ForgeDirection.UP => Icons.top case _ => Icons.side - } + }) override def registerIcons(iconRegister: IconRegister) = { Icons.front = iconRegister.registerIcon("opencomputers:screen_front") @@ -53,7 +53,7 @@ class Screen(val parent: Delegator) extends Delegate { override def hasTileEntity = true - override def createTileEntity(world: World, metadata: Int) = new TileEntityScreen + override def createTileEntity(world: World, metadata: Int) = Some(new tileentity.Screen) // ----------------------------------------------------------------------- // // Interaction diff --git a/li/cil/oc/common/block/SpecialMulti.scala b/li/cil/oc/common/block/SpecialDelegator.scala similarity index 95% rename from li/cil/oc/common/block/SpecialMulti.scala rename to li/cil/oc/common/block/SpecialDelegator.scala index a4fc3bfb3..53d02d575 100644 --- a/li/cil/oc/common/block/SpecialMulti.scala +++ b/li/cil/oc/common/block/SpecialDelegator.scala @@ -6,7 +6,7 @@ import net.minecraft.world.World import net.minecraftforge.common.ForgeDirection /** Used for sub blocks that need special rendering. */ -class SpecialMulti(id: Int) extends Delegator(id) { +class SpecialDelegator(id: Int) extends Delegator(id) { override def getRenderType = Config.blockRenderId override def isBlockNormalCube(world: World, x: Int, y: Int, z: Int) = diff --git a/li/cil/oc/common/container/Computer.scala b/li/cil/oc/common/container/Computer.scala index b4e90f803..22b2d4f96 100644 --- a/li/cil/oc/common/container/Computer.scala +++ b/li/cil/oc/common/container/Computer.scala @@ -1,11 +1,11 @@ package li.cil.oc.common.container -import li.cil.oc.common.tileentity.TileEntityComputer +import li.cil.oc.common.tileentity import net.minecraft.entity.player.InventoryPlayer import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack -class Computer(playerInventory: InventoryPlayer, computer: TileEntityComputer) extends Player(playerInventory, computer) { +class Computer(playerInventory: InventoryPlayer, computer: tileentity.Computer) extends Player(playerInventory, computer) { // PSU addSlotToContainer(new Slot(computer, 0, 58, 17) { override def isItemValid(item: ItemStack) = { diff --git a/li/cil/oc/common/item/Delegate.scala b/li/cil/oc/common/item/Delegate.scala index fd779ef4d..ac6e0fb40 100644 --- a/li/cil/oc/common/item/Delegate.scala +++ b/li/cil/oc/common/item/Delegate.scala @@ -17,7 +17,7 @@ trait Delegate { // Item // ----------------------------------------------------------------------- // - def icon: Icon = null + def icon: Option[Icon] = None def onItemRightClick(item: ItemStack, world: World, player: EntityPlayer): ItemStack = item diff --git a/li/cil/oc/common/item/Delegator.scala b/li/cil/oc/common/item/Delegator.scala index 9699a1463..f7c699223 100644 --- a/li/cil/oc/common/item/Delegator.scala +++ b/li/cil/oc/common/item/Delegator.scala @@ -49,8 +49,8 @@ class Delegator(id: Int) extends Item(id) { subItem(damage) match { case None => super.getIconFromDamage(damage) case Some(subItem) => subItem.icon match { - case null => super.getIconFromDamage(damage) - case icon => icon + case None => super.getIconFromDamage(damage) + case Some(icon) => icon } } diff --git a/li/cil/oc/common/tileentity/ItemComponentProxy.scala b/li/cil/oc/common/tileentity/ComponentInventory.scala similarity index 96% rename from li/cil/oc/common/tileentity/ItemComponentProxy.scala rename to li/cil/oc/common/tileentity/ComponentInventory.scala index 354d44702..4a514c387 100644 --- a/li/cil/oc/common/tileentity/ItemComponentProxy.scala +++ b/li/cil/oc/common/tileentity/ComponentInventory.scala @@ -1,19 +1,19 @@ package li.cil.oc.common.tileentity +import li.cil.oc.api.driver.Slot import li.cil.oc.api.network.Node +import li.cil.oc.common.component +import li.cil.oc.server.driver.Registry import net.minecraft.inventory.IInventory import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagList import net.minecraft.world.World -import li.cil.oc.api.driver.Slot -import li.cil.oc.common.component.Computer -import li.cil.oc.server.driver.Registry -trait ItemComponentProxy extends IInventory with Node { +trait ComponentInventory extends IInventory with Node { protected val inventory = new Array[ItemStack](8) - protected val computer: Computer + protected val computer: component.Computer def world: World diff --git a/li/cil/oc/common/tileentity/TileEntityComputer.scala b/li/cil/oc/common/tileentity/Computer.scala similarity index 91% rename from li/cil/oc/common/tileentity/TileEntityComputer.scala rename to li/cil/oc/common/tileentity/Computer.scala index ce23529f1..ee5538bb2 100644 --- a/li/cil/oc/common/tileentity/TileEntityComputer.scala +++ b/li/cil/oc/common/tileentity/Computer.scala @@ -2,20 +2,22 @@ package li.cil.oc.common.tileentity import java.util.concurrent.atomic.AtomicBoolean import li.cil.oc.api.network.Message -import li.cil.oc.client.computer.{Computer => ClientComputer} +import li.cil.oc.client.component.{Computer => ClientComputer} import li.cil.oc.client.{PacketSender => ClientPacketSender} -import li.cil.oc.server.component.{Computer, RedstoneEnabled} +import li.cil.oc.server.component.Computer.{Environment => ComputerEnvironment} +import li.cil.oc.server.component.RedstoneEnabled +import li.cil.oc.server.component.{Computer => ServerComputer} import li.cil.oc.server.{PacketSender => ServerPacketSender} import net.minecraft.entity.player.EntityPlayer import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.ForgeDirection -class TileEntityComputer(isClient: Boolean) extends TileEntityRotatable with Computer.Environment with ItemComponentProxy with RedstoneEnabled { +class Computer(isClient: Boolean) extends Rotatable with ComputerEnvironment with ComponentInventory with RedstoneEnabled { def this() = this(false) protected val computer = if (isClient) new ClientComputer(this) - else new Computer(this) + else new ServerComputer(this) private val hasChanged = new AtomicBoolean(true) diff --git a/li/cil/oc/common/tileentity/TileEntityKeyboard.scala b/li/cil/oc/common/tileentity/Keyboard.scala similarity index 96% rename from li/cil/oc/common/tileentity/TileEntityKeyboard.scala rename to li/cil/oc/common/tileentity/Keyboard.scala index 38a5b24e1..adba1b30d 100644 --- a/li/cil/oc/common/tileentity/TileEntityKeyboard.scala +++ b/li/cil/oc/common/tileentity/Keyboard.scala @@ -5,7 +5,7 @@ import li.cil.oc.api.network.{Visibility, Node, Message} import net.minecraft.entity.player.EntityPlayer import net.minecraft.nbt.NBTTagCompound -class TileEntityKeyboard extends TileEntityRotatable with Node { +class Keyboard extends Rotatable with Node { override def name = "keyboard" override def visibility = Visibility.Network diff --git a/li/cil/oc/common/tileentity/TileEntityRotatable.scala b/li/cil/oc/common/tileentity/Rotatable.scala similarity index 99% rename from li/cil/oc/common/tileentity/TileEntityRotatable.scala rename to li/cil/oc/common/tileentity/Rotatable.scala index 2720305a3..16330efa7 100644 --- a/li/cil/oc/common/tileentity/TileEntityRotatable.scala +++ b/li/cil/oc/common/tileentity/Rotatable.scala @@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity import net.minecraftforge.common.ForgeDirection /** TileEntity base class for rotatable blocks. */ -abstract class TileEntityRotatable extends TileEntity { +abstract class Rotatable extends TileEntity { // ----------------------------------------------------------------------- // // Lookup tables // ----------------------------------------------------------------------- // diff --git a/li/cil/oc/common/tileentity/TileEntityScreen.scala b/li/cil/oc/common/tileentity/Screen.scala similarity index 87% rename from li/cil/oc/common/tileentity/TileEntityScreen.scala rename to li/cil/oc/common/tileentity/Screen.scala index 25d52f2a2..bd42770d0 100644 --- a/li/cil/oc/common/tileentity/TileEntityScreen.scala +++ b/li/cil/oc/common/tileentity/Screen.scala @@ -1,13 +1,13 @@ package li.cil.oc.common.tileentity -import li.cil.oc.client.gui.Screen +import li.cil.oc.client.gui import li.cil.oc.client.{PacketSender => ClientPacketSender} import li.cil.oc.common.component.ScreenEnvironment import li.cil.oc.server.{PacketSender => ServerPacketSender} import net.minecraft.nbt.NBTTagCompound -class TileEntityScreen extends TileEntityRotatable with ScreenEnvironment { - var gui: Option[Screen] = None +class Screen extends Rotatable with ScreenEnvironment { + var guiScreen: Option[gui.Screen] = None override def readFromNBT(nbt: NBTTagCompound) = { super.readFromNBT(nbt) @@ -35,7 +35,7 @@ class TileEntityScreen extends TileEntityRotatable with ScreenEnvironment { override def onScreenResolutionChange(w: Int, h: Int) = { super.onScreenResolutionChange(w, h) if (worldObj.isRemote) { - gui.foreach(_.setSize(w, h)) + guiScreen.foreach(_.setSize(w, h)) } else { markAsChanged() @@ -46,7 +46,7 @@ class TileEntityScreen extends TileEntityRotatable with ScreenEnvironment { override def onScreenSet(col: Int, row: Int, s: String) = { super.onScreenSet(col, row, s) if (worldObj.isRemote) { - gui.foreach(_.updateText()) + guiScreen.foreach(_.updateText()) } else { markAsChanged() @@ -57,7 +57,7 @@ class TileEntityScreen extends TileEntityRotatable with ScreenEnvironment { override def onScreenFill(col: Int, row: Int, w: Int, h: Int, c: Char) = { super.onScreenFill(col, row, w, h, c) if (worldObj.isRemote) { - gui.foreach(_.updateText()) + guiScreen.foreach(_.updateText()) } else { markAsChanged() @@ -68,7 +68,7 @@ class TileEntityScreen extends TileEntityRotatable with ScreenEnvironment { override def onScreenCopy(col: Int, row: Int, w: Int, h: Int, tx: Int, ty: Int) = { super.onScreenCopy(col, row, w, h, tx, ty) if (worldObj.isRemote) { - gui.foreach(_.updateText()) + guiScreen.foreach(_.updateText()) } else { markAsChanged() diff --git a/li/cil/oc/server/PacketHandler.scala b/li/cil/oc/server/PacketHandler.scala index 1a8e4f001..c9bdb7ec0 100644 --- a/li/cil/oc/server/PacketHandler.scala +++ b/li/cil/oc/server/PacketHandler.scala @@ -4,9 +4,9 @@ import cpw.mods.fml.common.network.Player import li.cil.oc.api.network.Node import li.cil.oc.common.PacketBuilder import li.cil.oc.common.PacketType -import li.cil.oc.common.tileentity.TileEntityComputer -import li.cil.oc.common.tileentity.TileEntityRotatable -import li.cil.oc.common.tileentity.TileEntityScreen +import li.cil.oc.common.tileentity.Computer +import li.cil.oc.common.tileentity.Rotatable +import li.cil.oc.common.tileentity.Screen import li.cil.oc.common.{PacketHandler => CommonPacketHandler} import net.minecraftforge.common.DimensionManager @@ -26,7 +26,7 @@ class PacketHandler extends CommonPacketHandler { } def onScreenBufferRequest(p: PacketParser) = - p.readTileEntity[TileEntityScreen]() match { + p.readTileEntity[Screen]() match { case None => // Invalid packet. case Some(t) => { val pb = new PacketBuilder(PacketType.ScreenBufferResponse) @@ -39,7 +39,7 @@ class PacketHandler extends CommonPacketHandler { } def onComputerStateRequest(p: PacketParser) = - p.readTileEntity[TileEntityComputer]() match { + p.readTileEntity[Computer]() match { case None => // Invalid packet. case Some(t) => { val pb = new PacketBuilder(PacketType.ComputerStateResponse) @@ -52,7 +52,7 @@ class PacketHandler extends CommonPacketHandler { } def onRotatableStateRequest(p: PacketParser) = - p.readTileEntity[TileEntityRotatable]() match { + p.readTileEntity[Rotatable]() match { case None => // Invalid packet. case Some(t) => { val pb = new PacketBuilder(PacketType.RotatableStateResponse) diff --git a/li/cil/oc/server/PacketSender.scala b/li/cil/oc/server/PacketSender.scala index 369f6f534..0010c987d 100644 --- a/li/cil/oc/server/PacketSender.scala +++ b/li/cil/oc/server/PacketSender.scala @@ -2,7 +2,7 @@ package li.cil.oc.server import li.cil.oc.common.PacketBuilder import li.cil.oc.common.PacketType -import li.cil.oc.common.tileentity.TileEntityRotatable +import li.cil.oc.common.tileentity.Rotatable import net.minecraft.tileentity.TileEntity import net.minecraftforge.common.ForgeDirection @@ -65,7 +65,7 @@ object PacketSender { pb.sendToAllPlayers() } - def sendRotatableRotate(t: TileEntityRotatable, pitch: ForgeDirection, yaw: ForgeDirection) = { + def sendRotatableRotate(t: Rotatable, pitch: ForgeDirection, yaw: ForgeDirection) = { val pb = new PacketBuilder(PacketType.RotatableStateResponse) pb.writeTileEntity(t) diff --git a/li/cil/oc/server/component/Computer.scala b/li/cil/oc/server/component/Computer.scala index 5b6eab363..53d445cb2 100644 --- a/li/cil/oc/server/component/Computer.scala +++ b/li/cil/oc/server/component/Computer.scala @@ -1,15 +1,15 @@ package li.cil.oc.server.component -import com.naef.jnlua._ +import com.naef.jnlua.{LuaRuntimeException, LuaMemoryAllocationException, LuaType, LuaState} import java.lang.Thread.UncaughtExceptionHandler import java.util.concurrent._ import java.util.concurrent.atomic.AtomicInteger import java.util.logging.Level import li.cil.oc.api.network.{Visibility, Node} import li.cil.oc.common.component -import li.cil.oc.common.tileentity.TileEntityComputer +import li.cil.oc.common.tileentity import li.cil.oc.server.driver -import li.cil.oc.util.ExtendedLuaState._ +import li.cil.oc.util.ExtendedLuaState.extendLuaState import li.cil.oc.util.LuaStateFactory import li.cil.oc.{OpenComputers, Config} import net.minecraft.nbt._ @@ -191,11 +191,11 @@ class Computer(val owner: Computer.Environment) extends component.Computer with // Check if we should switch states. stateMonitor.synchronized(state match { // Resume from pauses based on signal underflow. - case Computer.State.Suspended if signals.nonEmpty => { + case Computer.State.Suspended if !signals.isEmpty => { assert(future.isEmpty) execute(Computer.State.Yielded) } - case Computer.State.Sleeping if lastUpdate >= sleepUntil || signals.nonEmpty => { + case Computer.State.Sleeping if lastUpdate >= sleepUntil || !signals.isEmpty => { assert(future.isEmpty) execute(Computer.State.Yielded) } @@ -793,8 +793,8 @@ object Computer { private def onUnload(w: World, tileEntities: Iterable[TileEntity]) = if (!w.isRemote) { tileEntities. - filter(_.isInstanceOf[TileEntityComputer]). - map(_.asInstanceOf[TileEntityComputer]). + filter(_.isInstanceOf[tileentity.Computer]). + map(_.asInstanceOf[tileentity.Computer]). foreach(_.turnOff()) } diff --git a/li/cil/oc/util/ExtendedLuaState.scala b/li/cil/oc/util/ExtendedLuaState.scala index 98b11d96f..b09f9944e 100644 --- a/li/cil/oc/util/ExtendedLuaState.scala +++ b/li/cil/oc/util/ExtendedLuaState.scala @@ -2,16 +2,10 @@ package li.cil.oc.util import com.naef.jnlua.{JavaFunction, LuaState} -class ExtendedLuaState(val state: LuaState) { - def pushScalaFunction(f: (LuaState) => Int) = state.pushJavaFunction(new ExtendedLuaState.ScalaFunction(f)) -} - object ExtendedLuaState { - - implicit def extendLuaState(lua: LuaState) = new ExtendedLuaState(lua) - - private class ScalaFunction(val f: (LuaState) => Int) extends JavaFunction { - override def invoke(state: LuaState) = f(state) + implicit def extendLuaState(state: LuaState) = new { + def pushScalaFunction(f: (LuaState) => Int) = state.pushJavaFunction(new JavaFunction { + override def invoke(state: LuaState) = f(state) + }) } - } \ No newline at end of file