Skip to content

Commit

Permalink
Fix JEI integration (closes #68)
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Jun 30, 2016
1 parent f18db77 commit 913c473
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion java/squeek/applecore/AppleCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@IFMLLoadingPlugin.SortingIndex(1100)
@IFMLLoadingPlugin.MCVersion("1.10")
@IFMLLoadingPlugin.TransformerExclusions({"squeek.applecore.asm", "squeek.asmhelper"})
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, acceptableRemoteVersions="*", guiFactory = ModInfo.GUI_FACTORY_CLASS, dependencies = "after:JEI@[3.2.12,); required-after:Forge@[12.18.0,)")
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, acceptableRemoteVersions="*", guiFactory = ModInfo.GUI_FACTORY_CLASS, dependencies = "after:JEI@[3.7.0,); required-after:Forge@[12.18.0,)")
public class AppleCore implements IFMLLoadingPlugin
{
public static Logger Log = LogManager.getLogger(ModInfo.MODID);
Expand Down
16 changes: 8 additions & 8 deletions java/squeek/applecore/client/TooltipOverlayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void init()
private static Class<?> RecipesGui = null;
private static Method jeiGetFocusUnderMouse = null;
private static Method jeiRecipesGetFocusUnderMouse = null;
private static Field jeiFocus_itemStack = null;
private static Field jeiFocus_value = null;
private static Field jeiRecipeLayouts = null;
private static Field jeiRecipesGui_guiLeft = null;
private static Field jeiRecipesGui_guiTop = null;
Expand Down Expand Up @@ -97,8 +97,8 @@ public static void init()
jeiRecipeLayout_getFocusUnderMouse = RecipeLayout.getDeclaredMethod("getFocusUnderMouse", int.class, int.class);

Class<?> Focus = Class.forName("mezz.jei.gui.Focus");
jeiFocus_itemStack = Focus.getDeclaredField("stack");
jeiFocus_itemStack.setAccessible(true);
jeiFocus_value = Focus.getDeclaredField("value");
jeiFocus_value.setAccessible(true);
}
}
catch (RuntimeException e)
Expand Down Expand Up @@ -174,7 +174,7 @@ public void onRenderTick(RenderTickEvent event)
try
{
// try JEI recipe handler
if (jeiFocus_itemStack != null)
if (jeiFocus_value != null)
{
Object jeiRuntime = jeiGetRuntime.invoke(null);

Expand All @@ -183,17 +183,17 @@ public void onRenderTick(RenderTickEvent event)
if (isJEIRecipesGui)
{
Object recipesFocus = jeiRecipesGetFocusUnderMouse.invoke(curScreen, mouseX, mouseY);
if (recipesFocus != null)
hoveredStack = (ItemStack) jeiFocus_itemStack.get(recipesFocus);
if (recipesFocus != null && jeiFocus_value.get(recipesFocus) instanceof ItemStack)
hoveredStack = (ItemStack) jeiFocus_value.get(recipesFocus);
}

// next try to get the hovered stack from the right-hand item list
if (hoveredStack == null)
{
Object itemList = jeiGetItemListOverlay.invoke(jeiRuntime);
Object listFocus = jeiGetFocusUnderMouse.invoke(itemList, mouseX, mouseY);
if (listFocus != null)
hoveredStack = (ItemStack) jeiFocus_itemStack.get(listFocus);
if (listFocus != null && jeiFocus_value.get(listFocus) instanceof ItemStack)
hoveredStack = (ItemStack) jeiFocus_value.get(listFocus);
}
else
{
Expand Down

0 comments on commit 913c473

Please sign in to comment.