aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-03-21 12:23:14 +0800
committershedaniel <daniel@shedaniel.me>2021-03-21 12:23:14 +0800
commit7c4788f86f589d71b319e186fa5d8a468046bcc1 (patch)
treeb87fd23a6d65a96e381c27fe0470d1f50e77a635 /runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
parent2c29cac8a5e0878696c8e6635f4e41ed4845b41c (diff)
downloadRoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.tar.gz
RoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.tar.bz2
RoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.zip
Rely on ScreenRegistry more on calculating the bounds
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java29
1 files changed, 10 insertions, 19 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index bd5f85ef4..8d1a1209a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -53,7 +53,6 @@ import me.shedaniel.rei.api.ingredient.EntryStack;
import me.shedaniel.rei.api.ingredient.util.EntryStacks;
import me.shedaniel.rei.api.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.registry.screen.ClickArea;
-import me.shedaniel.rei.api.registry.screen.DisplayBoundsProvider;
import me.shedaniel.rei.api.registry.screen.OverlayDecider;
import me.shedaniel.rei.api.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.util.CollectionUtils;
@@ -429,16 +428,10 @@ public class ContainerScreenOverlay extends REIOverlay {
}
private Rectangle getSubsetsButtonBounds() {
- // TODO rely on the screen registry
if (ConfigObject.getInstance().isSubsetsEnabled()) {
- if (Minecraft.getInstance().screen instanceof AbstractRecipeViewingScreen) {
- AbstractRecipeViewingScreen widget = (AbstractRecipeViewingScreen) Minecraft.getInstance().screen;
- return new Rectangle(widget.getBounds().x, 3, widget.getBounds().width, 18);
- }
- AbstractContainerScreen<?> containerScreen = REIHelper.getInstance().getPreviousContainerScreen();
- if (containerScreen != null) {
- return new Rectangle(containerScreen.leftPos, 3, containerScreen.imageWidth, 18);
- }
+ ScreenRegistry registry = ScreenRegistry.getInstance();
+ Rectangle screenBounds = registry.getScreenBounds(minecraft.screen);
+ return new Rectangle(screenBounds.x, 3, screenBounds.width, 18);
}
return null;
}
@@ -488,15 +481,8 @@ public class ContainerScreenOverlay extends REIOverlay {
case BOTTOM_SIDE:
return getBottomSideSearchFieldArea(widthRemoved);
default:
- case CENTER: {
- for (OverlayDecider decider : ScreenRegistry.getInstance().getDeciders(Minecraft.getInstance().screen)) {
- if (decider instanceof DisplayBoundsProvider) {
- Rectangle containerBounds = ((DisplayBoundsProvider<Screen>) decider).getScreenBounds(Minecraft.getInstance().screen);
- return getBottomCenterSearchFieldArea(containerBounds, widthRemoved);
- }
- }
- return new Rectangle();
- }
+ case CENTER:
+ return getCenterSearchFieldArea(widthRemoved);
}
}
@@ -508,6 +494,11 @@ public class ContainerScreenOverlay extends REIOverlay {
return new Rectangle(bounds.x + 2, window.getGuiScaledHeight() - 22, bounds.width - 6 - widthRemoved, 18);
}
+ private Rectangle getCenterSearchFieldArea(int widthRemoved) {
+ Rectangle screenBounds = ScreenRegistry.getInstance().getScreenBounds(minecraft.screen);
+ return getBottomCenterSearchFieldArea(screenBounds, widthRemoved);
+ }
+
private Rectangle getBottomCenterSearchFieldArea(Rectangle containerBounds, int widthRemoved) {
return new Rectangle(containerBounds.x, window.getGuiScaledHeight() - 22, containerBounds.width - widthRemoved, 18);
}