From 279f87a2b944c1e822bea5ce28d4a250cee6f0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 10 Feb 2015 02:26:21 +0100 Subject: [PATCH 1/4] Fixed cables having a chance to not yielding outputs when being disassembled. --- src/main/scala/li/cil/oc/util/ItemUtils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/util/ItemUtils.scala b/src/main/scala/li/cil/oc/util/ItemUtils.scala index 0645f7a37..ddb37eda9 100644 --- a/src/main/scala/li/cil/oc/util/ItemUtils.scala +++ b/src/main/scala/li/cil/oc/util/ItemUtils.scala @@ -76,7 +76,7 @@ object ItemUtils { // Split items up again to 'disassemble them individually'. val distinct = mutable.ArrayBuffer.empty[ItemStack] for (ingredient <- merged) { - val size = ingredient.stackSize + val size = ingredient.stackSize max 1 ingredient.stackSize = 1 for (i <- 0 until size) { distinct += ingredient.copy() From c05b4fc3d6a0365427ebb6a14269cba89b20e8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 10 Feb 2015 02:27:34 +0100 Subject: [PATCH 2/4] Fixed potential NPE in MCU tooltip. --- src/main/scala/li/cil/oc/common/block/Microcontroller.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/common/block/Microcontroller.scala b/src/main/scala/li/cil/oc/common/block/Microcontroller.scala index 8b7631a1b..7397115b3 100644 --- a/src/main/scala/li/cil/oc/common/block/Microcontroller.scala +++ b/src/main/scala/li/cil/oc/common/block/Microcontroller.scala @@ -47,7 +47,7 @@ class Microcontroller(protected implicit val tileTag: ClassTag[tileentity.Microc super.tooltipTail(metadata, stack, player, tooltip, advanced) if (KeyBindings.showExtendedTooltips) { val info = new MicrocontrollerData(stack) - for (component <- info.components) { + for (component <- info.components if component != null) { tooltip.add("- " + component.getDisplayName) } } From 66763c3317771b0ac2f0a915a6caff9cf3cd3a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 10 Feb 2015 02:28:16 +0100 Subject: [PATCH 3/4] Fixed robot inventory slot range. --- src/main/scala/li/cil/oc/common/tileentity/Robot.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala index e9b920f95..31f0db864 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala @@ -127,7 +127,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand override def isUseableByPlayer(player: EntityPlayer) = Robot.this.isUseableByPlayer(player) } - val actualInventorySize = 86 + val actualInventorySize = 100 def maxInventorySize = actualInventorySize - equipmentInventory.getSizeInventory - componentCount @@ -179,7 +179,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand def componentSlots = getSizeInventory - componentCount until getSizeInventory - def inventorySlots = 0 until inventorySize + def inventorySlots: Range = equipmentInventory.getSizeInventory until (equipmentInventory.getSizeInventory + mainInventory.getSizeInventory) def setLightColor(value: Int): Unit = { info.lightColor = value @@ -725,7 +725,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand } else super.setInventorySlotContents(slot, stack) } - else if (stack != null && stack.stackSize > 0) spawnStackInWorld(stack, Option(ForgeDirection.UP)) + else if (stack != null && stack.stackSize > 0 && !world.isRemote) spawnStackInWorld(stack, Option(ForgeDirection.UP)) } override def isUseableByPlayer(player: EntityPlayer) = From 43edfefa6eda29125e8891139c9f91428f45c6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 10 Feb 2015 02:32:55 +0100 Subject: [PATCH 4/4] Potential rendering improvements (mostly stuff discovered while porting to 1.8 that didn't seem to have an effect in 1.7, but can't hurt to clean up). --- src/main/scala/li/cil/oc/client/gui/Assembler.scala | 2 +- src/main/scala/li/cil/oc/client/gui/Disassembler.scala | 1 - src/main/scala/li/cil/oc/client/gui/Drone.scala | 10 +--------- .../li/cil/oc/client/gui/DynamicGuiContainer.scala | 5 +++++ src/main/scala/li/cil/oc/client/gui/Raid.scala | 1 - src/main/scala/li/cil/oc/client/gui/Robot.scala | 10 +--------- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/main/scala/li/cil/oc/client/gui/Assembler.scala b/src/main/scala/li/cil/oc/client/gui/Assembler.scala index 5e280ef7c..a92a1e042 100644 --- a/src/main/scala/li/cil/oc/client/gui/Assembler.scala +++ b/src/main/scala/li/cil/oc/client/gui/Assembler.scala @@ -101,12 +101,12 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { GL11.glColor3f(1, 1, 1) // Required under Linux. - super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY) mc.renderEngine.bindTexture(Textures.guiRobotAssembler) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) if (assemblerContainer.isAssembling) progress.level = assemblerContainer.assemblyProgress / 100.0 else progress.level = 0 drawWidgets() + drawInventorySlots() } override protected def drawDisabledSlot(slot: ComponentSlot) {} diff --git a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala index 7eb1fe59d..93bb8ebdd 100644 --- a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala +++ b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala @@ -21,7 +21,6 @@ class Disassembler(playerInventory: InventoryPlayer, val disassembler: tileentit override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { GL11.glColor3f(1, 1, 1) // Required under Linux. - super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY) mc.renderEngine.bindTexture(Textures.guiDisassembler) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) progress.level = disassemblerContainer.disassemblyProgress / 100.0 diff --git a/src/main/scala/li/cil/oc/client/gui/Drone.scala b/src/main/scala/li/cil/oc/client/gui/Drone.scala index 1baae4c6b..bc5c81f9c 100644 --- a/src/main/scala/li/cil/oc/client/gui/Drone.scala +++ b/src/main/scala/li/cil/oc/client/gui/Drone.scala @@ -17,7 +17,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer -import net.minecraft.inventory.Slot import org.lwjgl.opengl.GL11 class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends DynamicGuiContainer(new container.Drone(playerInventory, drone)) with traits.DisplayBuffer { @@ -117,14 +116,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D drawSelection() } - GL11.glPushMatrix() - GL11.glTranslatef(guiLeft, guiTop, 0) - for (slot <- 0 until inventorySlots.inventorySlots.size()) { - drawSlotInventory(inventorySlots.inventorySlots.get(slot).asInstanceOf[Slot]) - } - GL11.glPopMatrix() - - RenderState.makeItBlend() + drawInventorySlots() } protected override def drawGradientRect(par1: Int, par2: Int, par3: Int, par4: Int, par5: Int, par6: Int) { 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 8e7c76a71..e60106ab8 100644 --- a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala +++ b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala @@ -55,12 +55,17 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai RenderState.makeItBlend() GL11.glDisable(GL11.GL_LIGHTING) + drawInventorySlots() + } + + protected def drawInventorySlots(): Unit = { GL11.glPushMatrix() GL11.glTranslatef(guiLeft, guiTop, 0) for (slot <- 0 until inventorySlots.inventorySlots.size()) { drawSlotInventory(inventorySlots.inventorySlots.get(slot).asInstanceOf[Slot]) } GL11.glPopMatrix() + RenderState.makeItBlend() } override def drawScreen(mouseX: Int, mouseY: Int, dt: Float) { diff --git a/src/main/scala/li/cil/oc/client/gui/Raid.scala b/src/main/scala/li/cil/oc/client/gui/Raid.scala index 03693687e..91f1ecf1e 100644 --- a/src/main/scala/li/cil/oc/client/gui/Raid.scala +++ b/src/main/scala/li/cil/oc/client/gui/Raid.scala @@ -21,7 +21,6 @@ class Raid(playerInventory: InventoryPlayer, val raid: tileentity.Raid) extends override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { GL11.glColor3f(1, 1, 1) // Required under Linux. - super.drawGuiContainerBackgroundLayer(dt, mouseX, mouseY) mc.renderEngine.bindTexture(Textures.guiRaid) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } 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 6c8244959..4d43867e1 100644 --- a/src/main/scala/li/cil/oc/client/gui/Robot.scala +++ b/src/main/scala/li/cil/oc/client/gui/Robot.scala @@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer -import net.minecraft.inventory.Slot import org.lwjgl.input.Keyboard import org.lwjgl.input.Mouse import org.lwjgl.opengl.GL11 @@ -159,14 +158,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten drawSelection() } - GL11.glPushMatrix() - GL11.glTranslatef(guiLeft, guiTop, 0) - for (slot <- 0 until inventorySlots.inventorySlots.size()) { - drawSlotInventory(inventorySlots.inventorySlots.get(slot).asInstanceOf[Slot]) - } - GL11.glPopMatrix() - - RenderState.makeItBlend() + drawInventorySlots() } protected override def drawGradientRect(par1: Int, par2: Int, par3: Int, par4: Int, par5: Int, par6: Int) {