From 7e80b27e7032472db2432abc37500a0ebb8ebce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 7 Nov 2015 09:11:25 +0100 Subject: [PATCH] Started work on new rack GUI. --- .../opencomputers/textures/gui/rack.png | Bin 0 -> 1049 bytes .../li/cil/oc/client/PacketHandler.scala | 4 +- .../scala/li/cil/oc/client/Textures.scala | 1 + .../scala/li/cil/oc/client/gui/Rack.scala | 187 +++++++++++++++--- .../li/cil/oc/common/PacketBuilder.scala | 2 +- .../li/cil/oc/common/PacketHandler.scala | 16 +- .../li/cil/oc/common/container/Rack.scala | 39 ++-- .../common/inventory/ItemStackInventory.scala | 29 +-- .../li/cil/oc/common/tileentity/Rack.scala | 19 +- .../opencomputers/DriverServer.scala | 8 + .../opencomputers/ModOpenComputers.scala | 1 + .../li/cil/oc/server/component/Server.scala | 5 +- 12 files changed, 237 insertions(+), 74 deletions(-) create mode 100644 src/main/resources/assets/opencomputers/textures/gui/rack.png diff --git a/src/main/resources/assets/opencomputers/textures/gui/rack.png b/src/main/resources/assets/opencomputers/textures/gui/rack.png new file mode 100644 index 0000000000000000000000000000000000000000..7b046c181e3acacb55b76cb21f71d8f5023ef75c GIT binary patch literal 1049 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5FjO4;u=vBoS#-wo>-L1;Fyx1 zl&avFo0y&&l$w}QS$Hzl2B^q8z$e7@$dMx*9UcGw|2H-^28sm)1T;6@DBXMT#Hsk( zwWW0@<8^g)`}-$^hKAm`^I_2vzpShcZ{A$F`SR6=+c(n}`)y83xc%lz!pylq6OL*` zi-7G8@(TuXu>uB06RzzH49xbPE{-7;x8B^jT{PQ3gf)QKuV&%PzlZ+UXQpnIFhA!U zz2wNJ$m9A_{%JyCDup+W9f#_ zJ-DD6IZYCNPOD#_B6wpMvtG}3m;a_{h#`B{rvWq<>wEV z1X}S27u)d%PYx1)P`ply;qK;F+)O=38K#*n&}=9&e&D=Ls@g%Bp;#&8pH2Y(g5R?5 z#TkE0S$*tkf^CCV?Ey8d1KVRvnI^h1ymC$IWvDq>YQ?_In7M1)A#b&5t3(^_>=m=( zt~q=4nvg_UvSmZn%miiQ2i5DoF&vA1nBBO+c!6ufqO}Fx481N%cfX$XG;(B^$e@+h z6dLt#nqRZ!kS7AH9fgZzSrh2t!MGV)?J?`JK-paVnPH^AWa<~kPv6OLL{sf?eiqkZh5S(^UQW4z5 z0_VaQLJLJ1_L*}qH01YrwSEQVL1X|74J{pE7KR7YUcG#|(&oSx-*vqqvJIKH1spy; twrBLYU6!?qNnjVU7NXb>^j - for (slot <- 0 until t.getSizeInventory) { + val count = p.readInt() + for (_ <- 0 until count) { + val slot = p.readInt() t.setInventorySlotContents(slot, p.readItemStack()) } case _ => // Invalid packet. diff --git a/src/main/scala/li/cil/oc/client/Textures.scala b/src/main/scala/li/cil/oc/client/Textures.scala index a207fba72..121076371 100644 --- a/src/main/scala/li/cil/oc/client/Textures.scala +++ b/src/main/scala/li/cil/oc/client/Textures.scala @@ -35,6 +35,7 @@ object Textures { val guiPrinterInk = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_ink.png") val guiPrinterMaterial = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_material.png") val guiPrinterProgress = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_progress.png") + val guiRack = new ResourceLocation(Settings.resourceDomain, "textures/gui/rack.png") val guiRaid = new ResourceLocation(Settings.resourceDomain, "textures/gui/raid.png") val guiRange = new ResourceLocation(Settings.resourceDomain, "textures/gui/range.png") val guiRobot = new ResourceLocation(Settings.resourceDomain, "textures/gui/robot.png") diff --git a/src/main/scala/li/cil/oc/client/gui/Rack.scala b/src/main/scala/li/cil/oc/client/gui/Rack.scala index 97cd5b824..f7ca5a27a 100644 --- a/src/main/scala/li/cil/oc/client/gui/Rack.scala +++ b/src/main/scala/li/cil/oc/client/gui/Rack.scala @@ -10,14 +10,72 @@ import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer +import net.minecraft.util.ResourceLocation import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 import scala.collection.convert.WrapAsJava._ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends DynamicGuiContainer(new container.Rack(playerInventory, rack)) { -// protected var switchButton: ImageButton = _ -// + ySize = 210 + + final val busSlaveBlankUVs = (195, 1, 3, 4) + final val busSlavePresentUVs = (194, 6, 5, 4) + final val busMasterBlankUVs = (195, 14, 3, 5) + final val busMasterPresentUVs = (194, 20, 5, 5) + + final val connectorSlaveUVs = (194, 11, 1, 2) + final val hoverSlaveUVs = (196, 11, 3, 2) + final val connectorMasterUVs = (194, 26, 1, 3) + final val hoverMasterUVs = (196, 26, 3, 3) + + final val wireSlaveUVs = Array( + (186, 1, 6, 2), + (186, 4, 6, 2), + (186, 7, 6, 2), + (186, 10, 6, 2), + (186, 13, 6, 2) + ) + final val wireMasterUVs = Array( + (186, 16, 6, 3), + (186, 20, 6, 3), + (186, 24, 6, 3), + (186, 28, 6, 3), + (186, 32, 6, 3) + ) + + final val busStart = Array( + (45, 22), + (56, 22), + (67, 22), + (78, 22), + (89, 22) + ) + + final val busGap = 3 + + final val connectorStart = Array( + (37, 23), + (37, 43), + (37, 63), + (37, 83) + ) + + final val connectorGap = 2 + + final val relayModeUVs = (195, 30, 4, 2) + + final val wireRelay = Array( + (50, 104), + (61, 104), + (72, 104), + (83, 104) + ) + + var switchButton: ImageButton = _ + + var wireButtons = Array.fill(5)(Array.fill(rack.getSizeInventory * 4)(null: ImageButton)) + // protected var powerButtons = new Array[ImageButton](4) // // protected var sideButtons = new Array[GuiButton](4) @@ -64,18 +122,18 @@ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends // ClientPacketSender.sendServerSwitchMode(rack, !rack.internalSwitch) // } // } -// -// override def drawScreen(mouseX: Int, mouseY: Int, dt: Float) { + + override def drawScreen(mouseX: Int, mouseY: Int, dt: Float) { // for (i <- 0 to 3) { // powerButtons(i).toggled = rack.isRunning(i) // sideButtons(i).displayString = sideName(i) // } -// switchButton.displayString = if (rack.internalSwitch) Localization.ServerRack.SwitchInternal else Localization.ServerRack.SwitchExternal -// super.drawScreen(mouseX, mouseY, dt) -// } -// -// override def initGui() { -// super.initGui() + switchButton.displayString = if (rack.isRelayEnabled) Localization.ServerRack.SwitchInternal else Localization.ServerRack.SwitchExternal + super.drawScreen(mouseX, mouseY, dt) + } + + override def initGui() { + super.initGui() // for (i <- 0 to 3) { // powerButtons(i) = new ImageButton(i, guiLeft + 84, guiTop + 7 + i * 18, 18, 18, Textures.guiButtonPower, canToggle = true) // add(buttonList, powerButtons(i)) @@ -88,17 +146,17 @@ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends // rangeButtons(i) = new ImageButton(8 + i, guiLeft + 8 + i * 48, guiTop + 50, 16, 18, Textures.guiButtonRange, if (i == 0) "-" else "+") // add(buttonList, rangeButtons(i)) // } -// switchButton = new ImageButton(10, guiLeft + 8, guiTop + 17, 64, 18, Textures.guiButtonSwitch, Localization.ServerRack.SwitchExternal, textIndent = 18) -// add(buttonList, switchButton) -// } -// -// override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = { -// super.drawSecondaryForegroundLayer(mouseX, mouseY) -// GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Prevents NEI render glitch. -// -// fontRendererObj.drawString( -// Localization.localizeImmediately(rack.getInventoryName), -// 8, 6, 0x404040) + switchButton = new ImageButton(0, guiLeft + 101, guiTop + 96, 65, 18, Textures.guiButtonSwitch, Localization.ServerRack.SwitchExternal, textIndent = 18) + add(buttonList, switchButton) + } + + override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = { + super.drawSecondaryForegroundLayer(mouseX, mouseY) + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Prevents NEI render glitch. + + fontRendererObj.drawString( + Localization.localizeImmediately(rack.getInventoryName), + 8, 6, 0x404040) // // val rangeY = 39 // fontRendererObj.drawString(Localization.ServerRack.WirelessRange, 8, rangeY, 0x404040) @@ -132,6 +190,89 @@ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends // copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) // } // -// GL11.glPopAttrib() -// } + + GL11.glColor3f(1, 1, 1) + mc.renderEngine.bindTexture(Textures.guiRack) + + if (rack.isRelayEnabled) { + val (left, top, w, h) = relayModeUVs + for ((x, y) <- wireRelay) { + drawRect(x, y, w, h, left, top) + } + } + + val (mcx, mcy, mcw, mch) = connectorMasterUVs + val (mbx, mby, mbw, mbh) = busMasterBlankUVs + val (mpx, mpy, mpw, mph) = busMasterPresentUVs + val (scx, scy, scw, sch) = connectorSlaveUVs + val (sbx, sby, sbw, sbh) = busSlaveBlankUVs + val (spx, spy, spw, sph) = busSlavePresentUVs + for (mountable <- 0 until rack.getSizeInventory) { + val presence = inventoryContainer.nodePresence(mountable) + + // Draw connectable indicators next to item slots. + val (cx, cy) = connectorStart(mountable) + if (presence(0)) { + drawRect(cx, cy, mcw, mch, mcx, mcy) + } + for (connectable <- 1 until 4) { + if (presence(connectable)) { + drawRect(cx, cy + (mch + connectorGap) + (sch + connectorGap) * (connectable - 1), scw, sch, scx, scy) + } + } + + // Draw connection points on buses. + val offset = mountable * (mbh + sbh * 3 + busGap) + for (bus <- 0 until 5) { + val (bx, by) = busStart(bus) + if (presence(0)) { + drawRect(bx - 1, by + offset, mpw, mph, mpx, mpy) + } + else { + drawRect(bx, by + offset, mbw, mbh, mbx, mby) + } + for (connectable <- 0 until 3) { + if (presence(connectable + 1)) { + drawRect(bx - 1, by + offset + mph + sph * connectable, spw, sph, spx, spy) + } + else { + drawRect(bx, by + offset + mbh + sbh * connectable, sbw, sbh, sbx, sby) + } + } + } + + // Draw active connections. + } + + for (bus <- 0 until 5) { + val x = 122 + val y = 20 + bus * 11 + + fontRendererObj.drawString( + Localization.localizeImmediately("TODO"), + x, y, 0x404040) + } + + GL11.glPopAttrib() + } + + override def drawSecondaryBackgroundLayer() { + GL11.glColor3f(1, 1, 1) // Required under Linux. + mc.renderEngine.bindTexture(Textures.guiRack) + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) + } + + private def drawRect(x: Int, y: Int, w: Int, h: Int, u: Int, v: Int): Unit = { + val u0 = u / 256f + val v0 = v / 256f + val u1 = u0 + w / 256f + val v1 = v0 + h / 256f + val t = Tessellator.instance + t.startDrawingQuads() + t.addVertexWithUV(x, y, windowZ, u0, v0) + t.addVertexWithUV(x, y + h, windowZ, u0, v1) + t.addVertexWithUV(x + w, y + h, windowZ, u1, v1) + t.addVertexWithUV(x + w, y, windowZ, u1, v0) + t.draw() + } } diff --git a/src/main/scala/li/cil/oc/common/PacketBuilder.scala b/src/main/scala/li/cil/oc/common/PacketBuilder.scala index c7fb29b0b..fdf758298 100644 --- a/src/main/scala/li/cil/oc/common/PacketBuilder.scala +++ b/src/main/scala/li/cil/oc/common/PacketBuilder.scala @@ -47,7 +47,7 @@ abstract class PacketBuilder(stream: OutputStream) extends DataOutputStream(stre } } - def writeNBT(nbt: NBTTagCompound) = CompressedStreamTools.writeCompressed(nbt, this) + def writeNBT(nbt: NBTTagCompound) = CompressedStreamTools.write(nbt, this) def writePacketType(pt: PacketType.Value) = writeByte(pt.id) diff --git a/src/main/scala/li/cil/oc/common/PacketHandler.scala b/src/main/scala/li/cil/oc/common/PacketHandler.scala index 5bb0f0f4d..ed4044884 100644 --- a/src/main/scala/li/cil/oc/common/PacketHandler.scala +++ b/src/main/scala/li/cil/oc/common/PacketHandler.scala @@ -1,5 +1,6 @@ package li.cil.oc.common +import java.io.BufferedInputStream import java.io.DataInputStream import java.io.InputStream import java.util.zip.GZIPInputStream @@ -13,6 +14,7 @@ import li.cil.oc.common.block.RobotAfterimage import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.nbt.CompressedStreamTools +import net.minecraft.nbt.NBTSizeTracker import net.minecraft.world.World import net.minecraftforge.common.util.ForgeDirection @@ -36,12 +38,12 @@ abstract class PacketHandler { } /** - * Gets the world for the specified dimension. - * - * For clients this returns the client's world if it is the specified - * dimension; None otherwise. For the server it returns the world for the - * specified dimension, if such a dimension exists; None otherwise. - */ + * Gets the world for the specified dimension. + * + * For clients this returns the client's world if it is the specified + * dimension; None otherwise. For the server it returns the world for the + * specified dimension, if such a dimension exists; None otherwise. + */ protected def world(player: EntityPlayer, dimension: Int): Option[World] protected def dispatch(p: PacketParser): Unit @@ -111,7 +113,7 @@ abstract class PacketHandler { else null } - def readNBT() = CompressedStreamTools.readCompressed(this) + def readNBT() = CompressedStreamTools.read(this) def readPacketType() = PacketType(readByte()) } diff --git a/src/main/scala/li/cil/oc/common/container/Rack.scala b/src/main/scala/li/cil/oc/common/container/Rack.scala index f09e157e2..20c500362 100644 --- a/src/main/scala/li/cil/oc/common/container/Rack.scala +++ b/src/main/scala/li/cil/oc/common/container/Rack.scala @@ -1,5 +1,6 @@ package li.cil.oc.common.container +import li.cil.oc.api.component.RackMountable import li.cil.oc.common.Slot import li.cil.oc.common.tileentity import li.cil.oc.util.ExtendedNBT._ @@ -9,27 +10,35 @@ import net.minecraft.nbt.NBTTagIntArray import net.minecraftforge.common.util.Constants.NBT import net.minecraftforge.common.util.ForgeDirection -class Rack(playerInventory: InventoryPlayer, rack: tileentity.Rack) extends Player(playerInventory, rack) { - addSlotToContainer(106, 8, Slot.RackMountable) - addSlotToContainer(106, 26, Slot.RackMountable) - addSlotToContainer(106, 44, Slot.RackMountable) - addSlotToContainer(106, 62, Slot.RackMountable) - addPlayerInventorySlots(8, 84) +class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends Player(playerInventory, rack) { + addSlotToContainer(20, 23, Slot.RackMountable) + addSlotToContainer(20, 43, Slot.RackMountable) + addSlotToContainer(20, 63, Slot.RackMountable) + addSlotToContainer(20, 83, Slot.RackMountable) + addPlayerInventorySlots(8, 128) + + final val MaxConnections = 4 + val nodePresence = Array.fill(4)(Array.fill(4)(false)) override def updateCustomData(nbt: NBTTagCompound): Unit = { super.updateCustomData(nbt) - nbt.setNewTagList("nodeMapping", rack.nodeMapping.map(sides => toNbt(sides.map { - case Some(side) => side.ordinal() - case _ => -1 - }))) - nbt.setBoolean("isRelayEnabled", rack.isRelayEnabled) + nbt.getTagList("nodeMapping", NBT.TAG_INT_ARRAY).map((sides: NBTTagIntArray) => { + sides.func_150302_c().map(side => if (side >= 0) Option(ForgeDirection.getOrientation(side)) else None) + }).copyToArray(rack.nodeMapping) + nbt.getBooleanArray("nodePresence").grouped(MaxConnections).copyToArray(nodePresence) + rack.isRelayEnabled = nbt.getBoolean("isRelayEnabled") } override protected def detectCustomDataChanges(nbt: NBTTagCompound): Unit = { super.detectCustomDataChanges(nbt) - nbt.getTagList("nodeMapping", NBT.TAG_INT_ARRAY).map((sides: NBTTagIntArray) => { - sides.func_150302_c().map(side => if (side >= 0) Option(ForgeDirection.getOrientation(side)) else None) - }).copyToArray(rack.nodeMapping) - rack.isRelayEnabled = nbt.getBoolean("isRelayEnabled") + nbt.setNewTagList("nodeMapping", rack.nodeMapping.map(sides => toNbt(sides.map { + case Some(side) => side.ordinal() + case _ => -1 + }))) + nbt.setBooleanArray("nodePresence", (0 until rack.getSizeInventory).flatMap(slot => rack.getMountable(slot) match { + case mountable: RackMountable => (Seq(true) ++ (0 until math.min(MaxConnections - 1, mountable.getConnectableCount)).map(index => mountable.getConnectableAt(index) != null)).padTo(MaxConnections, false) + case _ => Array.fill(MaxConnections)(false) + }).toArray) + nbt.setBoolean("isRelayEnabled", rack.isRelayEnabled) } } diff --git a/src/main/scala/li/cil/oc/common/inventory/ItemStackInventory.scala b/src/main/scala/li/cil/oc/common/inventory/ItemStackInventory.scala index 45eea13dc..891840b13 100644 --- a/src/main/scala/li/cil/oc/common/inventory/ItemStackInventory.scala +++ b/src/main/scala/li/cil/oc/common/inventory/ItemStackInventory.scala @@ -1,10 +1,7 @@ package li.cil.oc.common.inventory -import li.cil.oc.Settings import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import net.minecraft.nbt.NBTTagList -import net.minecraftforge.common.util.Constants.NBT trait ItemStackInventory extends Inventory { // The item stack that provides the inventory. @@ -21,34 +18,20 @@ trait ItemStackInventory extends Inventory { // Load items from tag. def reinitialize() { - if (!container.hasTagCompound) { - container.setTagCompound(new NBTTagCompound()) - } for (i <- items.indices) { updateItems(i, null) } - if (container.getTagCompound.hasKey(Settings.namespace + "items")) { - val list = container.getTagCompound.getTagList(Settings.namespace + "items", NBT.TAG_COMPOUND) - for (i <- 0 until (list.tagCount min items.length)) { - val tag = list.getCompoundTagAt(i) - if (!tag.hasNoTags) { - updateItems(i, ItemStack.loadItemStackFromNBT(tag)) - } - } + if (!container.hasTagCompound) { + container.setTagCompound(new NBTTagCompound()) } + load(container.getTagCompound) } // Write items back to tag. override def markDirty() { - val list = new NBTTagList() - for (i <- items.indices) { - val tag = new NBTTagCompound() - items(i) match { - case Some(stack) => stack.writeToNBT(tag) - case _ => - } - list.appendTag(tag) + if (!container.hasTagCompound) { + container.setTagCompound(new NBTTagCompound()) } - container.getTagCompound.setTag(Settings.namespace + "items", list) + save(container.getTagCompound) } } diff --git a/src/main/scala/li/cil/oc/common/tileentity/Rack.scala b/src/main/scala/li/cil/oc/common/tileentity/Rack.scala index 665632d2d..ce2b5113a 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Rack.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Rack.scala @@ -202,7 +202,7 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance override def getInventoryStackLimit = 1 override def isItemValidForSlot(slot: Int, stack: ItemStack): Boolean = (slot, Option(Driver.driverFor(stack, getClass))) match { - case (0, Some(driver)) => driver.slot(stack) == Slot.RackMountable + case (_, Some(driver)) => driver.slot(stack) == Slot.RackMountable case _ => false } @@ -218,6 +218,23 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance } } + // ----------------------------------------------------------------------- // + // ComponentInventory + + override protected def onItemAdded(slot: Int, stack: ItemStack): Unit = { + // Reset mappings when adding an item. + for (connectable <- 0 until 4) { + nodeMapping(slot)(connectable) = None + } + super.onItemAdded(slot, stack) + } + + override protected def connectItemNode(node: Node): Unit = { + // By default create a new network for mountables. They have to + // be wired up manually (mapping is reset in onItemAdded). + api.Network.joinNewNetwork(node) + } + // ----------------------------------------------------------------------- // // TileEntity diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/DriverServer.scala b/src/main/scala/li/cil/oc/integration/opencomputers/DriverServer.scala index ba7c51761..263b27318 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/DriverServer.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/DriverServer.scala @@ -10,6 +10,7 @@ import li.cil.oc.common.tileentity import li.cil.oc.server.component import li.cil.oc.util.ExtendedInventory._ import net.minecraft.item.ItemStack +import net.minecraft.nbt.NBTTagCompound object DriverServer extends Item with HostAware { override def worksWith(stack: ItemStack): Boolean = isOneOf(stack, @@ -24,4 +25,11 @@ object DriverServer extends Item with HostAware { } override def slot(stack: ItemStack): String = Slot.RackMountable + + override def dataTag(stack: ItemStack): NBTTagCompound = { + if (!stack.hasTagCompound) { + stack.setTagCompound(new NBTTagCompound()) + } + stack.getTagCompound + } } diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala index e749a1f1d..a477c2853 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala @@ -115,6 +115,7 @@ object ModOpenComputers extends ModProxy { api.Driver.add(DriverNetworkCard) api.Driver.add(DriverKeyboard) api.Driver.add(DriverRedstoneCard) + api.Driver.add(DriverServer) api.Driver.add(DriverTablet) api.Driver.add(DriverWirelessNetworkCard) diff --git a/src/main/scala/li/cil/oc/server/component/Server.scala b/src/main/scala/li/cil/oc/server/component/Server.scala index ea1b77288..b4a405cbb 100644 --- a/src/main/scala/li/cil/oc/server/component/Server.scala +++ b/src/main/scala/li/cil/oc/server/component/Server.scala @@ -5,12 +5,11 @@ import java.util import li.cil.oc.OpenComputers import li.cil.oc.api -import li.cil.oc.api import li.cil.oc.api.Machine import li.cil.oc.api.StateAware +import li.cil.oc.api.StateAware.State import li.cil.oc.api.component.RackBusConnectable import li.cil.oc.api.internal -import StateAware.State import li.cil.oc.api.machine.MachineHost import li.cil.oc.api.network.Analyzable import li.cil.oc.api.network.Environment @@ -30,7 +29,7 @@ import net.minecraft.nbt.NBTTagCompound import scala.collection.convert.WrapAsJava._ class Server(val rack: tileentity.Rack, val slot: Int) extends Environment with MachineHost with ServerInventory with ComponentInventory with Analyzable with internal.Server { - val machine = Machine.create(this) + lazy val machine = Machine.create(this) val node = machine.node