Jelajahi Sumber

Wrap around plz (2.7.9.94)

Fix #66
Unknown 6 tahun lalu
induk
melakukan
d7b0900385

+ 4 - 0
CHANGELOG.md

@@ -1,4 +1,8 @@
 View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/1.14/CHANGELOG.md).
+## v2.7.9.94
+- Added: Support for `c` namespace ([Cotton](https://github.com/CottonMC/cotton) Common Resources)
+- Added: Warping around the recipe book: ![image](https://media.discordapp.net/attachments/530305137382653952/568432084419608576/unknown.png?width=967&height=517) 
+- Fixed [#66](https://github.com/shedaniel/RoughlyEnoughItems/issues/66): Tooltips can be out of bounds
 ## v2.7.8.93
 - Fixed: Some localisations having broken json
 - Fixed: Depth of Craftable Toggle Button

+ 1 - 1
gradle.properties

@@ -1,4 +1,4 @@
-mod_version=2.7.8+build.93
+mod_version=2.7.9+build.94
 minecraft_version=1.14 Pre-Release 4
 yarn_version=1.14 Pre-Release 4+build.2
 fabric_version=0.2.7+build.123

+ 7 - 0
src/main/java/me/shedaniel/rei/api/DisplayHelper.java

@@ -1,10 +1,13 @@
 package me.shedaniel.rei.api;
 
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import net.minecraft.util.ActionResult;
 
 import java.awt.*;
 import java.util.List;
 
+import static net.minecraft.util.ActionResult.PASS;
+
 public interface DisplayHelper {
     
     List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass);
@@ -20,6 +23,10 @@ public interface DisplayHelper {
         
         Rectangle getRightBounds(T screen);
         
+        default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) {
+            return PASS;
+        }
+        
         default Rectangle getItemListArea(Rectangle rectangle) {
             return new Rectangle(rectangle.x + 2, rectangle.y + 24, rectangle.width - 4, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField ? 27 + 22 : 27));
         }

+ 33 - 10
src/main/java/me/shedaniel/rei/client/ClientHelper.java

@@ -1,6 +1,7 @@
 package me.shedaniel.rei.client;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
 import io.netty.buffer.Unpooled;
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
 import me.shedaniel.rei.RoughlyEnoughItemsNetwork;
@@ -18,7 +19,9 @@ import net.fabricmc.loader.api.metadata.ModMetadata;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen;
 import net.minecraft.client.util.InputUtil;
+import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
+import net.minecraft.item.Items;
 import net.minecraft.text.TranslatableTextComponent;
 import net.minecraft.util.DefaultedList;
 import net.minecraft.util.Identifier;
@@ -29,24 +32,44 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 public class ClientHelper implements ClientModInitializer {
     
     private static final Identifier RECIPE_KEYBIND = new Identifier("roughlyenoughitems", "recipe_keybind");
     private static final Identifier USAGE_KEYBIND = new Identifier("roughlyenoughitems", "usage_keybind");
     private static final Identifier HIDE_KEYBIND = new Identifier("roughlyenoughitems", "hide_keybind");
+    private static final Map<String, String> MOD_NAME_CACHE = Maps.newHashMap();
     public static FabricKeyBinding RECIPE, USAGE, HIDE;
     
-    public static String getModFromItemStack(ItemStack stack) {
-        if (!stack.isEmpty()) {
-            Identifier location = Registry.ITEM.getId(stack.getItem());
-            assert location != null;
-            String modid = location.getNamespace();
-            if (modid.equalsIgnoreCase("minecraft"))
-                return "Minecraft";
-            return FabricLoader.getInstance().getModContainer(modid).map(ModContainer::getMetadata).map(ModMetadata::getName).orElse(modid);
-        }
-        return "";
+    static {
+        MOD_NAME_CACHE.put("minecraft", "Minecraft");
+        MOD_NAME_CACHE.put("c", "Common");
+    }
+    
+    public static String getFormattedModFromItem(Item item) {
+        String mod = getModFromItem(item);
+        if (mod.equalsIgnoreCase(""))
+            return "";
+        return "§9§o" + mod;
+    }
+    
+    public static String getModFromItem(Item item) {
+        if (item.equals(Items.AIR))
+            return "";
+        return getModFromIdentifier(Registry.ITEM.getId(item));
+    }
+    
+    public static String getModFromIdentifier(Identifier identifier) {
+        if (identifier == null)
+            return "";
+        Optional<String> any = Optional.ofNullable(MOD_NAME_CACHE.getOrDefault(identifier.getNamespace(), null));
+        if (any.isPresent())
+            return any.get();
+        String modid = identifier.getNamespace();
+        String s = FabricLoader.getInstance().getModContainer(modid).map(ModContainer::getMetadata).map(ModMetadata::getName).orElse(modid);
+        MOD_NAME_CACHE.put(modid, s);
+        return s;
     }
     
     public static boolean isCheating() {

+ 32 - 33
src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java

@@ -337,48 +337,49 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
             toggleButtonWidget.lateRender(mouseX, mouseY, delta);
         Screen currentScreen = MinecraftClient.getInstance().currentScreen;
         if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated)
-            QUEUED_TOOLTIPS.stream().filter(Objects::nonNull).forEach(queuedTooltip -> renderTooltip(queuedTooltip.getText(), queuedTooltip.getX(), queuedTooltip.getY()));
+            QUEUED_TOOLTIPS.stream().filter(Objects::nonNull).forEach(this::renderTooltip);
         QUEUED_TOOLTIPS.clear();
     }
     
-    public void renderTooltip(List<String> list_1, int int_1, int int_2) {
+    public void renderTooltip(QueuedTooltip tooltip) {
+        renderTooltip(tooltip.getText(), tooltip.getX(), tooltip.getY());
+    }
+    
+    public void renderTooltip(List<String> lines, int mouseX, int mouseY) {
         TextRenderer font = MinecraftClient.getInstance().textRenderer;
-        if (!list_1.isEmpty()) {
+        if (!lines.isEmpty()) {
             GlStateManager.disableRescaleNormal();
             GuiLighting.disable();
             GlStateManager.disableLighting();
-            int int_3 = 0;
-            for(String string_1 : list_1)
-                if (font.getStringWidth(string_1) > int_3)
-                    int_3 = font.getStringWidth(string_1);
-            int int_5 = int_1 + 12;
-            int int_6 = int_2 - 12;
-            int int_8 = 8;
-            if (list_1.size() > 1)
-                int_8 += 2 + (list_1.size() - 1) * 10;
-            if (int_5 + int_3 > window.getScaledWidth())
-                int_5 -= 28 + int_3;
-            if (int_6 + int_8 + 6 > window.getScaledHeight())
-                int_6 = window.getScaledHeight() - int_8 - 6;
+            int width = 0;
+            for(String line : lines)
+                if (font.getStringWidth(line) > width)
+                    width = font.getStringWidth(line);
+            int height = lines.size() <= 1 ? 8 : lines.size() * 10;
+            int x = Math.max(mouseX + 12, 6);
+            int y = Math.min(mouseY - 12, window.getScaledHeight() - height - 6);
+            if (x + width > window.getScaledWidth())
+                x -= 24 + width;
+            if (y < 6)
+                y += 24;
             
             this.blitOffset = 1000;
-            this.fillGradient(int_5 - 3, int_6 - 4, int_5 + int_3 + 3, int_6 - 3, -267386864, -267386864);
-            this.fillGradient(int_5 - 3, int_6 + int_8 + 3, int_5 + int_3 + 3, int_6 + int_8 + 4, -267386864, -267386864);
-            this.fillGradient(int_5 - 3, int_6 - 3, int_5 + int_3 + 3, int_6 + int_8 + 3, -267386864, -267386864);
-            this.fillGradient(int_5 - 4, int_6 - 3, int_5 - 3, int_6 + int_8 + 3, -267386864, -267386864);
-            this.fillGradient(int_5 + int_3 + 3, int_6 - 3, int_5 + int_3 + 4, int_6 + int_8 + 3, -267386864, -267386864);
-            this.fillGradient(int_5 - 3, int_6 - 3 + 1, int_5 - 3 + 1, int_6 + int_8 + 3 - 1, 1347420415, 1344798847);
-            this.fillGradient(int_5 + int_3 + 2, int_6 - 3 + 1, int_5 + int_3 + 3, int_6 + int_8 + 3 - 1, 1347420415, 1344798847);
-            this.fillGradient(int_5 - 3, int_6 - 3, int_5 + int_3 + 3, int_6 - 3 + 1, 1347420415, 1347420415);
-            this.fillGradient(int_5 - 3, int_6 + int_8 + 2, int_5 + int_3 + 3, int_6 + int_8 + 3, 1344798847, 1344798847);
+            this.fillGradient(x - 3, y - 4, x + width + 3, y - 3, -267386864, -267386864);
+            this.fillGradient(x - 3, y + height + 3, x + width + 3, y + height + 4, -267386864, -267386864);
+            this.fillGradient(x - 3, y - 3, x + width + 3, y + height + 3, -267386864, -267386864);
+            this.fillGradient(x - 4, y - 3, x - 3, y + height + 3, -267386864, -267386864);
+            this.fillGradient(x + width + 3, y - 3, x + width + 4, y + height + 3, -267386864, -267386864);
+            this.fillGradient(x - 3, y - 3 + 1, x - 3 + 1, y + height + 3 - 1, 1347420415, 1344798847);
+            this.fillGradient(x + width + 2, y - 3 + 1, x + width + 3, y + height + 3 - 1, 1347420415, 1344798847);
+            this.fillGradient(x - 3, y - 3, x + width + 3, y - 3 + 1, 1347420415, 1347420415);
+            this.fillGradient(x - 3, y + height + 2, x + width + 3, y + height + 3, 1344798847, 1344798847);
             
-            for(int int_12 = 0; int_12 < list_1.size(); ++int_12) {
+            int currentY = y;
+            for(int lineIndex = 0; lineIndex < lines.size(); lineIndex++) {
                 GlStateManager.disableDepthTest();
-                font.drawWithShadow(list_1.get(int_12), (float) int_5, (float) int_6, -1);
+                font.drawWithShadow(lines.get(lineIndex), x, currentY, -1);
                 GlStateManager.enableDepthTest();
-                if (int_12 == 0)
-                    int_6 += 2;
-                int_6 += 10;
+                currentY += lineIndex == 0 ? 12 : 10;
             }
             this.blitOffset = 0;
             GlStateManager.enableLighting();
@@ -420,9 +421,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
     }
     
     private int getTotalPage() {
-        if (itemListOverlay.getTotalSlotsPerPage() > 0)
-            return MathHelper.ceil(itemListOverlay.getCurrentDisplayed().size() / itemListOverlay.getTotalSlotsPerPage());
-        return 0;
+        return itemListOverlay.getTotalPage();
     }
     
     @Override

+ 1 - 0
src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java

@@ -325,6 +325,7 @@ public class RecipeViewingScreen extends Screen {
         GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         GuiLighting.disable();
         tabs.stream().filter(TabWidget::isSelected).forEach(tabWidget -> tabWidget.render(mouseX, mouseY, delta));
+        GuiLighting.disable();
         ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta);
         ScreenHelper.getLastOverlay().lateRender(mouseX, mouseY, delta);
         if (choosePageActivated) {

+ 46 - 11
src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java

@@ -12,10 +12,12 @@ import me.shedaniel.rei.client.ScreenHelper;
 import me.shedaniel.rei.client.SearchArgument;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.render.GuiLighting;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemGroup;
 import net.minecraft.item.ItemStack;
+import net.minecraft.util.ActionResult;
 import net.minecraft.util.math.MathHelper;
 import net.minecraft.util.registry.Registry;
 import org.apache.commons.lang3.StringUtils;
@@ -24,7 +26,6 @@ import java.awt.*;
 import java.util.*;
 import java.util.List;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 public class ItemListOverlay extends Widget {
     
@@ -68,12 +69,13 @@ public class ItemListOverlay extends Widget {
         return "ERROR";
     }
     
-    public int getTotalSlotsPerPage() {
+    public int getFullTotalSlotsPerPage() {
         return width * height;
     }
     
     @Override
     public void render(int int_1, int int_2, float float_1) {
+        GuiLighting.disable();
         widgets.forEach(widget -> widget.render(int_1, int_2, float_1));
         ClientPlayerEntity player = minecraft.player;
         if (rectangle.contains(ClientUtils.getMouseLocation()) && ClientHelper.isCheating() && !player.inventory.getCursorStack().isEmpty() && minecraft.isInSingleplayer())
@@ -86,19 +88,24 @@ public class ItemListOverlay extends Widget {
         this.widgets = Lists.newLinkedList();
         calculateListSize(rectangle);
         currentDisplayed = processSearchTerm(searchTerm, RoughlyEnoughItemsCore.getItemRegisterer().getItemList(), ScreenHelper.inventoryStacks);
-        double startX = rectangle.getCenterX() - width * 9;
-        double startY = rectangle.getCenterY() - height * 9;
+        int startX = (int) rectangle.getCenterX() - width * 9;
+        int startY = (int) rectangle.getCenterY() - height * 9;
         this.listArea = new Rectangle((int) startX, (int) startY, width * 18, height * 18);
-        for(int i = 0; i < getTotalSlotsPerPage(); i++) {
-            int j = i + page * getTotalSlotsPerPage();
+        int fitSlotsPerPage = getTotalFitSlotsPerPage(listArea.x, listArea.y, listArea);
+        int j = page * fitSlotsPerPage;
+        for(int i = 0; i < getFullTotalSlotsPerPage(); i++) {
             if (j >= currentDisplayed.size())
                 break;
-            widgets.add(new ItemSlotWidget((int) (startX + (i % width) * 18), (int) (startY + MathHelper.floor(i / width) * 18), Collections.singletonList(currentDisplayed.get(j)), false, true, true) {
+            int x = startX + (i % width) * 18, y = startY + MathHelper.floor(i / width) * 18;
+            if (!canBeFit(x, y, listArea))
+                continue;
+            j++;
+            widgets.add(new ItemSlotWidget(x, y, Collections.singletonList(currentDisplayed.get(j)), false, true, true) {
                 @Override
-                protected void drawToolTip(ItemStack itemStack, float delta) {
+                protected void queueTooltip(ItemStack itemStack, float delta) {
                     ClientPlayerEntity player = minecraft.player;
                     if (!ClientHelper.isCheating() || player.inventory.getCursorStack().isEmpty())
-                        super.drawToolTip(itemStack, delta);
+                        super.queueTooltip(itemStack, delta);
                 }
                 
                 @Override
@@ -126,6 +133,34 @@ public class ItemListOverlay extends Widget {
         }
     }
     
+    public int getTotalPage() {
+        int fitSlotsPerPage = getTotalFitSlotsPerPage(listArea.x, listArea.y, listArea);
+        if (fitSlotsPerPage > 0)
+            return MathHelper.ceil(getCurrentDisplayed().size() / fitSlotsPerPage);
+        return 0;
+    }
+    
+    public int getTotalFitSlotsPerPage(int startX, int startY, Rectangle listArea) {
+        int slots = 0;
+        for(int i = 0; i < getFullTotalSlotsPerPage(); i++)
+            if (canBeFit(startX + (i % width) * 18, startY + MathHelper.floor(i / width) * 18, listArea))
+                slots++;
+        return slots;
+    }
+    
+    public boolean canBeFit(int left, int top, Rectangle listArea) {
+        List<DisplayHelper.DisplayBoundsHandler> sortedBoundsHandlers = RoughlyEnoughItemsCore.getDisplayHelper().getSortedBoundsHandlers(minecraft.currentScreen.getClass());
+        ActionResult result = ActionResult.SUCCESS;
+        for(DisplayHelper.DisplayBoundsHandler sortedBoundsHandler : sortedBoundsHandlers) {
+            ActionResult fit = sortedBoundsHandler.canItemSlotWidgetFit(!RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel, left, top, minecraft.currentScreen, listArea);
+            if (fit != ActionResult.PASS) {
+                result = fit;
+                break;
+            }
+        }
+        return result == ActionResult.SUCCESS;
+    }
+    
     @Override
     public boolean keyPressed(int int_1, int int_2, int int_3) {
         for(Widget widget : widgets)
@@ -196,10 +231,10 @@ public class ItemListOverlay extends Widget {
     }
     
     private boolean filterItem(ItemStack itemStack, List<SearchArgument> arguments) {
-        String mod = ClientHelper.getModFromItemStack(itemStack);
+        String mod = ClientHelper.getModFromItem(itemStack.getItem());
         List<String> toolTipsList = tryGetItemStackToolTip(itemStack);
         String toolTipsMixed = toolTipsList.stream().skip(1).collect(Collectors.joining()).toLowerCase();
-        String allMixed = Stream.of(tryGetItemStackName(itemStack), toolTipsMixed).collect(Collectors.joining()).toLowerCase();
+        String allMixed = toolTipsList.stream().collect(Collectors.joining()).toLowerCase();
         for(SearchArgument searchArgument : arguments.stream().filter(searchArgument -> !searchArgument.isInclude()).collect(Collectors.toList())) {
             if (searchArgument.getArgumentType().equals(SearchArgument.ArgumentType.MOD))
                 if (mod.toLowerCase().contains(searchArgument.getText().toLowerCase()))

+ 15 - 10
src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java

@@ -65,7 +65,8 @@ public class ItemSlotWidget extends HighlightableWidget {
             minecraft.getTextureManager().bindTexture(RECIPE_GUI);
             blit(this.x - 1, this.y - 1, 0, 222, 18, 18);
         }
-        if (drawHighlightedBackground && isHighlighted(mouseX, mouseY)) {
+        boolean highlighted = isHighlighted(mouseX, mouseY);
+        if (drawHighlightedBackground && highlighted) {
             GlStateManager.disableLighting();
             GlStateManager.disableDepthTest();
             GlStateManager.colorMask(true, true, true, false);
@@ -75,7 +76,7 @@ public class ItemSlotWidget extends HighlightableWidget {
             GlStateManager.enableDepthTest();
         }
         if (!itemStack.isEmpty()) {
-            if (RoughlyEnoughItemsCore.getConfigManager().getConfig().aprilFoolsFish2019 && !isHighlighted(mouseX, mouseY))
+            if (RoughlyEnoughItemsCore.getConfigManager().getConfig().aprilFoolsFish2019 && !highlighted)
                 itemStack = Items.TROPICAL_FISH.getDefaultStack();
             GuiLighting.enableForItems();
             ItemRenderer itemRenderer = minecraft.getItemRenderer();
@@ -84,27 +85,31 @@ public class ItemSlotWidget extends HighlightableWidget {
             itemRenderer.renderGuiItemOverlay(font, itemStack, x, y, getItemCountOverlay(itemStack));
             itemRenderer.zOffset = 0.0F;
         }
-        if (!itemStack.isEmpty() && isHighlighted(mouseX, mouseY) && showToolTips)
-            drawToolTip(itemStack, delta);
+        if (!itemStack.isEmpty() && highlighted && showToolTips)
+            queueTooltip(itemStack, delta);
     }
     
-    protected void drawToolTip(ItemStack itemStack, float delta) {
+    protected void queueTooltip(ItemStack itemStack, float delta) {
         ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltip(itemStack)));
     }
     
     protected List<String> getTooltip(ItemStack itemStack) {
-        final String modString = "§9§o" + ClientHelper.getModFromItemStack(itemStack);
+        final String modString = ClientHelper.getFormattedModFromItem(itemStack.getItem());
         List<String> toolTip = Lists.newArrayList(ItemListOverlay.tryGetItemStackToolTip(itemStack));
         toolTip.addAll(getExtraToolTips(itemStack));
+        boolean alreadyHasMod = false;
         for(String s : Lists.newArrayList(toolTip))
-            if (s.equalsIgnoreCase(modString))
-                toolTip.remove(s);
-        toolTip.add(modString);
+            if (s.equalsIgnoreCase(modString)) {
+                alreadyHasMod = true;
+                break;
+            }
+        if (!alreadyHasMod)
+            toolTip.add(modString);
         return toolTip;
     }
     
     protected List<String> getExtraToolTips(ItemStack stack) {
-        return Lists.newArrayList();
+        return Collections.emptyList();
     }
     
     protected String getItemCountOverlay(ItemStack currentStack) {

+ 2 - 2
src/main/java/me/shedaniel/rei/gui/widget/QueuedTooltip.java

@@ -5,7 +5,7 @@ import com.google.common.collect.Lists;
 import me.shedaniel.cloth.api.ClientUtils;
 
 import java.awt.*;
-import java.util.LinkedList;
+import java.util.Collections;
 import java.util.List;
 
 public class QueuedTooltip {
@@ -15,7 +15,7 @@ public class QueuedTooltip {
     
     private QueuedTooltip(Point location, List<String> text) {
         this.location = location;
-        this.text = new LinkedList<>(text);
+        this.text = Collections.unmodifiableList(text);
     }
     
     public static QueuedTooltip create(Point location, List<String> text) {

+ 19 - 11
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -28,6 +28,7 @@ import net.minecraft.recipe.cooking.SmeltingRecipe;
 import net.minecraft.recipe.cooking.SmokingRecipe;
 import net.minecraft.recipe.crafting.ShapedRecipe;
 import net.minecraft.recipe.crafting.ShapelessRecipe;
+import net.minecraft.util.ActionResult;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.registry.Registry;
 
@@ -136,43 +137,50 @@ public class DefaultPlugin implements REIPlugin {
     
     @Override
     public void registerBounds(DisplayHelper displayHelper) {
-        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler() {
+        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<ContainerScreen>() {
             @Override
             public Class getBaseSupportedClass() {
                 return ContainerScreen.class;
             }
             
             @Override
-            public Rectangle getLeftBounds(Object screen) {
-                if (MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen())
-                    return new Rectangle(2, 0, ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 4 - 147 - 30, MinecraftClient.getInstance().window.getScaledHeight());
+            public Rectangle getLeftBounds(ContainerScreen screen) {
                 return new Rectangle(2, 0, ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 4, MinecraftClient.getInstance().window.getScaledHeight());
             }
             
             @Override
-            public Rectangle getRightBounds(Object screen) {
+            public Rectangle getRightBounds(ContainerScreen screen) {
                 int startX = ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerWidth() + 2;
                 return new Rectangle(startX, 0, MinecraftClient.getInstance().window.getScaledWidth() - startX - 2, MinecraftClient.getInstance().window.getScaledHeight());
             }
             
+            @Override
+            public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, ContainerScreen screen, Rectangle fullBounds) {
+                if (!isOnRightSide)
+                    if (MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() && left + 18 > ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 4 - 145 - 30)
+                        if (top + 18 >= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() && top <= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerHeight())
+                            return ActionResult.FAIL;
+                return ActionResult.PASS;
+            }
+            
             @Override
             public float getPriority() {
                 return -1.0f;
             }
         });
-        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler() {
+        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<RecipeViewingScreen>() {
             @Override
             public Class getBaseSupportedClass() {
                 return RecipeViewingScreen.class;
             }
             
             @Override
-            public Rectangle getLeftBounds(Object screen) {
+            public Rectangle getLeftBounds(RecipeViewingScreen screen) {
                 return new Rectangle(2, 0, ((RecipeViewingScreen) screen).getBounds().x - 4, MinecraftClient.getInstance().window.getScaledHeight());
             }
             
             @Override
-            public Rectangle getRightBounds(Object screen) {
+            public Rectangle getRightBounds(RecipeViewingScreen screen) {
                 int startX = ((RecipeViewingScreen) screen).getBounds().x + ((RecipeViewingScreen) screen).getBounds().width + 2;
                 return new Rectangle(startX, 0, MinecraftClient.getInstance().window.getScaledWidth() - startX - 2, MinecraftClient.getInstance().window.getScaledHeight());
             }
@@ -182,19 +190,19 @@ public class DefaultPlugin implements REIPlugin {
                 return -1.0f;
             }
         });
-        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler() {
+        displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<CreativePlayerInventoryScreen>() {
             @Override
             public Class getBaseSupportedClass() {
                 return CreativePlayerInventoryScreen.class;
             }
             
             @Override
-            public Rectangle getLeftBounds(Object screen) {
+            public Rectangle getLeftBounds(CreativePlayerInventoryScreen screen) {
                 return new Rectangle(2, 0, ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 2, MinecraftClient.getInstance().window.getScaledHeight());
             }
             
             @Override
-            public Rectangle getRightBounds(Object screen) {
+            public Rectangle getRightBounds(CreativePlayerInventoryScreen screen) {
                 int startX = ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerWidth();
                 return new Rectangle(startX, 0, MinecraftClient.getInstance().window.getScaledWidth() - startX - 2, MinecraftClient.getInstance().window.getScaledHeight());
             }

+ 0 - 10
src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java

@@ -1,7 +1,6 @@
 package me.shedaniel.rei.utils;
 
 import me.shedaniel.cloth.api.ConfigScreenBuilder;
-import me.shedaniel.cloth.gui.ClothConfigScreen;
 import me.shedaniel.cloth.gui.entries.BooleanListEntry;
 import me.shedaniel.cloth.gui.entries.EnumListEntry;
 import me.shedaniel.cloth.gui.entries.IntegerSliderEntry;
@@ -15,11 +14,8 @@ import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Screen;
 import net.minecraft.client.gui.widget.ButtonWidget;
 import net.minecraft.client.resource.language.I18n;
-import net.minecraft.util.Pair;
 
 import java.io.IOException;
-import java.util.List;
-import java.util.Map;
 
 public class ClothScreenRegistry {
     
@@ -69,10 +65,4 @@ public class ClothScreenRegistry {
         }));
     }
     
-    private static class SelfSavedConfig extends ClothConfigScreen.Builder.SavedConfig {
-        protected SelfSavedConfig(Map<String, List<Pair<String, Object>>> map) {
-            super(map);
-        }
-    }
-    
 }