瀏覽代碼

Welcome back: Container

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 年之前
父節點
當前提交
bd08543707
共有 39 個文件被更改,包括 235 次插入221 次删除
  1. 1 0
      build.gradle
  2. 2 2
      gradle.properties
  3. 14 14
      src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
  4. 12 12
      src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
  5. 0 1
      src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
  6. 22 12
      src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
  7. 7 2
      src/main/java/me/shedaniel/rei/api/REIHelper.java
  8. 3 3
      src/main/java/me/shedaniel/rei/api/RecipeHelper.java
  9. 2 3
      src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java
  10. 20 20
      src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
  11. 3 3
      src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
  12. 2 2
      src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
  13. 2 2
      src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
  14. 2 2
      src/main/java/me/shedaniel/rei/gui/WarningAndErrorScreen.java
  15. 1 1
      src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java
  16. 3 3
      src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java
  17. 0 3
      src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java
  18. 2 2
      src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java
  19. 1 1
      src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java
  20. 5 2
      src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
  21. 1 1
      src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
  22. 5 5
      src/main/java/me/shedaniel/rei/impl/InternalWidgets.java
  23. 6 6
      src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java
  24. 11 11
      src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
  25. 6 6
      src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
  26. 5 5
      src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java
  27. 7 7
      src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java
  28. 6 6
      src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java
  29. 11 11
      src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java
  30. 13 13
      src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java
  31. 6 6
      src/main/java/me/shedaniel/rei/plugin/containers/CraftingContainerInfoWrapper.java
  32. 2 2
      src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java
  33. 3 3
      src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
  34. 2 2
      src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java
  35. 1 1
      src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java
  36. 3 3
      src/main/java/me/shedaniel/rei/server/ContainerInfo.java
  37. 11 11
      src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java
  38. 26 26
      src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java
  39. 6 6
      src/main/resources/rei.aw

+ 1 - 0
build.gradle

@@ -32,6 +32,7 @@ license {
 }
 
 repositories {
+    maven { url "https://dl.bintray.com/shedaniel/legacy-yarn-updated" }
 }
 
 jar {

+ 2 - 2
gradle.properties

@@ -1,7 +1,7 @@
-mod_version=4.3.3-unstable
+mod_version=4.3.4-unstable
 supported_version=20w19a
 minecraft_version=20w19a
-yarn_version=20w19a+build.4
+yarn_version=20w19a+build.5+legacy.20w09a+build.8
 fabricloader_version=0.8.2+build.194
 cloth_events_version=2.2.0-unstable
 cloth_config_version=4.1.0-unstable

+ 14 - 14
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java

@@ -39,9 +39,9 @@ import net.fabricmc.loader.api.ModContainer;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.CraftingScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
+import net.minecraft.client.gui.screen.ingame.CraftingTableScreen;
 import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
 import net.minecraft.client.gui.screen.ingame.InventoryScreen;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookGhostSlots;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
@@ -49,11 +49,11 @@ import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
 import net.minecraft.client.gui.widget.TextFieldWidget;
 import net.minecraft.client.gui.widget.TexturedButtonWidget;
 import net.minecraft.client.resource.language.I18n;
+import net.minecraft.container.CraftingTableContainer;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.Items;
 import net.minecraft.recipe.Ingredient;
 import net.minecraft.recipe.RecipeManager;
-import net.minecraft.screen.CraftingScreenHandler;
 import net.minecraft.screen.slot.Slot;
 import net.minecraft.text.LiteralText;
 import net.minecraft.util.ActionResult;
@@ -192,11 +192,11 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
             ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> {
                 ItemStack stack = packetByteBuf.readItemStack();
                 String player = packetByteBuf.readString(32767);
-                packetContext.getPlayer().sendMessage(new LiteralText(I18n.translate("text.rei.cheat_items").replaceAll("\\{item_name}", SearchArgument.tryGetItemStackName(stack.copy())).replaceAll("\\{item_count}", stack.copy().getCount() + "").replaceAll("\\{player_name}", player)), false);
+                packetContext.getPlayer().addMessage(new LiteralText(I18n.translate("text.rei.cheat_items").replaceAll("\\{item_name}", SearchArgument.tryGetItemStackName(stack.copy())).replaceAll("\\{item_count}", stack.copy().getCount() + "").replaceAll("\\{player_name}", player)), false);
             });
             ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.NOT_ENOUGH_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
                 Screen currentScreen = MinecraftClient.getInstance().currentScreen;
-                if (currentScreen instanceof CraftingScreen) {
+                if (currentScreen instanceof CraftingTableScreen) {
                     RecipeBookWidget recipeBookGui = ((RecipeBookProvider) currentScreen).getRecipeBookWidget();
                     RecipeBookGhostSlots ghostSlots = recipeBookGui.ghostSlots;
                     ghostSlots.reset();
@@ -213,12 +213,12 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                     }
                     
                     ghostSlots.addSlot(Ingredient.ofItems(Items.STONE), 381203812, 12738291);
-                    CraftingScreenHandler screenHandler = ((CraftingScreen) currentScreen).getScreenHandler();
+                    CraftingTableContainer container = ((CraftingTableScreen) currentScreen).getContainer();
                     for (int i = 0; i < input.size(); i++) {
                         List<ItemStack> stacks = input.get(i);
                         if (!stacks.isEmpty()) {
-                            Slot slot = screenHandler.getSlot(i + screenHandler.getCraftingResultSlotIndex() + 1);
-                            ghostSlots.addSlot(Ingredient.ofStacks(stacks.toArray(new ItemStack[0])), slot.x, slot.y);
+                            Slot slot = container.getSlot(i + container.getCraftingResultSlotIndex() + 1);
+                            ghostSlots.addSlot(Ingredient.ofStacks(stacks.toArray(new ItemStack[0])), slot.xPosition, slot.yPosition);
                         }
                     }
                 }
@@ -296,7 +296,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                     continue;
                 ActionResult result = decider.shouldScreenBeOverlayed(screen);
                 if (result != ActionResult.PASS)
-                    return result == ActionResult.FAIL || REIHelper.getInstance().getPreviousHandledScreen() == null;
+                    return result == ActionResult.FAIL || REIHelper.getInstance().getPreviousContainerScreen() == null;
             }
         } catch (ConcurrentModificationException ignored) {
         }
@@ -308,7 +308,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
         long[] lastSync = {-1};
         ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> syncRecipes(lastSync));
         ClothClientHooks.SCREEN_ADD_BUTTON.register((minecraftClient, screen, abstractButtonWidget) -> {
-            if (ConfigObject.getInstance().doesDisableRecipeBook() && screen instanceof HandledScreen && abstractButtonWidget instanceof TexturedButtonWidget)
+            if (ConfigObject.getInstance().doesDisableRecipeBook() && screen instanceof ContainerScreen && abstractButtonWidget instanceof TexturedButtonWidget)
                 if (((TexturedButtonWidget) abstractButtonWidget).texture.equals(recipeButtonTex))
                     return ActionResult.FAIL;
             return ActionResult.PASS;
@@ -318,8 +318,8 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                 return;
             if (screen instanceof InventoryScreen && minecraftClient.interactionManager.hasCreativeInventory())
                 return;
-            if (screen instanceof HandledScreen)
-                ScreenHelper.setLastHandledScreen((HandledScreen<?>) screen);
+            if (screen instanceof ContainerScreen)
+                ScreenHelper.setPreviousContainerScreen((ContainerScreen<?>) screen);
             boolean alreadyAdded = false;
             for (Element element : Lists.newArrayList(screenHooks.cloth_getChildren()))
                 if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass()))
@@ -385,9 +385,9 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                 return ActionResult.PASS;
             if (ScreenHelper.getLastOverlay().keyPressed(i, i1, i2))
                 return ActionResult.SUCCESS;
-            if (screen instanceof HandledScreen && ConfigObject.getInstance().doesDisableRecipeBook() && ConfigObject.getInstance().doesFixTabCloseContainer())
+            if (screen instanceof ContainerScreen && ConfigObject.getInstance().doesDisableRecipeBook() && ConfigObject.getInstance().doesFixTabCloseContainer())
                 if (i == 258 && minecraftClient.options.keyInventory.matchesKey(i, i1)) {
-                    minecraftClient.player.closeHandledScreen();
+                    minecraftClient.player.closeContainer();
                     return ActionResult.SUCCESS;
                 }
             return ActionResult.PASS;

+ 12 - 12
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java

@@ -31,11 +31,11 @@ import me.shedaniel.rei.server.InputSlotCrafter;
 import net.fabricmc.api.ModInitializer;
 import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
 import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.container.Container;
+import net.minecraft.container.CraftingContainer;
+import net.minecraft.container.PlayerContainer;
 import net.minecraft.item.ItemStack;
 import net.minecraft.network.PacketByteBuf;
-import net.minecraft.screen.AbstractRecipeScreenHandler;
-import net.minecraft.screen.PlayerScreenHandler;
-import net.minecraft.screen.ScreenHandler;
 import net.minecraft.server.network.ServerPlayerEntity;
 import net.minecraft.text.TranslatableText;
 import net.minecraft.util.Formatting;
@@ -65,7 +65,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
             ServerSidePacketRegistry.INSTANCE.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
                 ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer();
                 if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) {
-                    player.sendMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false);
+                    player.addMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false);
                     return;
                 }
                 if (!player.inventory.getCursorStack().isEmpty())
@@ -74,20 +74,20 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
             ServerSidePacketRegistry.INSTANCE.register(CREATE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
                 ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer();
                 if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) {
-                    player.sendMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false);
+                    player.addMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false);
                     return;
                 }
                 ItemStack stack = packetByteBuf.readItemStack();
                 if (player.inventory.insertStack(stack.copy())) {
                     ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(stack.copy()).writeString(player.getEntityName(), 32767));
                 } else
-                    player.sendMessage(new TranslatableText("text.rei.failed_cheat_items"), false);
+                    player.addMessage(new TranslatableText("text.rei.failed_cheat_items"), false);
             });
             ServerSidePacketRegistry.INSTANCE.register(MOVE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
                 Identifier category = packetByteBuf.readIdentifier();
                 ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer();
-                ScreenHandler screenHandler = player.currentScreenHandler;
-                PlayerScreenHandler playerScreenHandler = player.playerScreenHandler;
+                Container container = player.container;
+                PlayerContainer playerContainer = player.playerContainer;
                 try {
                     boolean shift = packetByteBuf.readBoolean();
                     Map<Integer, List<ItemStack>> input = Maps.newHashMap();
@@ -101,9 +101,9 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                         input.put(i, list);
                     }
                     try {
-                        InputSlotCrafter.start(category, screenHandler, player, input, shift);
+                        InputSlotCrafter.start(category, container, player, input, shift);
                     } catch (InputSlotCrafter.NotEnoughMaterialsException e) {
-                        if (!(screenHandler instanceof AbstractRecipeScreenHandler))
+                        if (!(container instanceof CraftingContainer))
                             return;
                         PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
                         buf.writeInt(input.size());
@@ -118,9 +118,9 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
                             ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NOT_ENOUGH_ITEMS_PACKET, buf);
                         }
                     } catch (IllegalStateException e) {
-                        player.sendSystemMessage(new TranslatableText(e.getMessage()).formatted(Formatting.RED));
+                        player.sendMessage(new TranslatableText(e.getMessage()).formatted(Formatting.RED));
                     } catch (Exception e) {
-                        player.sendSystemMessage(new TranslatableText("error.rei.internal.error", e.getMessage()).formatted(Formatting.RED));
+                        player.sendMessage(new TranslatableText("error.rei.internal.error", e.getMessage()).formatted(Formatting.RED));
                         e.printStackTrace();
                     }
                 } catch (Exception e) {

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

@@ -79,7 +79,6 @@ public class RoughlyEnoughItemsState {
         }
     }
     
-    @SuppressWarnings({"Convert2MethodRef", "FunctionalExpressionCanBeFolded"})
     public static void onContinue(Runnable runnable) {
         continueCallbacks.add(runnable);
     }

+ 22 - 12
src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java

@@ -26,8 +26,8 @@ package me.shedaniel.rei.api;
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.ints.IntList;
 import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
-import net.minecraft.screen.ScreenHandler;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
+import net.minecraft.container.Container;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.function.Supplier;
@@ -80,8 +80,8 @@ public interface AutoTransferHandler {
     }
     
     interface Context {
-        static Context create(boolean actuallyCrafting, HandledScreen<?> handledScreen, RecipeDisplay recipeDisplay) {
-            return new ContextImpl(actuallyCrafting, handledScreen, () -> recipeDisplay);
+        static Context create(boolean actuallyCrafting, ContainerScreen<?> containerScreen, RecipeDisplay recipeDisplay) {
+            return new ContextImpl(actuallyCrafting, containerScreen, () -> recipeDisplay);
         }
         
         default MinecraftClient getMinecraft() {
@@ -90,12 +90,22 @@ public interface AutoTransferHandler {
         
         boolean isActuallyCrafting();
         
-        HandledScreen<?> getHandledScreen();
+        ContainerScreen<?> getContainerScreen();
+        
+        @Deprecated
+        default ContainerScreen<?> getHandledScreen() {
+            return getContainerScreen();
+        }
         
         RecipeDisplay getRecipe();
         
-        default ScreenHandler getScreenHandler() {
-            return getHandledScreen().getScreenHandler();
+        @Deprecated
+        default Container getScreenHandler() {
+            return getContainer();
+        }
+        
+        default Container getContainer() {
+            return getHandledScreen().getContainer();
         }
     }
     
@@ -154,12 +164,12 @@ public interface AutoTransferHandler {
     @ApiStatus.Internal
     final class ContextImpl implements Context {
         boolean actuallyCrafting;
-        HandledScreen<?> handledScreen;
+        ContainerScreen<?> containerScreen;
         Supplier<RecipeDisplay> recipeDisplaySupplier;
         
-        private ContextImpl(boolean actuallyCrafting, HandledScreen<?> handledScreen, Supplier<RecipeDisplay> recipeDisplaySupplier) {
+        private ContextImpl(boolean actuallyCrafting, ContainerScreen<?> containerScreen, Supplier<RecipeDisplay> recipeDisplaySupplier) {
             this.actuallyCrafting = actuallyCrafting;
-            this.handledScreen = handledScreen;
+            this.containerScreen = containerScreen;
             this.recipeDisplaySupplier = recipeDisplaySupplier;
         }
         
@@ -169,8 +179,8 @@ public interface AutoTransferHandler {
         }
         
         @Override
-        public HandledScreen<?> getHandledScreen() {
-            return handledScreen;
+        public ContainerScreen<?> getContainerScreen() {
+            return containerScreen;
         }
         
         @Override

+ 7 - 2
src/main/java/me/shedaniel/rei/api/REIHelper.java

@@ -26,7 +26,7 @@ package me.shedaniel.rei.api;
 import me.shedaniel.rei.api.widgets.Tooltip;
 import me.shedaniel.rei.gui.widget.TextFieldWidget;
 import me.shedaniel.rei.impl.ScreenHelper;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.item.ItemStack;
 import org.jetbrains.annotations.Nullable;
 
@@ -41,7 +41,12 @@ public interface REIHelper {
         return ScreenHelper.getInstance();
     }
     
-    HandledScreen<?> getPreviousHandledScreen();
+    ContainerScreen<?> getPreviousContainerScreen();
+    
+    @Deprecated
+    default ContainerScreen<?> getPreviousHandledScreen() {
+        return getPreviousContainerScreen();
+    }
     
     boolean isDarkThemeEnabled();
     

+ 3 - 3
src/main/java/me/shedaniel/rei/api/RecipeHelper.java

@@ -25,7 +25,7 @@ package me.shedaniel.rei.api;
 
 import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.recipe.Recipe;
 import net.minecraft.recipe.RecipeManager;
 import net.minecraft.util.Identifier;
@@ -221,7 +221,7 @@ public interface RecipeHelper {
      */
     void registerLiveRecipeGenerator(LiveRecipeGenerator<?> liveRecipeGenerator);
     
-    void registerScreenClickArea(Rectangle rectangle, Class<? extends HandledScreen<?>> screenClass, Identifier... categories);
+    void registerScreenClickArea(Rectangle rectangle, Class<? extends ContainerScreen<?>> screenClass, Identifier... categories);
     
     <T extends Recipe<?>> void registerRecipes(Identifier category, Class<T> recipeClass, Function<T, RecipeDisplay> mappingFunction);
     
@@ -233,7 +233,7 @@ public interface RecipeHelper {
     boolean arePluginsLoading();
     
     interface ScreenClickArea {
-        Class<? extends HandledScreen> getScreenClass();
+        Class<? extends ContainerScreen> getScreenClass();
         
         Rectangle getRectangle();
         

+ 2 - 3
src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java

@@ -24,8 +24,7 @@
 package me.shedaniel.rei.api;
 
 import me.shedaniel.rei.server.ContainerInfo;
-import net.minecraft.screen.ScreenHandler;
-
+import net.minecraft.container.Container;
 import java.util.List;
 
 public interface TransferRecipeDisplay extends RecipeDisplay {
@@ -40,6 +39,6 @@ public interface TransferRecipeDisplay extends RecipeDisplay {
      */
     int getHeight();
     
-    List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container);
+    List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<Container> containerInfo, Container container);
     
 }

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

@@ -47,7 +47,7 @@ import net.minecraft.block.Blocks;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.render.Tessellator;
 import net.minecraft.client.render.VertexConsumerProvider;
 import net.minecraft.client.render.item.ItemRenderer;
@@ -234,7 +234,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
                                 ClientHelper.getInstance().setCheating(!ClientHelper.getInstance().isCheating());
                                 return;
                             }
-                            ConfigManager.getInstance().openConfigScreen(REIHelper.getInstance().getPreviousHandledScreen());
+                            ConfigManager.getInstance().openConfigScreen(REIHelper.getInstance().getPreviousContainerScreen());
                         })
                         .onRender((matrices, button) -> {
                             if (ClientHelper.getInstance().isCheating() && RoughlyEnoughItemsCore.hasOperatorPermission()) {
@@ -374,7 +374,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
                 VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
                 return new Rectangle(widget.bounds.x, 3, widget.bounds.width, 18);
             }
-            return new Rectangle(REIHelper.getInstance().getPreviousHandledScreen().x, 3, REIHelper.getInstance().getPreviousHandledScreen().backgroundWidth, 18);
+            return new Rectangle(REIHelper.getInstance().getPreviousContainerScreen().x, 3, REIHelper.getInstance().getPreviousContainerScreen().containerWidth, 18);
         }
         return null;
     }
@@ -443,7 +443,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
             VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) MinecraftClient.getInstance().currentScreen;
             return new Rectangle(widget.bounds.x, window.getScaledHeight() - 22, widget.bounds.width - widthRemoved, 18);
         }
-        return new Rectangle(REIHelper.getInstance().getPreviousHandledScreen().x, window.getScaledHeight() - 22, REIHelper.getInstance().getPreviousHandledScreen().backgroundWidth - widthRemoved, 18);
+        return new Rectangle(REIHelper.getInstance().getPreviousContainerScreen().x, window.getScaledHeight() - 22, REIHelper.getInstance().getPreviousContainerScreen().containerWidth - widthRemoved, 18);
     }
     
     private Rectangle getCraftableToggleArea() {
@@ -494,22 +494,22 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
         if (OverlaySearchField.isSearching) {
             matrices.push();
             matrices.translate(0, 0, 200f);
-            if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) {
-                HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
-                int x = handledScreen.x, y = handledScreen.y;
-                for (Slot slot : handledScreen.getScreenHandler().slots)
+            if (MinecraftClient.getInstance().currentScreen instanceof ContainerScreen) {
+                ContainerScreen<?> containerScreen = (ContainerScreen<?>) MinecraftClient.getInstance().currentScreen;
+                int x = containerScreen.x, y = containerScreen.y;
+                for (Slot slot : containerScreen.getContainer().slots)
                     if (!slot.hasStack() || !ENTRY_LIST_WIDGET.canLastSearchTermsBeAppliedTo(EntryStack.create(slot.getStack())))
-                        fillGradient(matrices, x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, -601874400, -601874400);
+                        fillGradient(matrices, x + slot.xPosition, y + slot.yPosition, x + slot.xPosition + 16, y + slot.yPosition + 16, -601874400, -601874400);
             }
             matrices.pop();
         }
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         this.renderWidgets(matrices, mouseX, mouseY, delta);
-        if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
-            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
+        if (MinecraftClient.getInstance().currentScreen instanceof ContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
+            ContainerScreen<?> containerScreen = (ContainerScreen<?>) MinecraftClient.getInstance().currentScreen;
             for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas())
                 if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass()))
-                    if (area.getRectangle().contains(mouseX - handledScreen.x, mouseY - handledScreen.y)) {
+                    if (area.getRectangle().contains(mouseX - containerScreen.x, mouseY - containerScreen.y)) {
                         String collect = CollectionUtils.mapAndJoinToString(area.getCategories(), identifier -> RecipeHelper.getInstance().getCategory(identifier).getCategoryName(), ", ");
                         TOOLTIPS.add(Tooltip.create(new TranslatableText("text.rei.view_recipes_for", collect)));
                         break;
@@ -640,10 +640,10 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
             return true;
         }
         ItemStack itemStack = null;
-        if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) {
-            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
-            if (handledScreen.focusedSlot != null && !handledScreen.focusedSlot.getStack().isEmpty())
-                itemStack = handledScreen.focusedSlot.getStack();
+        if (MinecraftClient.getInstance().currentScreen instanceof ContainerScreen) {
+            ContainerScreen<?> containerScreen = (ContainerScreen<?>) MinecraftClient.getInstance().currentScreen;
+            if (containerScreen.focusedSlot != null && !containerScreen.focusedSlot.getStack().isEmpty())
+                itemStack = containerScreen.focusedSlot.getStack();
         }
         if (itemStack != null && !itemStack.isEmpty()) {
             if (ConfigObject.getInstance().getRecipeKeybind().matchesKey(int_1, int_2))
@@ -713,11 +713,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds {
                 removeGameModeMenu();
             }
         }
-        if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
-            HandledScreen<?> handledScreen = (HandledScreen<?>) MinecraftClient.getInstance().currentScreen;
+        if (MinecraftClient.getInstance().currentScreen instanceof ContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
+            ContainerScreen<?> containerScreen = (ContainerScreen<?>) MinecraftClient.getInstance().currentScreen;
             for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas())
-                if (area.getScreenClass().equals(handledScreen.getClass()))
-                    if (area.getRectangle().contains(double_1 - handledScreen.x, double_2 - handledScreen.y)) {
+                if (area.getScreenClass().equals(containerScreen.getClass()))
+                    if (area.getRectangle().contains(double_1 - containerScreen.x, double_2 - containerScreen.y)) {
                         ClientHelper.getInstance().executeViewAllRecipesFromCategories(Arrays.asList(area.getCategories()));
                         MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                         return true;

+ 3 - 3
src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java

@@ -37,7 +37,7 @@ import me.shedaniel.rei.impl.ScreenHelper;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.util.NarratorManager;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.text.Text;
@@ -127,7 +127,7 @@ public class PreRecipeViewingScreen extends Screen {
         this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 20, 16777215);
         if (showTips) {
             int i = 30;
-            for (Text s : this.textRenderer.wrapLines(new TranslatableText("text.rei.recipe_screen_type.selection.sub").formatted(Formatting.GRAY), width - 30)) {
+            for (Text s : this.textRenderer.wrapStringToWidthAsList(new TranslatableText("text.rei.recipe_screen_type.selection.sub").formatted(Formatting.GRAY), width - 30)) {
                 this.drawCenteredText(matrices, this.textRenderer, s, width / 2, i, -1);
                 i += 10;
             }
@@ -163,7 +163,7 @@ public class PreRecipeViewingScreen extends Screen {
     public boolean keyPressed(int int_1, int int_2, int int_3) {
         if (int_1 == 256 || this.client.options.keyInventory.matchesKey(int_1, int_2)) {
             MinecraftClient.getInstance().openScreen(parent);
-            if (parent instanceof HandledScreen)
+            if (parent instanceof ContainerScreen)
                 ScreenHelper.getLastOverlay().init();
             return true;
         }

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

@@ -193,7 +193,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
             if (element.keyPressed(int_1, int_2, int_3))
                 return true;
         if (int_1 == 256 || this.client.options.keyInventory.matchesKey(int_1, int_2)) {
-            MinecraftClient.getInstance().openScreen(ScreenHelper.getLastHandledScreen());
+            MinecraftClient.getInstance().openScreen(REIHelper.getInstance().getPreviousContainerScreen());
             ScreenHelper.getLastOverlay().init();
             return true;
         }
@@ -201,7 +201,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen {
             if (ScreenHelper.hasLastRecipeScreen())
                 client.openScreen(ScreenHelper.getLastRecipeScreen());
             else
-                client.openScreen(ScreenHelper.getLastHandledScreen());
+                client.openScreen(REIHelper.getInstance().getPreviousContainerScreen());
             return true;
         }
         return super.keyPressed(int_1, int_2, int_3);

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

@@ -399,7 +399,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen
             if (element.keyPressed(int_1, int_2, int_3))
                 return true;
         if (int_1 == 256 || this.client.options.keyInventory.matchesKey(int_1, int_2)) {
-            MinecraftClient.getInstance().openScreen(ScreenHelper.getLastHandledScreen());
+            MinecraftClient.getInstance().openScreen(REIHelper.getInstance().getPreviousContainerScreen());
             ScreenHelper.getLastOverlay().init();
             return true;
         }
@@ -407,7 +407,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen
             if (ScreenHelper.hasLastRecipeScreen())
                 client.openScreen(ScreenHelper.getLastRecipeScreen());
             else
-                client.openScreen(ScreenHelper.getLastHandledScreen());
+                client.openScreen(REIHelper.getInstance().getPreviousContainerScreen());
             return true;
         }
         return super.keyPressed(int_1, int_2, int_3);

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

@@ -66,13 +66,13 @@ public class WarningAndErrorScreen extends Screen {
     }
     
     private void addText(Text string) {
-        for (Text s : textRenderer.wrapLines(string, width - 80)) {
+        for (Text s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
             listWidget.creditsAddEntry(new TextItem(s));
         }
     }
     
     private void addLink(Text string, String link) {
-        for (Text s : textRenderer.wrapLines(string, width - 80)) {
+        for (Text s : textRenderer.wrapStringToWidthAsList(string, width - 80)) {
             listWidget.creditsAddEntry(new LinkItem(s.getString(), link));
         }
     }

+ 1 - 1
src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java

@@ -113,7 +113,7 @@ public class CreditsEntryListWidget extends DynamicNewSmoothScrollingEntryListWi
         
         public TranslationCreditsItem(Text language, Text translators, int width, int maxWidth) {
             this.language = language;
-            this.translators = MinecraftClient.getInstance().textRenderer.wrapLines(translators, width);
+            this.translators = MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(translators, width);
             this.maxWidth = maxWidth;
         }
         

+ 3 - 3
src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java

@@ -30,7 +30,7 @@ import me.shedaniel.rei.impl.ScreenHelper;
 import net.fabricmc.loader.api.FabricLoader;
 import net.fabricmc.loader.api.metadata.CustomValue;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.client.util.NarratorManager;
@@ -61,7 +61,7 @@ public class CreditsScreen extends Screen {
     public boolean keyPressed(int int_1, int int_2, int int_3) {
         if (int_1 == 256 && this.shouldCloseOnEsc()) {
             this.client.openScreen(parent);
-            if (parent instanceof HandledScreen)
+            if (parent instanceof ContainerScreen)
                 ScreenHelper.getLastOverlay().init();
             return true;
         }
@@ -115,7 +115,7 @@ public class CreditsScreen extends Screen {
             @Override
             public void onPress() {
                 CreditsScreen.this.client.openScreen(parent);
-                if (parent instanceof HandledScreen)
+                if (parent instanceof ContainerScreen)
                     ScreenHelper.getLastOverlay().init();
             }
         });

+ 0 - 3
src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java

@@ -36,9 +36,7 @@ import me.shedaniel.rei.impl.ScreenHelper;
 import me.shedaniel.rei.utils.CollectionUtils;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.resource.language.I18n;
-import net.minecraft.client.sound.PositionedSoundInstance;
 import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.sound.SoundEvents;
 import net.minecraft.text.LiteralText;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.math.MathHelper;
@@ -389,7 +387,6 @@ public class EntryWidget extends Slot {
                     } else {
                         ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
                     }
-                    minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                     return true;
                 }
             }

+ 2 - 2
src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java

@@ -177,7 +177,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
             String madeUpCommand = og.replaceAll("\\{player_name}", MinecraftClient.getInstance().player.getEntityName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", tagMessage).replaceAll("\\{count}", String.valueOf(cheatedStack.getCount()));
             if (madeUpCommand.length() > 256) {
                 madeUpCommand = og.replaceAll("\\{player_name}", MinecraftClient.getInstance().player.getEntityName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", "").replaceAll("\\{count}", String.valueOf(cheatedStack.getCount()));
-                MinecraftClient.getInstance().player.sendMessage(new TranslatableText("text.rei.too_long_nbt"), false);
+                MinecraftClient.getInstance().player.addMessage(new TranslatableText("text.rei.too_long_nbt"), false);
             }
             MinecraftClient.getInstance().player.sendChatMessage(madeUpCommand);
             return true;
@@ -260,7 +260,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
             screen = new VillagerRecipeViewingScreen(map, category);
         } else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) {
             @Nullable Identifier finalCategory = category;
-            screen = new PreRecipeViewingScreen(REIHelper.getInstance().getPreviousHandledScreen(), RecipeScreenType.UNSET, true, original -> {
+            screen = new PreRecipeViewingScreen(REIHelper.getInstance().getPreviousContainerScreen(), RecipeScreenType.UNSET, true, original -> {
                 ConfigObject.getInstance().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER);
                 ConfigManager.getInstance().saveConfig();
                 openRecipeViewingScreen(map, finalCategory, ingredientNotice, resultNotice);

+ 1 - 1
src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java

@@ -117,7 +117,7 @@ public class ConfigManagerImpl implements ConfigManager {
                         Collections.singletonList(new RecipeScreenTypeEntry(220, new TranslatableText(i13n), getUnsafely(field, config, RecipeScreenType.UNSET), getUnsafely(field, defaults), type -> setUnsafely(field, config, type)))
                 , (field) -> field.getType() == RecipeScreenType.class, ConfigObjectImpl.UseSpecialRecipeTypeScreen.class);
         guiRegistry.registerAnnotationProvider((i13n, field, config, defaults, guiProvider) ->
-                        REIHelper.getInstance().getPreviousHandledScreen() == null || MinecraftClient.getInstance().getNetworkHandler() == null || MinecraftClient.getInstance().getNetworkHandler().getRecipeManager() == null ?
+                        REIHelper.getInstance().getPreviousContainerScreen() == null || MinecraftClient.getInstance().getNetworkHandler() == null || MinecraftClient.getInstance().getNetworkHandler().getRecipeManager() == null ?
                                 Collections.singletonList(new NoFilteringEntry(getUnsafely(field, config, new ArrayList<>()), getUnsafely(field, defaults), list -> setUnsafely(field, config, list)))
                                 :
                                 Collections.singletonList(new FilteringEntry(getUnsafely(field, config, new ArrayList<>()), getUnsafely(field, defaults), list -> setUnsafely(field, config, list)))

+ 5 - 2
src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java

@@ -32,6 +32,9 @@ import me.shedaniel.clothconfig2.api.ModifierKeyCode;
 import me.shedaniel.rei.api.ConfigObject;
 import me.shedaniel.rei.api.EntryStack;
 import me.shedaniel.rei.gui.config.*;
+import me.shedaniel.rei.impl.ConfigObjectImpl.DontApplyFieldName;
+import me.shedaniel.rei.impl.ConfigObjectImpl.UseFilteringScreen;
+import me.shedaniel.rei.impl.ConfigObjectImpl.UseSpecialRecipeTypeScreen;
 import net.minecraft.client.util.InputUtil;
 import org.jetbrains.annotations.ApiStatus;
 
@@ -399,7 +402,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
         @Comment("Declares whether favorites will be searched.") private boolean searchFavorites = true;
         @UsePercentage(min = 0.25, max = 4.0) private double entrySize = 1.0;
         private boolean useCompactTabs = true;
-        private boolean lowerConfigButton = false;
+        private boolean lowerConfigButton = true;
         @Comment("Declares whether REI should resize its recipe window dynamically")
         private boolean resizeDynamically = false;
     }
@@ -415,7 +418,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
     }
     
     public static class Modules {
-        @Comment("Declares whether the craftable filter button is enabled.") private boolean enableCraftableOnlyButton = true;
+        @Comment("Declares whether the craftable filter button is enabled.") private boolean enableCraftableOnlyButton = false;
         private boolean toastDisplayedOnCopyIdentifier = true;
         @Comment("Declares whether the utils buttons are shown.") private boolean showUtilsButtons = false;
         @Comment("Declares whether REI should remove the recipe book.") private boolean disableRecipeBook = false;

+ 1 - 1
src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java

@@ -126,7 +126,7 @@ public class EntryRegistryImpl implements EntryRegistry {
     public ItemStack[] getAllStacksFromItem(Item item) {
         List<ItemStack> list = appendStacksForItem(item);
         ItemStack[] array = list.toArray(new ItemStack[0]);
-        Arrays.sort(array, (a, b) -> ItemStack.areEqual(a, b) ? 0 : 1);
+        Arrays.sort(array, (a, b) -> ItemStack.areEqualIgnoreDamage(a, b) ? 0 : 1);
         return array;
     }
     

+ 5 - 5
src/main/java/me/shedaniel/rei/impl/InternalWidgets.java

@@ -37,7 +37,7 @@ import me.shedaniel.rei.gui.widget.WidgetWithBounds;
 import me.shedaniel.rei.utils.CollectionUtils;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.text.Text;
@@ -55,13 +55,13 @@ public final class InternalWidgets {
     private InternalWidgets() {}
     
     public static Widget createAutoCraftingButtonWidget(Rectangle displayBounds, Rectangle rectangle, Text text, Supplier<RecipeDisplay> displaySupplier, List<Widget> setupDisplay, RecipeCategory<?> category) {
-        HandledScreen<?> handledScreen = REIHelper.getInstance().getPreviousHandledScreen();
+        ContainerScreen<?> containerScreen = REIHelper.getInstance().getPreviousContainerScreen();
         boolean[] visible = {false};
         List<String>[] errorTooltip = new List[]{null};
         Button autoCraftingButton = Widgets.createButton(rectangle, text)
                 .focusable(false)
                 .onClick(button -> {
-                    AutoTransferHandler.Context context = AutoTransferHandler.Context.create(true, handledScreen, displaySupplier.get());
+                    AutoTransferHandler.Context context = AutoTransferHandler.Context.create(true, containerScreen, displaySupplier.get());
                     for (AutoTransferHandler autoTransferHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler())
                         try {
                             AutoTransferHandler.Result result = autoTransferHandler.handle(context);
@@ -70,7 +70,7 @@ public final class InternalWidgets {
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                    MinecraftClient.getInstance().openScreen(handledScreen);
+                    MinecraftClient.getInstance().openScreen(containerScreen);
                     ScreenHelper.getLastOverlay().init();
                 })
                 .onRender((matrices, button) -> {
@@ -79,7 +79,7 @@ public final class InternalWidgets {
                     int color = 0;
                     visible[0] = false;
                     IntList redSlots = null;
-                    AutoTransferHandler.Context context = AutoTransferHandler.Context.create(false, handledScreen, displaySupplier.get());
+                    AutoTransferHandler.Context context = AutoTransferHandler.Context.create(false, containerScreen, displaySupplier.get());
                     for (AutoTransferHandler autoTransferHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler()) {
                         try {
                             AutoTransferHandler.Result result = autoTransferHandler.handle(context);

+ 6 - 6
src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java

@@ -34,7 +34,7 @@ import me.shedaniel.rei.api.plugins.REIPluginV0;
 import me.shedaniel.rei.api.subsets.SubsetsRegistry;
 import me.shedaniel.rei.impl.subsets.SubsetsRegistryImpl;
 import me.shedaniel.rei.utils.CollectionUtils;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.recipe.Recipe;
 import net.minecraft.recipe.RecipeManager;
 import net.minecraft.util.ActionResult;
@@ -360,7 +360,7 @@ public class RecipeHelperImpl implements RecipeHelper {
             
             @Override
             public ActionResult shouldScreenBeOverlayed(Class<?> screen) {
-                return HandledScreen.class.isAssignableFrom(screen) ? ActionResult.SUCCESS : ActionResult.PASS;
+                return ContainerScreen.class.isAssignableFrom(screen) ? ActionResult.SUCCESS : ActionResult.PASS;
             }
             
             @Override
@@ -466,7 +466,7 @@ public class RecipeHelperImpl implements RecipeHelper {
     }
     
     @Override
-    public void registerScreenClickArea(Rectangle rectangle, Class<? extends HandledScreen<?>> screenClass, Identifier... categories) {
+    public void registerScreenClickArea(Rectangle rectangle, Class<? extends ContainerScreen<?>> screenClass, Identifier... categories) {
         this.screenClickAreas.add(new ScreenClickAreaImpl(screenClass, rectangle, categories));
     }
     
@@ -498,17 +498,17 @@ public class RecipeHelperImpl implements RecipeHelper {
     }
     
     private static class ScreenClickAreaImpl implements ScreenClickArea {
-        Class<? extends HandledScreen<?>> screenClass;
+        Class<? extends ContainerScreen<?>> screenClass;
         Rectangle rectangle;
         Identifier[] categories;
         
-        private ScreenClickAreaImpl(Class<? extends HandledScreen<?>> screenClass, Rectangle rectangle, Identifier[] categories) {
+        private ScreenClickAreaImpl(Class<? extends ContainerScreen<?>> screenClass, Rectangle rectangle, Identifier[] categories) {
             this.screenClass = screenClass;
             this.rectangle = rectangle;
             this.categories = categories;
         }
         
-        public Class<? extends HandledScreen<?>> getScreenClass() {
+        public Class<? extends ContainerScreen<?>> getScreenClass() {
             return screenClass;
         }
         

+ 11 - 11
src/main/java/me/shedaniel/rei/impl/ScreenHelper.java

@@ -44,7 +44,7 @@ import net.fabricmc.fabric.api.event.client.ClientTickCallback;
 import net.fabricmc.loader.api.FabricLoader;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.util.Window;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.item.ItemStack;
@@ -64,7 +64,7 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
     @ApiStatus.Internal
     public static List<ItemStack> inventoryStacks = Lists.newArrayList();
     private static ContainerScreenOverlay overlay;
-    private static HandledScreen<?> lastHandledScreen = null;
+    private static ContainerScreen<?> previousContainerScreen = null;
     private static LinkedHashSet<RecipeScreen> lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(5);
     private static ScreenHelper instance;
     
@@ -152,21 +152,21 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
     }
     
     /**
-     * @see REIHelper#getPreviousHandledScreen()
+     * @see REIHelper#getPreviousContainerScreen()
      */
     @Deprecated
     @ApiStatus.ScheduledForRemoval
-    public static HandledScreen<?> getLastHandledScreen() {
-        return lastHandledScreen;
+    public static ContainerScreen<?> getLastHandledScreen() {
+        return previousContainerScreen;
     }
     
     @Override
-    public HandledScreen<?> getPreviousHandledScreen() {
-        return lastHandledScreen;
+    public ContainerScreen<?> getPreviousContainerScreen() {
+        return previousContainerScreen;
     }
     
-    public static void setLastHandledScreen(HandledScreen<?> lastScreenWithHandler) {
-        ScreenHelper.lastHandledScreen = lastScreenWithHandler;
+    public static void setPreviousContainerScreen(ContainerScreen<?> previousContainerScreen) {
+        ScreenHelper.previousContainerScreen = previousContainerScreen;
     }
     
     public static void drawHoveringWidget(MatrixStack matrices, int x, int y, TriConsumer<MatrixStack, Point, Float> consumer, int width, int height, float delta) {
@@ -215,8 +215,8 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
                 }
                 client.currentScreen = null;
                 client.openScreen(warningAndErrorScreen);
-            } else if (lastHandledScreen != screen && screen instanceof HandledScreen)
-                lastHandledScreen = (HandledScreen<?>) screen;
+            } else if (previousContainerScreen != screen && screen instanceof ContainerScreen)
+                previousContainerScreen = (ContainerScreen<?>) screen;
             return ActionResult.PASS;
         });
         boolean loaded = FabricLoader.getInstance().isModLoaded("fabric-events-lifecycle-v0");

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

@@ -299,20 +299,20 @@ public class DefaultPlugin implements REIPluginV0 {
                 return Collections.emptyList();
             return Collections.singletonList(widget.getBounds().clone());
         });
-        displayHelper.registerHandler(new DisplayHelper.DisplayBoundsHandler<HandledScreen<?>>() {
+        displayHelper.registerHandler(new DisplayHelper.DisplayBoundsHandler<ContainerScreen<?>>() {
             @Override
             public Class<?> getBaseSupportedClass() {
-                return HandledScreen.class;
+                return ContainerScreen.class;
             }
             
             @Override
-            public Rectangle getLeftBounds(HandledScreen<?> screen) {
+            public Rectangle getLeftBounds(ContainerScreen<?> screen) {
                 return new Rectangle(2, 0, screen.x - 4, screen.height);
             }
             
             @Override
-            public Rectangle getRightBounds(HandledScreen<?> screen) {
-                int startX = screen.x + screen.backgroundWidth + 2;
+            public Rectangle getRightBounds(ContainerScreen<?> screen) {
+                int startX = screen.x + screen.containerWidth + 2;
                 return new Rectangle(startX, 0, screen.width - startX - 2, screen.height);
             }
             
@@ -392,7 +392,7 @@ public class DefaultPlugin implements REIPluginV0 {
         recipeHelper.removeAutoCraftButton(COMPOSTING);
         recipeHelper.removeAutoCraftButton(BEACON);
         recipeHelper.removeAutoCraftButton(INFO);
-        recipeHelper.registerScreenClickArea(new Rectangle(88, 32, 28, 23), CraftingScreen.class, CRAFTING);
+        recipeHelper.registerScreenClickArea(new Rectangle(88, 32, 28, 23), CraftingTableScreen.class, CRAFTING);
         recipeHelper.registerScreenClickArea(new Rectangle(137, 29, 10, 13), InventoryScreen.class, CRAFTING);
         recipeHelper.registerScreenClickArea(new Rectangle(97, 16, 14, 30), BrewingStandScreen.class, BREWING);
         recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), FurnaceScreen.class, SMELTING);

+ 5 - 5
src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java

@@ -28,7 +28,7 @@ import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.api.REIHelper;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.entity.effect.StatusEffectInstance;
 
 import java.util.ArrayList;
@@ -40,15 +40,15 @@ import java.util.function.Supplier;
 public class DefaultPotionEffectExclusionZones implements Supplier<List<Rectangle>> {
     @Override
     public List<Rectangle> get() {
-        if (!(REIHelper.getInstance().getPreviousHandledScreen() instanceof AbstractInventoryScreen) || !((AbstractInventoryScreen<?>) REIHelper.getInstance().getPreviousHandledScreen()).drawStatusEffects)
+        if (!(REIHelper.getInstance().getPreviousContainerScreen() instanceof AbstractInventoryScreen) || !((AbstractInventoryScreen<?>) REIHelper.getInstance().getPreviousContainerScreen()).offsetGuiForEffects)
             return Collections.emptyList();
         Collection<StatusEffectInstance> activePotionEffects = MinecraftClient.getInstance().player.getStatusEffects();
         if (activePotionEffects.isEmpty())
             return Collections.emptyList();
-        HandledScreen<?> handledScreen = REIHelper.getInstance().getPreviousHandledScreen();
+        ContainerScreen<?> containerScreen = REIHelper.getInstance().getPreviousContainerScreen();
         List<Rectangle> list = new ArrayList<>();
-        int x = handledScreen.x - 124;
-        int y = handledScreen.y;
+        int x = containerScreen.x - 124;
+        int y = containerScreen.y;
         int height = 33;
         if (activePotionEffects.size() > 5)
             height = 132 / (activePotionEffects.size() - 1);

+ 7 - 7
src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java

@@ -27,10 +27,10 @@ import com.google.common.collect.Lists;
 import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.api.REIHelper;
 import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
 import net.minecraft.client.recipebook.ClientRecipeBook;
-import net.minecraft.screen.AbstractRecipeScreenHandler;
+import net.minecraft.container.CraftingContainer;
 
 import java.util.Collections;
 import java.util.List;
@@ -40,13 +40,13 @@ public class DefaultRecipeBookExclusionZones implements Supplier<List<Rectangle>
     
     @Override
     public List<Rectangle> get() {
-        if (!MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() || !(MinecraftClient.getInstance().currentScreen instanceof RecipeBookProvider) || !(REIHelper.getInstance().getPreviousHandledScreen().getScreenHandler() instanceof AbstractRecipeScreenHandler))
+        if (!MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() || !(MinecraftClient.getInstance().currentScreen instanceof RecipeBookProvider) || !(REIHelper.getInstance().getPreviousContainerScreen().getContainer() instanceof CraftingContainer))
             return Collections.emptyList();
-        HandledScreen<?> handledScreen = REIHelper.getInstance().getPreviousHandledScreen();
-        List<Rectangle> l = Lists.newArrayList(new Rectangle(handledScreen.x - 4 - 145, handledScreen.y, 4 + 145 + 30, handledScreen.backgroundHeight));
-        int size = ClientRecipeBook.getGroups((AbstractRecipeScreenHandler<?>) REIHelper.getInstance().getPreviousHandledScreen().getScreenHandler()).size();
+        ContainerScreen<?> containerScreen = REIHelper.getInstance().getPreviousContainerScreen();
+        List<Rectangle> l = Lists.newArrayList(new Rectangle(containerScreen.x - 4 - 145, containerScreen.y, 4 + 145 + 30, containerScreen.containerHeight));
+        int size = ClientRecipeBook.getGroupsForContainer((CraftingContainer<?>) REIHelper.getInstance().getPreviousContainerScreen().getContainer()).size();
         if (size > 0)
-            l.add(new Rectangle(handledScreen.x - 4 - 145 - 30, handledScreen.y, 30, size * 27));
+            l.add(new Rectangle(containerScreen.x - 4 - 145 - 30, containerScreen.y, 30, size * 27));
         return l;
     }
     

+ 6 - 6
src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java

@@ -25,16 +25,16 @@ package me.shedaniel.rei.plugin;
 
 import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper;
 import me.shedaniel.rei.server.ContainerInfoHandler;
-import net.minecraft.screen.*;
+import net.minecraft.container.*;
 import net.minecraft.util.Identifier;
 
 public class DefaultServerContainerPlugin implements Runnable {
     @Override
     public void run() {
-        ContainerInfoHandler.registerScreenWithHandlerInfo(new Identifier("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(CraftingScreenHandler.class));
-        ContainerInfoHandler.registerScreenWithHandlerInfo(new Identifier("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(PlayerScreenHandler.class));
-        ContainerInfoHandler.registerScreenWithHandlerInfo(new Identifier("minecraft", "plugins/smelting"), CraftingContainerInfoWrapper.create(FurnaceScreenHandler.class));
-        ContainerInfoHandler.registerScreenWithHandlerInfo(new Identifier("minecraft", "plugins/smoking"), CraftingContainerInfoWrapper.create(SmokerScreenHandler.class));
-        ContainerInfoHandler.registerScreenWithHandlerInfo(new Identifier("minecraft", "plugins/blasting"), CraftingContainerInfoWrapper.create(BlastFurnaceScreenHandler.class));
+        ContainerInfoHandler.registerContainerInfo(new Identifier("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(CraftingTableContainer.class));
+        ContainerInfoHandler.registerContainerInfo(new Identifier("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(PlayerContainer.class));
+        ContainerInfoHandler.registerContainerInfo(new Identifier("minecraft", "plugins/smelting"), CraftingContainerInfoWrapper.create(FurnaceContainer.class));
+        ContainerInfoHandler.registerContainerInfo(new Identifier("minecraft", "plugins/smoking"), CraftingContainerInfoWrapper.create(SmokerContainer.class));
+        ContainerInfoHandler.registerContainerInfo(new Identifier("minecraft", "plugins/blasting"), CraftingContainerInfoWrapper.create(BlastFurnaceContainer.class));
     }
 }

+ 11 - 11
src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java

@@ -35,12 +35,12 @@ import me.shedaniel.rei.server.ContainerInfoHandler;
 import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.gui.screen.ingame.ContainerScreen;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
 import net.minecraft.client.resource.language.I18n;
+import net.minecraft.container.Container;
 import net.minecraft.item.ItemStack;
 import net.minecraft.network.PacketByteBuf;
-import net.minecraft.screen.ScreenHandler;
 import net.minecraft.util.collection.DefaultedList;
 
 import java.util.List;
@@ -56,14 +56,14 @@ public class DefaultCategoryHandler implements AutoTransferHandler {
         if (!(context.getRecipe() instanceof TransferRecipeDisplay))
             return Result.createNotApplicable();
         TransferRecipeDisplay recipe = (TransferRecipeDisplay) context.getRecipe();
-        HandledScreen<?> handledScreen = context.getHandledScreen();
-        ScreenHandler screenHandler = context.getScreenHandler();
-        ContainerInfo<ScreenHandler> containerInfo = (ContainerInfo<ScreenHandler>) ContainerInfoHandler.getContainerInfo(recipe.getRecipeCategory(), screenHandler.getClass());
+        ContainerScreen<?> containerScreen = context.getContainerScreen();
+        Container container = context.getContainer();
+        ContainerInfo<Container> containerInfo = (ContainerInfo<Container>) ContainerInfoHandler.getContainerInfo(recipe.getRecipeCategory(), container.getClass());
         if (containerInfo == null)
             return Result.createNotApplicable();
-        if (recipe.getHeight() > containerInfo.getCraftingHeight(screenHandler) || recipe.getWidth() > containerInfo.getCraftingWidth(screenHandler))
-            return Result.createFailed(I18n.translate("error.rei.transfer.too_small", containerInfo.getCraftingWidth(screenHandler), containerInfo.getCraftingHeight(screenHandler)));
-        List<List<EntryStack>> input = recipe.getOrganisedInputEntries(containerInfo, screenHandler);
+        if (recipe.getHeight() > containerInfo.getCraftingHeight(container) || recipe.getWidth() > containerInfo.getCraftingWidth(container))
+            return Result.createFailed(I18n.translate("error.rei.transfer.too_small", containerInfo.getCraftingWidth(container), containerInfo.getCraftingHeight(container)));
+        List<List<EntryStack>> input = recipe.getOrganisedInputEntries(containerInfo, container);
         IntList intList = hasItems(input);
         if (!intList.isEmpty())
             return Result.createFailed("error.rei.not.enough.materials", intList);
@@ -72,9 +72,9 @@ public class DefaultCategoryHandler implements AutoTransferHandler {
         if (!context.isActuallyCrafting())
             return Result.createSuccessful();
         
-        context.getMinecraft().openScreen(handledScreen);
-        if (handledScreen instanceof RecipeBookProvider)
-            ((RecipeBookProvider) handledScreen).getRecipeBookWidget().ghostSlots.reset();
+        context.getMinecraft().openScreen(containerScreen);
+        if (containerScreen instanceof RecipeBookProvider)
+            ((RecipeBookProvider) containerScreen).getRecipeBookWidget().ghostSlots.reset();
         PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
         buf.writeIdentifier(recipe.getRecipeCategory());
         buf.writeBoolean(Screen.hasShiftDown());

+ 13 - 13
src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java

@@ -32,10 +32,10 @@ import me.shedaniel.rei.plugin.crafting.DefaultCraftingDisplay;
 import net.minecraft.client.gui.screen.Screen;
 import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
 import net.minecraft.client.resource.language.I18n;
+import net.minecraft.container.CraftingContainer;
+import net.minecraft.container.CraftingTableContainer;
+import net.minecraft.container.PlayerContainer;
 import net.minecraft.recipe.Recipe;
-import net.minecraft.screen.AbstractRecipeScreenHandler;
-import net.minecraft.screen.CraftingScreenHandler;
-import net.minecraft.screen.PlayerScreenHandler;
 
 public class DefaultRecipeBookHandler implements AutoTransferHandler {
     @Override
@@ -43,17 +43,17 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
         if (context.getRecipe() instanceof TransferRecipeDisplay && DefaultCategoryHandler.canUseMovePackets())
             return Result.createNotApplicable();
         RecipeDisplay display = context.getRecipe();
-        if (!(context.getScreenHandler() instanceof AbstractRecipeScreenHandler))
+        if (!(context.getContainer() instanceof CraftingContainer))
             return Result.createNotApplicable();
-        AbstractRecipeScreenHandler<?> container = (AbstractRecipeScreenHandler<?>) context.getScreenHandler();
+        CraftingContainer<?> container = (CraftingContainer<?>) context.getContainer();
         if (display instanceof DefaultCraftingDisplay) {
             DefaultCraftingDisplay craftingDisplay = (DefaultCraftingDisplay) display;
             if (craftingDisplay.getOptionalRecipe().isPresent()) {
                 int h = -1, w = -1;
-                if (container instanceof CraftingScreenHandler) {
+                if (container instanceof CraftingTableContainer) {
                     h = 3;
                     w = 3;
-                } else if (container instanceof PlayerScreenHandler) {
+                } else if (container instanceof PlayerContainer) {
                     h = 2;
                     w = 2;
                 }
@@ -66,9 +66,9 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
                     return Result.createFailed(I18n.translate("error.rei.recipe.not.unlocked"));
                 if (!context.isActuallyCrafting())
                     return Result.createSuccessful();
-                context.getMinecraft().openScreen(context.getHandledScreen());
-                if (context.getHandledScreen() instanceof RecipeBookProvider)
-                    ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget().ghostSlots.reset();
+                context.getMinecraft().openScreen(context.getContainerScreen());
+                if (context.getContainerScreen() instanceof RecipeBookProvider)
+                    ((RecipeBookProvider) context.getContainerScreen()).getRecipeBookWidget().ghostSlots.reset();
                 context.getMinecraft().interactionManager.clickRecipe(container.syncId, recipe, Screen.hasShiftDown());
                 ScreenHelper.getLastOverlay().init();
             }
@@ -80,9 +80,9 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
                     return Result.createFailed(I18n.translate("error.rei.recipe.not.unlocked"));
                 if (!context.isActuallyCrafting())
                     return Result.createSuccessful();
-                context.getMinecraft().openScreen(context.getHandledScreen());
-                if (context.getHandledScreen() instanceof RecipeBookProvider)
-                    ((RecipeBookProvider) context.getHandledScreen()).getRecipeBookWidget().ghostSlots.reset();
+                context.getMinecraft().openScreen(context.getContainerScreen());
+                if (context.getContainerScreen() instanceof RecipeBookProvider)
+                    ((RecipeBookProvider) context.getContainerScreen()).getRecipeBookWidget().ghostSlots.reset();
                 context.getMinecraft().interactionManager.clickRecipe(container.syncId, recipe, Screen.hasShiftDown());
                 ScreenHelper.getLastOverlay().init();
             }

+ 6 - 6
src/main/java/me/shedaniel/rei/plugin/containers/CraftingContainerInfoWrapper.java

@@ -25,23 +25,23 @@ package me.shedaniel.rei.plugin.containers;
 
 import me.shedaniel.rei.server.ContainerInfo;
 import me.shedaniel.rei.server.RecipeFinder;
+import net.minecraft.container.Container;
+import net.minecraft.container.CraftingContainer;
 import net.minecraft.item.ItemStack;
-import net.minecraft.screen.AbstractRecipeScreenHandler;
-import net.minecraft.screen.ScreenHandler;
 
-public class CraftingContainerInfoWrapper<T extends AbstractRecipeScreenHandler<?>> implements ContainerInfo<T> {
-    private Class<? extends AbstractRecipeScreenHandler<?>> containerClass;
+public class CraftingContainerInfoWrapper<T extends CraftingContainer<?>> implements ContainerInfo<T> {
+    private Class<? extends CraftingContainer<?>> containerClass;
     
     public CraftingContainerInfoWrapper(Class<T> containerClass) {
         this.containerClass = containerClass;
     }
     
-    public static <R extends AbstractRecipeScreenHandler<?>> ContainerInfo<R> create(Class<R> containerClass) {
+    public static <R extends CraftingContainer<?>> ContainerInfo<R> create(Class<R> containerClass) {
         return new CraftingContainerInfoWrapper<>(containerClass);
     }
     
     @Override
-    public Class<? extends ScreenHandler> getContainerClass() {
+    public Class<? extends Container> getContainerClass() {
         return containerClass;
     }
     

+ 2 - 2
src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java

@@ -28,9 +28,9 @@ import me.shedaniel.rei.api.TransferRecipeDisplay;
 import me.shedaniel.rei.server.ContainerInfo;
 import me.shedaniel.rei.utils.CollectionUtils;
 import net.minecraft.block.entity.FurnaceBlockEntity;
+import net.minecraft.container.Container;
 import net.minecraft.item.Item;
 import net.minecraft.recipe.AbstractCookingRecipe;
-import net.minecraft.screen.ScreenHandler;
 import net.minecraft.text.TranslatableText;
 import net.minecraft.util.Formatting;
 import net.minecraft.util.Identifier;
@@ -110,7 +110,7 @@ public abstract class DefaultCookingDisplay implements TransferRecipeDisplay {
     }
     
     @Override
-    public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
+    public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<Container> containerInfo, Container container) {
         return input;
     }
     

+ 3 - 3
src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java

@@ -40,7 +40,7 @@ import net.minecraft.block.Blocks;
 import net.minecraft.client.gui.DrawableHelper;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.screen.ScreenHandler;
+import net.minecraft.container.Container;
 import net.minecraft.util.Identifier;
 import net.minecraft.util.math.MathHelper;
 
@@ -95,13 +95,13 @@ public class DefaultCraftingCategory implements TransferRecipeCategory<DefaultCr
     
     @Override
     public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, DefaultCraftingDisplay display, IntList redSlots) {
-        ContainerInfo<ScreenHandler> info = (ContainerInfo<ScreenHandler>) ContainerInfoHandler.getContainerInfo(getIdentifier(), REIHelper.getInstance().getPreviousHandledScreen().getScreenHandler().getClass());
+        ContainerInfo<Container> info = (ContainerInfo<Container>) ContainerInfoHandler.getContainerInfo(getIdentifier(), REIHelper.getInstance().getPreviousContainerScreen().getContainer().getClass());
         if (info == null)
             return;
         matrices.push();
         matrices.translate(0, 0, 400);
         Point startPoint = new Point(bounds.getCenterX() - 58, bounds.getCenterY() - 27);
-        int width = info.getCraftingWidth(REIHelper.getInstance().getPreviousHandledScreen().getScreenHandler());
+        int width = info.getCraftingWidth(REIHelper.getInstance().getPreviousContainerScreen().getContainer());
         for (Integer slot : redSlots) {
             int i = slot;
             int x = i % width;

+ 2 - 2
src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java

@@ -28,8 +28,8 @@ import me.shedaniel.rei.api.EntryStack;
 import me.shedaniel.rei.api.TransferRecipeDisplay;
 import me.shedaniel.rei.plugin.DefaultPlugin;
 import me.shedaniel.rei.server.ContainerInfo;
+import net.minecraft.container.Container;
 import net.minecraft.recipe.Recipe;
-import net.minecraft.screen.ScreenHandler;
 import net.minecraft.util.Identifier;
 
 import java.util.Collections;
@@ -56,7 +56,7 @@ public interface DefaultCraftingDisplay extends TransferRecipeDisplay {
     Optional<Recipe<?>> getOptionalRecipe();
     
     @Override
-    default List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
+    default List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<Container> containerInfo, Container container) {
         List<List<EntryStack>> list = Lists.newArrayListWithCapacity(containerInfo.getCraftingWidth(container) * containerInfo.getCraftingHeight(container));
         for (int i = 0; i < containerInfo.getCraftingWidth(container) * containerInfo.getCraftingHeight(container); i++) {
             list.add(Collections.emptyList());

+ 1 - 1
src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java

@@ -157,7 +157,7 @@ public class DefaultInformationCategory implements RecipeCategory<DefaultInforma
             for (Text text : texts) {
                 if (!this.texts.isEmpty())
                     this.texts.add(null);
-                this.texts.addAll(MinecraftClient.getInstance().textRenderer.wrapLines(text, bounds.width - 11));
+                this.texts.addAll(MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(text, bounds.width - 11));
             }
         }
         

+ 3 - 3
src/main/java/me/shedaniel/rei/server/ContainerInfo.java

@@ -23,10 +23,10 @@
 
 package me.shedaniel.rei.server;
 
-import net.minecraft.screen.ScreenHandler;
+import net.minecraft.container.Container;
 
-public interface ContainerInfo<T extends ScreenHandler> {
-    Class<? extends ScreenHandler> getContainerClass();
+public interface ContainerInfo<T extends Container> {
+    Class<? extends Container> getContainerClass();
     
     int getCraftingResultSlotIndex(T container);
     

+ 11 - 11
src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java

@@ -24,25 +24,25 @@
 package me.shedaniel.rei.server;
 
 import com.google.common.collect.Maps;
-import net.minecraft.screen.ScreenHandler;
+import net.minecraft.container.Container;
 import net.minecraft.util.Identifier;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Map;
 
 public class ContainerInfoHandler {
-    private static final Map<String, Map<Class<? extends ScreenHandler>, ContainerInfo<? extends ScreenHandler>>> containerInfoMap = Maps.newLinkedHashMap();
+    private static final Map<String, Map<Class<? extends Container>, ContainerInfo<? extends Container>>> containerInfoMap = Maps.newLinkedHashMap();
+    
+    public static void registerContainerInfo(Identifier category, ContainerInfo<? extends Container> containerInfo) {
+        registerScreenWithHandlerInfo(category, containerInfo);
+    }
     
     /**
-     * @deprecated Use {@link #registerScreenWithHandlerInfo(Identifier, ContainerInfo)}
+     * @deprecated Use {@link #registerContainerInfo(Identifier, ContainerInfo)}
      */
     @Deprecated
     @ApiStatus.ScheduledForRemoval
-    public static void registerContainerInfo(Identifier category, ContainerInfo<? extends ScreenHandler> containerInfo) {
-        registerScreenWithHandlerInfo(category, containerInfo);
-    }
-    
-    public static void registerScreenWithHandlerInfo(Identifier category, ContainerInfo<? extends ScreenHandler> containerInfo) {
+    public static void registerScreenWithHandlerInfo(Identifier category, ContainerInfo<? extends Container> containerInfo) {
         if (!containerInfoMap.containsKey(category.toString()))
             containerInfoMap.put(category.toString(), Maps.newLinkedHashMap());
         containerInfoMap.get(category.toString()).put(containerInfo.getContainerClass(), containerInfo);
@@ -52,13 +52,13 @@ public class ContainerInfoHandler {
         return containerInfoMap.containsKey(category.toString()) && !containerInfoMap.get(category.toString()).isEmpty();
     }
     
-    public static ContainerInfo<? extends ScreenHandler> getContainerInfo(Identifier category, Class<?> containerClass) {
+    public static ContainerInfo<? extends Container> getContainerInfo(Identifier category, Class<?> containerClass) {
         if (!isCategoryHandled(category))
             return null;
-        Map<Class<? extends ScreenHandler>, ContainerInfo<? extends ScreenHandler>> infoMap = containerInfoMap.get(category.toString());
+        Map<Class<? extends Container>, ContainerInfo<? extends Container>> infoMap = containerInfoMap.get(category.toString());
         if (infoMap.containsKey(containerClass))
             return infoMap.get(containerClass);
-        for (Map.Entry<Class<? extends ScreenHandler>, ContainerInfo<? extends ScreenHandler>> entry : infoMap.entrySet())
+        for (Map.Entry<Class<? extends Container>, ContainerInfo<? extends Container>> entry : infoMap.entrySet())
             if (entry.getKey().isAssignableFrom(containerClass))
                 return entry.getValue();
         return null;

+ 26 - 26
src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java

@@ -26,12 +26,12 @@ package me.shedaniel.rei.server;
 import com.google.common.collect.Lists;
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.ints.IntList;
+import net.minecraft.container.Container;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.recipe.Ingredient;
-import net.minecraft.screen.ScreenHandler;
 import net.minecraft.screen.slot.Slot;
 import net.minecraft.server.network.ServerPlayerEntity;
 import net.minecraft.util.Identifier;
@@ -41,17 +41,17 @@ import java.util.*;
 
 public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<Integer> {
     
-    protected ScreenHandler screenHandler;
+    protected Container container;
     protected ContainerInfo containerInfo;
     protected PlayerInventory inventory;
     
-    private InputSlotCrafter(ScreenHandler screenHandler, ContainerInfo<? extends ScreenHandler> containerInfo) {
-        this.screenHandler = screenHandler;
+    private InputSlotCrafter(Container container, ContainerInfo<? extends Container> containerInfo) {
+        this.container = container;
         this.containerInfo = containerInfo;
     }
     
-    public static <C extends Inventory> void start(Identifier category, ScreenHandler craftingContainer_1, ServerPlayerEntity player, Map<Integer, List<ItemStack>> map, boolean hasShift) {
-        ContainerInfo<? extends ScreenHandler> containerInfo = Objects.requireNonNull(ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()), "Container Info does not exist on the server!");
+    public static <C extends Inventory> void start(Identifier category, Container craftingContainer_1, ServerPlayerEntity player, Map<Integer, List<ItemStack>> map, boolean hasShift) {
+        ContainerInfo<? extends Container> containerInfo = Objects.requireNonNull(ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()), "Container Info does not exist on the server!");
         new InputSlotCrafter<C>(craftingContainer_1, containerInfo).fillInputSlots(player, map, hasShift);
     }
     
@@ -66,7 +66,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
             for (ItemStack stack : player.inventory.main) {
                 recipeFinder.addNormalItem(stack);
             }
-            this.containerInfo.populateRecipeFinder(screenHandler, recipeFinder);
+            this.containerInfo.populateRecipeFinder(container, recipeFinder);
             DefaultedList<Ingredient> ingredients = DefaultedList.of();
             map.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).forEach(entry -> {
                 ingredients.add(Ingredient.ofItems(entry.getValue().stream().map(ItemStack::getItem).toArray(Item[]::new)));
@@ -85,7 +85,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
     
     @Override
     public void acceptAlignedInput(Iterator<Integer> iterator_1, int int_1, int int_2, int int_3, int int_4) {
-        Slot slot_1 = this.screenHandler.getSlot(int_1);
+        Slot slot_1 = this.container.getSlot(int_1);
         ItemStack itemStack_1 = RecipeFinder.getStackFromId(iterator_1.next());
         if (!itemStack_1.isEmpty()) {
             for (int int_5 = 0; int_5 < int_2; ++int_5) {
@@ -97,12 +97,12 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
     protected void fillInputSlot(Slot slot_1, ItemStack itemStack_1) {
         int int_1 = this.inventory.method_7371(itemStack_1);
         if (int_1 != -1) {
-            ItemStack itemStack_2 = this.inventory.getStack(int_1).copy();
+            ItemStack itemStack_2 = this.inventory.getInvStack(int_1).copy();
             if (!itemStack_2.isEmpty()) {
                 if (itemStack_2.getCount() > 1) {
-                    this.inventory.removeStack(int_1, 1);
+                    this.inventory.takeInvStack(int_1, 1);
                 } else {
-                    this.inventory.removeStack(int_1);
+                    this.inventory.removeInvStack(int_1);
                 }
                 
                 itemStack_2.setCount(1);
@@ -122,9 +122,9 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
         int int_1 = recipeFinder.countRecipeCrafts(ingredients, null);
         int int_2;
         if (boolean_2) {
-            for (int_2 = 0; int_2 < this.containerInfo.getCraftingHeight(screenHandler) * this.containerInfo.getCraftingWidth(screenHandler) + 1; ++int_2) {
-                if (int_2 != this.containerInfo.getCraftingResultSlotIndex(screenHandler)) {
-                    ItemStack itemStack_1 = this.screenHandler.getSlot(int_2).getStack();
+            for (int_2 = 0; int_2 < this.containerInfo.getCraftingHeight(container) * this.containerInfo.getCraftingWidth(container) + 1; ++int_2) {
+                if (int_2 != this.containerInfo.getCraftingResultSlotIndex(container)) {
+                    ItemStack itemStack_1 = this.container.getSlot(int_2).getStack();
                     if (!itemStack_1.isEmpty() && Math.min(int_1, itemStack_1.getMaxCount()) < itemStack_1.getCount() + 1) {
                         return;
                     }
@@ -146,7 +146,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
             
             if (recipeFinder.findRecipe(ingredients, intList_1, int_4)) {
                 this.returnInputs();
-                this.alignRecipeToGrid(this.containerInfo.getCraftingWidth(screenHandler), this.containerInfo.getCraftingHeight(screenHandler), this.containerInfo.getCraftingResultSlotIndex(screenHandler), ingredients, intList_1.iterator(), int_4);
+                this.alignRecipeToGrid(this.containerInfo.getCraftingWidth(container), this.containerInfo.getCraftingHeight(container), this.containerInfo.getCraftingResultSlotIndex(container), ingredients, intList_1.iterator(), int_4);
             }
         }
         
@@ -158,9 +158,9 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
             int_2 = int_1;
         } else if (boolean_2) {
             int_2 = 64;
-            for (int int_3 = 0; int_3 < this.containerInfo.getCraftingWidth(screenHandler) * this.containerInfo.getCraftingHeight(screenHandler) + 1; ++int_3) {
-                if (int_3 != this.containerInfo.getCraftingResultSlotIndex(screenHandler)) {
-                    ItemStack itemStack_1 = this.screenHandler.getSlot(int_3).getStack();
+            for (int int_3 = 0; int_3 < this.containerInfo.getCraftingWidth(container) * this.containerInfo.getCraftingHeight(container) + 1; ++int_3) {
+                if (int_3 != this.containerInfo.getCraftingResultSlotIndex(container)) {
+                    ItemStack itemStack_1 = this.container.getSlot(int_3).getStack();
                     if (!itemStack_1.isEmpty() && int_2 > itemStack_1.getCount()) {
                         int_2 = itemStack_1.getCount();
                     }
@@ -174,19 +174,19 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
     }
     
     protected void returnInputs() {
-        for (int int_1 = 0; int_1 < this.containerInfo.getCraftingWidth(screenHandler) * this.containerInfo.getCraftingHeight(screenHandler) + 1; ++int_1) {
-            if (int_1 != this.containerInfo.getCraftingResultSlotIndex(screenHandler)) {
+        for (int int_1 = 0; int_1 < this.containerInfo.getCraftingWidth(container) * this.containerInfo.getCraftingHeight(container) + 1; ++int_1) {
+            if (int_1 != this.containerInfo.getCraftingResultSlotIndex(container)) {
                 this.returnSlot(int_1);
             }
         }
         
-        this.containerInfo.clearCraftingSlots(screenHandler);
+        this.containerInfo.clearCraftingSlots(container);
     }
     
     protected void returnSlot(int int_1) {
-        ItemStack itemStack_1 = this.screenHandler.getSlot(int_1).getStack();
+        ItemStack itemStack_1 = this.container.getSlot(int_1).getStack();
         if (!itemStack_1.isEmpty()) {
-            for (; itemStack_1.getCount() > 0; this.screenHandler.getSlot(int_1).takeStack(1)) {
+            for (; itemStack_1.getCount() > 0; this.container.getSlot(int_1).takeStack(1)) {
                 int int_2 = this.inventory.getOccupiedSlotWithRoomForStack(itemStack_1);
                 if (int_2 == -1) {
                     int_2 = this.inventory.getEmptySlot();
@@ -205,9 +205,9 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<
         List<ItemStack> list_1 = Lists.newArrayList();
         int int_1 = this.getFreeInventorySlots();
         
-        for (int int_2 = 0; int_2 < this.containerInfo.getCraftingWidth(screenHandler) * this.containerInfo.getCraftingHeight(screenHandler) + 1; ++int_2) {
-            if (int_2 != this.containerInfo.getCraftingResultSlotIndex(screenHandler)) {
-                ItemStack itemStack_1 = this.screenHandler.getSlot(int_2).getStack().copy();
+        for (int int_2 = 0; int_2 < this.containerInfo.getCraftingWidth(container) * this.containerInfo.getCraftingHeight(container) + 1; ++int_2) {
+            if (int_2 != this.containerInfo.getCraftingResultSlotIndex(container)) {
+                ItemStack itemStack_1 = this.container.getSlot(int_2).getStack().copy();
                 if (!itemStack_1.isEmpty()) {
                     int int_3 = this.inventory.getOccupiedSlotWithRoomForStack(itemStack_1);
                     if (int_3 == -1 && list_1.size() <= int_1) {

+ 6 - 6
src/main/resources/rei.aw

@@ -1,13 +1,13 @@
 accessWidener   v1  named
 accessible field net/minecraft/item/BucketItem fluid Lnet/minecraft/fluid/Fluid;
-accessible field net/minecraft/client/gui/screen/ingame/AbstractInventoryScreen drawStatusEffects Z
+accessible field net/minecraft/client/gui/screen/ingame/AbstractInventoryScreen offsetGuiForEffects Z
 accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget ghostSlots Lnet/minecraft/client/gui/screen/recipebook/RecipeBookGhostSlots;
 accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget searchField Lnet/minecraft/client/gui/widget/TextFieldWidget;
 accessible field net/minecraft/client/gui/screen/recipebook/RecipeBookWidget tabButtons Ljava/util/List;
-accessible field net/minecraft/client/gui/screen/ingame/HandledScreen x I
-accessible field net/minecraft/client/gui/screen/ingame/HandledScreen y I
-accessible field net/minecraft/client/gui/screen/ingame/HandledScreen backgroundWidth I
-accessible field net/minecraft/client/gui/screen/ingame/HandledScreen backgroundHeight I
-accessible field net/minecraft/client/gui/screen/ingame/HandledScreen focusedSlot Lnet/minecraft/screen/slot/Slot;
+accessible field net/minecraft/client/gui/screen/ingame/ContainerScreen x I
+accessible field net/minecraft/client/gui/screen/ingame/ContainerScreen y I
+accessible field net/minecraft/client/gui/screen/ingame/ContainerScreen containerWidth I
+accessible field net/minecraft/client/gui/screen/ingame/ContainerScreen containerHeight I
+accessible field net/minecraft/client/gui/screen/ingame/ContainerScreen focusedSlot Lnet/minecraft/screen/slot/Slot;
 accessible field net/minecraft/client/gui/widget/TexturedButtonWidget texture Lnet/minecraft/util/Identifier;
 accessible method net/minecraft/client/gui/DrawableHelper drawTexturedQuad (Lnet/minecraft/util/math/Matrix4f;IIIIIFFFF)V