From 7f877d63e1343a51273015088e713e4c900c53f6 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 14 May 2014 13:46:02 +0100 Subject: [PATCH 1/4] Updated irc.lua; change the output of required.... args to make the fact that you need a nickname more prominent --- src/main/resources/assets/opencomputers/loot/OpenIRC/irc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenIRC/irc.lua b/src/main/resources/assets/opencomputers/loot/OpenIRC/irc.lua index d9f5cd151..7358396eb 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenIRC/irc.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenIRC/irc.lua @@ -17,7 +17,7 @@ local text = require("text") local args, options = shell.parse(...) if #args < 1 then - print("Usage: irc nickname [server:port]") + print("Usage: irc [server:port]") return end @@ -457,4 +457,4 @@ end if not result then error(reason, 0) end -return reason \ No newline at end of file +return reason From 365475e2c5f23770e0d55d07fb793014c0a60346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 16 May 2014 00:03:29 +0200 Subject: [PATCH 2/4] Properly handling conversion of tables with null keys or values. Closes #254. --- src/main/scala/li/cil/oc/server/driver/Registry.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/server/driver/Registry.scala b/src/main/scala/li/cil/oc/server/driver/Registry.scala index c9ce341a9..9c9b27875 100644 --- a/src/main/scala/li/cil/oc/server/driver/Registry.scala +++ b/src/main/scala/li/cil/oc/server/driver/Registry.scala @@ -90,10 +90,10 @@ private[oc] object Registry extends api.detail.DriverAPI { case arg: Array[_] => arg.map { case (value: AnyRef) => convertRecursively(value) } - case arg: Map[_, _] => arg.map { + case arg: Map[_, _] => arg.collect { case (key: AnyRef, value: AnyRef) => convertRecursively(key) -> convertRecursively(value) } - case arg: java.util.Map[_, _] => arg.map { + case arg: java.util.Map[_, _] => arg.collect { case (key: AnyRef, value: AnyRef) => convertRecursively(key) -> convertRecursively(value) } From 2e649a3f4419bb800520d3c2bb0acbc4c901d933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 16 May 2014 00:42:24 +0200 Subject: [PATCH 3/4] Workaround for TMI screwing with the GuiContainer class. Should fix #251. --- .../scala/li/cil/oc/client/gui/Case.scala | 2 +- .../oc/client/gui/CustomGuiContainer.scala | 72 +++++++++++++++++++ .../oc/client/gui/DynamicGuiContainer.scala | 3 +- .../scala/li/cil/oc/client/gui/Rack.scala | 2 +- .../scala/li/cil/oc/client/gui/Robot.scala | 7 +- 5 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala diff --git a/src/main/scala/li/cil/oc/client/gui/Case.scala b/src/main/scala/li/cil/oc/client/gui/Case.scala index 60746dc36..1813ecd42 100644 --- a/src/main/scala/li/cil/oc/client/gui/Case.scala +++ b/src/main/scala/li/cil/oc/client/gui/Case.scala @@ -42,7 +42,7 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte val tooltip = new java.util.ArrayList[String] val which = if (computer.isRunning) "gui.Robot.TurnOff" else "gui.Robot.TurnOn" tooltip.add(StatCollector.translateToLocal(Settings.namespace + which)) - drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) + copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) } GL11.glPopAttrib() } diff --git a/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala b/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala new file mode 100644 index 000000000..bdf79e665 --- /dev/null +++ b/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala @@ -0,0 +1,72 @@ +package li.cil.oc.client.gui + +import net.minecraft.client.gui.inventory.GuiContainer +import java.util +import net.minecraft.client.gui.FontRenderer +import org.lwjgl.opengl.{GL12, GL11} +import net.minecraft.client.renderer.RenderHelper +import scala.collection.convert.WrapAsScala._ +import net.minecraft.inventory.Container + +// Workaround because certain other mods *cough*TMI*cough* do base class +// transformations that break things! Such fun. Many annoyed. And yes, this +// is a common issue, have a look at EnderIO and Enchanting Plus. They have +// to work around this, too. +abstract class CustomGuiContainer(container: Container) extends GuiContainer(container) { + // Pretty much Scalaified copy-pasta from base-class. + override def drawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) { + copiedDrawHoveringText(text, x, y, font) + } + + protected def copiedDrawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) { + if (!text.isEmpty) { + GL11.glDisable(GL12.GL_RESCALE_NORMAL) + RenderHelper.disableStandardItemLighting() + GL11.glDisable(GL11.GL_LIGHTING) + GL11.glDisable(GL11.GL_DEPTH_TEST) + + val textWidth = text.map(line => font.getStringWidth(line.asInstanceOf[String])).max + + var posX = x + 12 + var posY = y - 12 + var textHeight = 8 + if (text.size > 1) { + textHeight += 2 + (text.size - 1) * 10 + } + if (posX + textWidth > width) { + posX -= 28 + textWidth + } + if (posY + textHeight + 6 > height) { + posY = height - textHeight - 6 + } + + zLevel = 300f + val bg = 0xF0100010 + drawGradientRect(posX - 3, posY - 4, posX + textWidth + 3, posY - 3, bg, bg) + drawGradientRect(posX - 3, posY + textHeight + 3, posX + textWidth + 3, posY + textHeight + 4, bg, bg) + drawGradientRect(posX - 3, posY - 3, posX + textWidth + 3, posY + textHeight + 3, bg, bg) + drawGradientRect(posX - 4, posY - 3, posX - 3, posY + textHeight + 3, bg, bg) + drawGradientRect(posX + textWidth + 3, posY - 3, posX + textWidth + 4, posY + textHeight + 3, bg, bg) + val color1 = 0x505000FF + val color2 = 0x505000FE + drawGradientRect(posX - 3, posY - 3 + 1, posX - 3 + 1, posY + textHeight + 3 - 1, color1, color2) + drawGradientRect(posX + textWidth + 2, posY - 3 + 1, posX + textWidth + 3, posY + textHeight + 3 - 1, color1, color2) + drawGradientRect(posX - 3, posY - 3, posX + textWidth + 3, posY - 3 + 1, color1, color1) + drawGradientRect(posX - 3, posY + textHeight + 2, posX + textWidth + 3, posY + textHeight + 3, color2, color2) + + for ((line, index) <- text.zipWithIndex) { + font.drawStringWithShadow(line.asInstanceOf[String], posX, posY, -1) + if (index == 0) { + posY += 2 + } + posY += 10 + } + zLevel = 0f + + GL11.glEnable(GL11.GL_LIGHTING) + GL11.glEnable(GL11.GL_DEPTH_TEST) + RenderHelper.enableStandardItemLighting() + GL11.glEnable(GL12.GL_RESCALE_NORMAL) + } + } +} diff --git a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala index 56356b39e..8f15333d8 100644 --- a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala +++ b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala @@ -3,14 +3,13 @@ package li.cil.oc.client.gui import li.cil.oc.client.TexturePreloader import li.cil.oc.common.container.ComponentSlot import li.cil.oc.util.RenderState -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.texture.TextureMap import net.minecraft.inventory.{Container, Slot} import net.minecraft.util.StatCollector import org.lwjgl.opengl.GL11 -abstract class DynamicGuiContainer(container: Container) extends GuiContainer(container) { +abstract class DynamicGuiContainer(container: Container) extends CustomGuiContainer(container) { override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) { fontRenderer.drawString( StatCollector.translateToLocal("container.inventory"), 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 827660631..2330c0de2 100644 --- a/src/main/scala/li/cil/oc/client/gui/Rack.scala +++ b/src/main/scala/li/cil/oc/client/gui/Rack.scala @@ -122,7 +122,7 @@ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends val tooltip = new java.util.ArrayList[String] val which = if (rack.isRunning(i)) "gui.Robot.TurnOff" else "gui.Robot.TurnOn" tooltip.add(StatCollector.translateToLocal(Settings.namespace + which)) - drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) + copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) } GL11.glPopAttrib() diff --git a/src/main/scala/li/cil/oc/client/gui/Robot.scala b/src/main/scala/li/cil/oc/client/gui/Robot.scala index 43f9b790b..c250c0eb7 100644 --- a/src/main/scala/li/cil/oc/client/gui/Robot.scala +++ b/src/main/scala/li/cil/oc/client/gui/Robot.scala @@ -11,7 +11,6 @@ import li.cil.oc.common.tileentity import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.texture.TextureMap import net.minecraft.entity.player.InventoryPlayer @@ -20,7 +19,7 @@ import net.minecraft.util.StatCollector import org.lwjgl.input.Keyboard import org.lwjgl.opengl.GL11 -class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) extends GuiContainer(new container.Robot(playerInventory, robot)) with Buffer { +class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) extends CustomGuiContainer(new container.Robot(playerInventory, robot)) with Buffer { xSize = 256 ySize = 242 @@ -106,13 +105,13 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten ((robot.globalBuffer / robot.globalBufferSize) * 100).toInt, robot.globalBuffer.toInt, robot.globalBufferSize.toInt)) - drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) + copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) } if (powerButton.func_82252_a) { val tooltip = new java.util.ArrayList[String] val which = if (robot.isRunning) "gui.Robot.TurnOff" else "gui.Robot.TurnOn" tooltip.add(StatCollector.translateToLocal(Settings.namespace + which)) - drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) + copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRenderer) } GL11.glPopAttrib() } From a579a3792f251b8b40fc257fbdc34069940560e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 16 May 2014 00:48:51 +0200 Subject: [PATCH 4/4] Removed the bucket consumption in acid/grog crafting and bucket retrieval in PCB crafting. Kind of meh because the grog now is in a magical container that disappears instead of the bucket, logically speaking, but it avoids issues - in particular this closes #194. --- .../scala/li/cil/oc/CraftingHandler.scala | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/main/scala/li/cil/oc/CraftingHandler.scala b/src/main/scala/li/cil/oc/CraftingHandler.scala index d354480c6..6ba5ecc19 100644 --- a/src/main/scala/li/cil/oc/CraftingHandler.scala +++ b/src/main/scala/li/cil/oc/CraftingHandler.scala @@ -9,28 +9,6 @@ import net.minecraft.item.{ItemMap, Item, ItemStack} object CraftingHandler extends ICraftingHandler { override def onCrafting(player: EntityPlayer, craftedStack: ItemStack, inventory: IInventory) = { - if (craftedStack.isItemEqual(Items.acid.createItemStack())) { - for (i <- 0 until inventory.getSizeInventory) { - val stack = inventory.getStackInSlot(i) - if (stack != null && stack.getItem == Item.bucketWater) { - stack.stackSize = 0 - inventory.setInventorySlotContents(i, null) - } - } - } - - if (craftedStack.isItemEqual(Items.pcb.createItemStack())) { - for (i <- 0 until inventory.getSizeInventory) { - val stack = inventory.getStackInSlot(i) - if (stack != null && stack.isItemEqual(Items.acid.createItemStack())) { - val container = new ItemStack(Item.bucketEmpty, 1) - if (!player.inventory.addItemStackToInventory(container)) { - player.dropPlayerItem(container) - } - } - } - } - if (craftedStack.isItemEqual(Items.upgradeNavigation.createItemStack())) { Registry.itemDriverFor(craftedStack) match { case Some(driver) =>