mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge pull request #2135 from Vexatos/jei-update
Updated JEI integration.
This commit is contained in:
commit
b8de81f879
@ -1,6 +1,6 @@
|
||||
minecraft.version=1.10.2
|
||||
minecraft.mappings=snapshot_20160720
|
||||
forge.version=12.18.1.2014
|
||||
forge.version=12.18.2.2122
|
||||
|
||||
oc.version=1.6.0
|
||||
oc.subversion=dev
|
||||
@ -30,7 +30,7 @@ gc.version=3.0.7
|
||||
gt.version=5.04.06
|
||||
ic2.version=2.6.69-ex110
|
||||
igwmod.version=1.3.0-5
|
||||
jei.version=3.7.9.236
|
||||
jei.version=3.13.3.373
|
||||
mcmp.version=1.2.0_70
|
||||
mekanism.build=5
|
||||
mekanism.version=7.1.2
|
||||
|
@ -15,7 +15,7 @@
|
||||
"EnderStorage",
|
||||
"ForgeMultipart",
|
||||
"IC2",
|
||||
"JEI",
|
||||
"JEI@[3.13.3,)",
|
||||
"MineFactoryReloaded",
|
||||
"ProjRed|Transmission",
|
||||
"RedLogic",
|
||||
@ -25,4 +25,4 @@
|
||||
],
|
||||
"dependants": [],
|
||||
"useDependencyInformation": "true"
|
||||
}]
|
||||
}]
|
||||
|
@ -14,6 +14,7 @@ import mezz.jei.api.IGuiHelper
|
||||
import mezz.jei.api.IModRegistry
|
||||
import mezz.jei.api.gui.IDrawable
|
||||
import mezz.jei.api.gui.IRecipeLayout
|
||||
import mezz.jei.api.ingredients.IIngredients
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper
|
||||
import mezz.jei.api.recipe.IRecipeHandler
|
||||
@ -107,7 +108,9 @@ object CallbackDocHandler {
|
||||
|
||||
class CallbackDocRecipe(val stack: ItemStack, val page: String) extends BlankRecipeWrapper {
|
||||
|
||||
override def getInputs: util.List[_] = List(stack)
|
||||
override def getInputs: util.List[ItemStack] = List(stack)
|
||||
|
||||
override def getIngredients(ingredients: IIngredients): Unit = ingredients.setInputs(classOf[ItemStack], getInputs)
|
||||
|
||||
override def drawInfo(@Nonnull minecraft: Minecraft, recipeWidth: Int, recipeHeight: Int, mouseX: Int, mouseY: Int): Unit = {
|
||||
for ((text, line) <- page.lines.zipWithIndex) {
|
||||
@ -119,7 +122,7 @@ object CallbackDocHandler {
|
||||
object CallbackDocRecipeCategory extends BlankRecipeCategory[CallbackDocRecipe] {
|
||||
val recipeWidth: Int = 160
|
||||
val recipeHeight: Int = 125
|
||||
private var background: IDrawable = null
|
||||
private var background: IDrawable = _
|
||||
|
||||
def initialize(guiHelper: IGuiHelper) {
|
||||
background = guiHelper.createBlankDrawable(recipeWidth, recipeHeight)
|
||||
@ -130,6 +133,9 @@ object CallbackDocHandler {
|
||||
override def setRecipe(recipeLayout: IRecipeLayout, recipeWrapper: CallbackDocRecipe) {
|
||||
}
|
||||
|
||||
override def setRecipe(recipeLayout: IRecipeLayout, recipeWrapper: CallbackDocRecipe, ingredients: IIngredients) {
|
||||
}
|
||||
|
||||
override def getTitle = "OpenComputers API"
|
||||
|
||||
override def getUid = "oc.api"
|
||||
|
@ -6,6 +6,7 @@ import li.cil.oc.Constants
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.Loot
|
||||
import li.cil.oc.common.recipe.LootDiskCyclingRecipe
|
||||
import mezz.jei.api.ingredients.IIngredients
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper
|
||||
import mezz.jei.api.recipe.IRecipeHandler
|
||||
import mezz.jei.api.recipe.IRecipeWrapper
|
||||
@ -28,9 +29,14 @@ object LootDiskCyclingRecipeHandler extends IRecipeHandler[LootDiskCyclingRecipe
|
||||
|
||||
class LootDiskCyclingRecipeWrapper(val recipe: LootDiskCyclingRecipe) extends BlankRecipeWrapper with ICraftingRecipeWrapper {
|
||||
|
||||
override def getInputs: util.List[_] = List(seqAsJavaList(Loot.worldDisks.map(_._1)), api.Items.get(Constants.ItemName.Wrench).createItemStack(1))
|
||||
override def getInputs: util.List[util.List[ItemStack]] = List(seqAsJavaList(Loot.worldDisks.map(_._1)), seqAsJavaList(List(api.Items.get(Constants.ItemName.Wrench).createItemStack(1))))
|
||||
|
||||
override def getOutputs: util.List[ItemStack] = Loot.worldDisks.map(_._1).toList
|
||||
|
||||
override def getIngredients(ingredients: IIngredients): Unit = {
|
||||
ingredients.setInputLists(classOf[ItemStack], getInputs)
|
||||
ingredients.setOutputs(classOf[ItemStack], getOutputs)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import mezz.jei.api.IGuiHelper
|
||||
import mezz.jei.api.IModRegistry
|
||||
import mezz.jei.api.gui.IDrawable
|
||||
import mezz.jei.api.gui.IRecipeLayout
|
||||
import mezz.jei.api.ingredients.IIngredients
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper
|
||||
import mezz.jei.api.recipe.IRecipeHandler
|
||||
@ -43,7 +44,9 @@ object ManualUsageHandler {
|
||||
class ManualUsageRecipe(val stack: ItemStack, val path: String) extends BlankRecipeWrapper {
|
||||
lazy val button = new GuiButtonExt(0, (160 - 100) / 2, 10, 100, 20, Localization.localizeImmediately("nei.usage.oc.Manual"))
|
||||
|
||||
override def getInputs: util.List[_] = List(stack)
|
||||
override def getInputs: util.List[ItemStack] = List(stack)
|
||||
|
||||
override def getIngredients(ingredients: IIngredients): Unit = ingredients.setInputs(classOf[ItemStack], getInputs)
|
||||
|
||||
override def drawInfo(@Nonnull minecraft: Minecraft, recipeWidth: Int, recipeHeight: Int, mouseX: Int, mouseY: Int): Unit = {
|
||||
button.displayString = Localization.localizeImmediately("nei.usage.oc.Manual")
|
||||
@ -77,6 +80,9 @@ object ManualUsageHandler {
|
||||
override def setRecipe(recipeLayout: IRecipeLayout, recipeWrapper: ManualUsageRecipe) {
|
||||
}
|
||||
|
||||
override def setRecipe(recipeLayout: IRecipeLayout, recipeWrapper: ManualUsageRecipe, ingredients: IIngredients) {
|
||||
}
|
||||
|
||||
override def getTitle = "OpenComputers Manual"
|
||||
|
||||
override def getUid = "oc.manual"
|
||||
|
@ -8,8 +8,10 @@ import li.cil.oc.integration.util.ItemSearch
|
||||
import mezz.jei.api.IJeiRuntime
|
||||
import mezz.jei.api.IModPlugin
|
||||
import mezz.jei.api.IModRegistry
|
||||
import mezz.jei.api.ISubtypeRegistry
|
||||
import mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter
|
||||
import mezz.jei.api.JEIPlugin
|
||||
import mezz.jei.api.ingredients.IModIngredientRegistration
|
||||
import net.minecraft.client.gui.inventory.GuiContainer
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -35,10 +37,28 @@ class ModPluginOpenComputers extends IModPlugin {
|
||||
registry.addRecipeHandlers(CallbackDocHandler.CallbackDocRecipeHandler)
|
||||
registry.addRecipes(CallbackDocHandler.getRecipes(registry))
|
||||
|
||||
registry.addAdvancedGuiHandlers(RelayGuiHandler)
|
||||
}
|
||||
|
||||
private var stackUnderMouse: (GuiContainer, Int, Int) => Option[ItemStack] = _
|
||||
|
||||
override def onRuntimeAvailable(jeiRuntime: IJeiRuntime) {
|
||||
if (stackUnderMouse == null) {
|
||||
ItemSearch.stackFocusing += ((container, mouseX, mouseY) => stackUnderMouse(container, mouseX, mouseY))
|
||||
}
|
||||
stackUnderMouse = (container, mouseX, mouseY) => Option(jeiRuntime.getItemListOverlay.getStackUnderMouse)
|
||||
|
||||
ModJEI.runtime = Option(jeiRuntime)
|
||||
}
|
||||
|
||||
override def registerIngredients(registry: IModIngredientRegistration) {
|
||||
}
|
||||
|
||||
override def registerItemSubtypes(subtypeRegistry: ISubtypeRegistry) {
|
||||
def useNBT(names: String*) = names.map(name => {
|
||||
val info = Items.get(name)
|
||||
Option(info.item).getOrElse(Item.getItemFromBlock(info.block))
|
||||
}).filter(_ != null).distinct.foreach(registry.getJeiHelpers.getSubtypeRegistry.useNbtForSubtypes(_))
|
||||
}).filter(_ != null).distinct.foreach(subtypeRegistry.useNbtForSubtypes(_))
|
||||
|
||||
// Only the preconfigured blocks and items have to be here.
|
||||
useNBT(
|
||||
@ -49,7 +69,7 @@ class ModPluginOpenComputers extends IModPlugin {
|
||||
Constants.ItemName.Tablet
|
||||
)
|
||||
|
||||
registry.getJeiHelpers.getSubtypeRegistry.registerNbtInterpreter(Items.get(Constants.ItemName.Floppy).item(), new ISubtypeInterpreter {
|
||||
subtypeRegistry.registerNbtInterpreter(Items.get(Constants.ItemName.Floppy).item(), new ISubtypeInterpreter {
|
||||
override def getSubtypeInfo(stack: ItemStack): String = {
|
||||
if (!stack.hasTagCompound) return null
|
||||
val compound: NBTTagCompound = stack.getTagCompound
|
||||
@ -61,18 +81,5 @@ class ModPluginOpenComputers extends IModPlugin {
|
||||
if (data.hasNoTags) null else data.toString
|
||||
}
|
||||
})
|
||||
|
||||
registry.addAdvancedGuiHandlers(RelayGuiHandler)
|
||||
}
|
||||
|
||||
private var stackUnderMouse: (GuiContainer, Int, Int) => Option[ItemStack] = null
|
||||
|
||||
override def onRuntimeAvailable(jeiRuntime: IJeiRuntime) {
|
||||
if (stackUnderMouse == null) {
|
||||
ItemSearch.stackFocusing += ((container, mouseX, mouseY) => stackUnderMouse(container, mouseX, mouseY))
|
||||
}
|
||||
stackUnderMouse = (container, mouseX, mouseY) => Option(jeiRuntime.getItemListOverlay.getStackUnderMouse)
|
||||
|
||||
ModJEI.runtime = Option(jeiRuntime)
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,6 @@ object RelayGuiHandler extends IAdvancedGuiHandler[Relay] {
|
||||
override def getGuiExtraAreas(gui: Relay): util.List[Rectangle] = List(
|
||||
new Rectangle(gui.windowX + gui.tabPosition.getX, gui.windowY + gui.tabPosition.getY, gui.tabPosition.getWidth, gui.tabPosition.getHeight)
|
||||
)
|
||||
|
||||
override def getIngredientUnderMouse(guiContainer: Relay, mouseX: Int, mouseY: Int) = null
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user