Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEI manual offset fix #138

Merged
merged 3 commits into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading