aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/gui/REIRenderHelper.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-02 23:06:23 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-02 23:06:23 +0800
commitfe03c35dc0613aaf67bbde531a930cb9939c6096 (patch)
treedd342072bddc348a331fbabf1dc1ed5d980e4b3d /src/main/java/me/shedaniel/gui/REIRenderHelper.java
parent6ff53479192a474a68c9ce07c65f92464cb04d6e (diff)
downloadRoughlyEnoughItems-fe03c35dc0613aaf67bbde531a930cb9939c6096.tar.gz
RoughlyEnoughItems-fe03c35dc0613aaf67bbde531a930cb9939c6096.tar.bz2
RoughlyEnoughItems-fe03c35dc0613aaf67bbde531a930cb9939c6096.zip
v1.4 Bug Fixes
Diffstat (limited to 'src/main/java/me/shedaniel/gui/REIRenderHelper.java')
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/REIRenderHelper.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/main/java/me/shedaniel/gui/REIRenderHelper.java b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
index f4e66808a..f0cb15e8e 100755
--- a/src/main/java/me/shedaniel/gui/REIRenderHelper.java
+++ b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
@@ -17,8 +17,10 @@ import net.minecraft.item.ItemStack;
import java.awt.*;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
@@ -127,7 +129,12 @@ public class REIRenderHelper {
}
}
if (overlayedGui instanceof RecipeGui) {
- List<Control> controls = ((RecipeGui) overlayedGui).controls;
+ List<Control> controls = new LinkedList<>(((RecipeGui) overlayedGui).controls);
+ if (((RecipeGui) overlayedGui).slots != null)
+ controls.addAll(((RecipeGui) overlayedGui).slots);
+ controls.addAll(reiGui.controls.stream().filter(control -> {
+ return control instanceof REISlot;
+ }).collect(Collectors.toList()));
Optional<Control> ctrl = controls.stream().filter(Control::isHighlighted).filter(Control::isEnabled).findFirst();
if (ctrl.isPresent()) {
try {
@@ -181,6 +188,30 @@ public class REIRenderHelper {
public static boolean mouseScrolled(double direction) {
if (!reiGui.visible)
return false;
+ if (MinecraftClient.getInstance().currentGui instanceof RecipeGui) {
+ Window window = REIRenderHelper.getResolution();
+ Point mouse = new Point((int) MinecraftClient.getInstance().mouse.getX(), (int) MinecraftClient.getInstance().mouse.getY());
+ int mouseX = (int) (mouse.x * (double) window.getScaledWidth() / (double) window.method_4480());
+ int mouseY = (int) (mouse.y * (double) window.getScaledHeight() / (double) window.method_4507());
+ mouse = new Point(mouseX, mouseY);
+
+ RecipeGui recipeGui = (RecipeGui) MinecraftClient.getInstance().currentGui;
+ System.out.printf("%b.%b.%b.%b.%b%n", mouse.getX() < window.getScaledWidth() / 2 + recipeGui.guiWidth / 2, mouse.getX() > window.getScaledWidth() / 2 - recipeGui.guiWidth / 2,
+ mouse.getY() < window.getScaledHeight() / 2 + recipeGui.guiHeight / 2, mouse.getY() > window.getScaledHeight() / 2 - recipeGui.guiHeight / 2,
+ recipeGui.recipes.get(recipeGui.selectedCategory).size() > 2);
+ if (mouse.getX() < window.getScaledWidth() / 2 + recipeGui.guiWidth / 2 && mouse.getX() > window.getScaledWidth() / 2 - recipeGui.guiWidth / 2 &&
+ mouse.getY() < window.getScaledHeight() / 2 + recipeGui.guiHeight / 2 && mouse.getY() > window.getScaledHeight() / 2 - recipeGui.guiHeight / 2 &&
+ recipeGui.recipes.get(recipeGui.selectedCategory).size() > 2) {
+ boolean failed = false;
+ if (direction > 0 && reiGui.buttonLeft.isEnabled())
+ recipeGui.btnRecipeLeft.onClick.apply(0);
+ else if (direction < 0 && reiGui.buttonRight.isEnabled())
+ recipeGui.btnRecipeRight.onClick.apply(0);
+ else failed = true;
+ if (!failed)
+ return true;
+ }
+ }
if (direction > 0 && reiGui.buttonLeft.isEnabled())
reiGui.buttonLeft.onClick.apply(0);
else if (direction < 0 && reiGui.buttonRight.isEnabled())