Skip to content

Commit

Permalink
Use NEI recipe position when rendering the "Open Manual" button
Browse files Browse the repository at this point in the history
(cherry picked from commit 1c44654)
  • Loading branch information
YannickMG authored and Dream-Master committed Dec 15, 2024
1 parent d2ba427 commit 0dae539
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class ManualUsageHandler(path: Option[String]) extends IUsageHandler {
override def numRecipes = if (path.isDefined) 1 else 0

override def drawForeground(recipe: Int): Unit = if (path.isDefined) Minecraft.getMinecraft.currentScreen match {
case container: GuiContainer =>
case container: GuiRecipe[_] =>
val pos = GuiDraw.getMousePosition
button.drawButton(Minecraft.getMinecraft, pos.x - container.guiLeft - 5, pos.y - container.guiTop - 16)
val offset = container.getRecipePosition(recipe)
button.drawButton(Minecraft.getMinecraft, pos.x - container.guiLeft - offset.x, pos.y - container.guiTop - offset.y)
case _ =>
}

Expand All @@ -69,10 +70,11 @@ class ManualUsageHandler(path: Option[String]) extends IUsageHandler {
override def keyTyped(gui: GuiRecipe[_], char: Char, code: Int, recipe: Int): Boolean = false

override def mouseClicked(container: GuiRecipe[_], btn: Int, recipe: Int): Boolean = path.isDefined && (container match {
case container: GuiContainer =>
case container: GuiRecipe[_] =>
val pos = GuiDraw.getMousePosition
val offset = container.getRecipePosition(recipe)
val mc = Minecraft.getMinecraft
if (button.mousePressed(mc, pos.x - container.guiLeft - 5, pos.y - container.guiTop - 16)) {
if (button.mousePressed(mc, pos.x - container.guiLeft - offset.x, pos.y - container.guiTop - offset.y)) {
mc.thePlayer.closeScreen()
api.Manual.openFor(mc.thePlayer)
path.foreach(api.Manual.navigate)
Expand Down

0 comments on commit 0dae539

Please sign in to comment.