Skip to content

Commit 809d2a4

Browse files
committedJul 18, 2016
Merge branch 'jei-relay-gui-handler' of https://github.com/Vexatos/OpenComputers into master-MC1.9.4
# Conflicts: # src/main/scala/li/cil/oc/integration/jei/ModPluginOpenComputers.scala

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed
 

Diff for: ‎src/main/scala/li/cil/oc/client/gui/Relay.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.lwjgl.util.Rectangle
2727
class Relay(playerInventory: InventoryPlayer, val relay: tileentity.Relay) extends DynamicGuiContainer(new container.Relay(playerInventory, relay)) with INEIGuiHandler {
2828
private val format = new DecimalFormat("#.##hz")
2929

30-
private val tabPosition = new Rectangle(xSize, 10, 23, 26)
30+
val tabPosition = new Rectangle(xSize, 10, 23, 26)
3131

3232
override protected def drawSecondaryBackgroundLayer(): Unit = {
3333
super.drawSecondaryBackgroundLayer()

Diff for: ‎src/main/scala/li/cil/oc/integration/jei/ModPluginOpenComputers.scala

+1-28
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,7 @@ class ModPluginOpenComputers extends IModPlugin {
3535
registry.addRecipeHandlers(CallbackDocHandler.CallbackDocRecipeHandler)
3636
registry.addRecipes(CallbackDocHandler.getRecipes(registry))
3737

38-
def useNBT(names: String*) = names.map(name => {
39-
val info = Items.get(name)
40-
Option(info.item).getOrElse(Item.getItemFromBlock(info.block))
41-
}).filter(_ != null).distinct.foreach(registry.getJeiHelpers.getSubtypeRegistry.useNbtForSubtypes(_))
42-
43-
// Only the preconfigured blocks and items have to be here.
44-
useNBT(
45-
Constants.BlockName.Microcontroller,
46-
Constants.BlockName.Robot,
47-
48-
Constants.ItemName.Drone,
49-
Constants.ItemName.Tablet
50-
)
51-
52-
registry.getJeiHelpers.getSubtypeRegistry.registerNbtInterpreter(Items.get(Constants.ItemName.Floppy).item(), new ISubtypeInterpreter {
53-
override def getSubtypeInfo(stack: ItemStack): String = {
54-
if (!stack.hasTagCompound) return null
55-
val compound: NBTTagCompound = stack.getTagCompound
56-
val data = new NBTTagCompound
57-
// Separate loot disks from normal floppies
58-
if (compound.hasKey(Settings.namespace + "lootFactory")) {
59-
data.setTag(Settings.namespace + "lootFactory", compound.getTag(Settings.namespace + "lootFactory"))
60-
}
61-
if (data.hasNoTags) null else data.toString
62-
}
63-
})
38+
registry.addAdvancedGuiHandlers(RelayGuiHandler)
6439
}
6540

6641
private var stackUnderMouse: (GuiContainer, Int, Int) => Option[ItemStack] = null
@@ -70,7 +45,5 @@ class ModPluginOpenComputers extends IModPlugin {
7045
ItemSearch.stackFocusing += ((container, mouseX, mouseY) => stackUnderMouse(container, mouseX, mouseY))
7146
}
7247
stackUnderMouse = (container, mouseX, mouseY) => Option(jeiRuntime.getItemListOverlay.getStackUnderMouse)
73-
74-
// TODO check for focused input
7548
}
7649
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package li.cil.oc.integration.jei
2+
3+
import java.awt.Rectangle
4+
import java.util
5+
6+
import li.cil.oc.client.gui.Relay
7+
import mezz.jei.api.gui.IAdvancedGuiHandler
8+
9+
import scala.collection.convert.WrapAsJava._
10+
11+
object RelayGuiHandler extends IAdvancedGuiHandler[Relay] {
12+
13+
override def getGuiContainerClass: Class[Relay] = classOf[Relay]
14+
15+
override def getGuiExtraAreas(gui: Relay): util.List[Rectangle] = List(
16+
new Rectangle(gui.windowX + gui.tabPosition.getX, gui.windowY + gui.tabPosition.getY, gui.tabPosition.getWidth, gui.tabPosition.getHeight)
17+
)
18+
}

0 commit comments

Comments
 (0)
Please sign in to comment.