From 6104964f60bac00a4ac1359bd244d361e50786bd Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 27 Aug 2020 19:36:00 +0800 Subject: Migrate from yarn to mojmap Signed-off-by: shedaniel --- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 169 +++++++------ .../shedaniel/rei/RoughlyEnoughItemsNetwork.java | 108 ++++----- .../me/shedaniel/rei/RoughlyEnoughItemsState.java | 18 +- .../shedaniel/rei/gui/ConfigReloadingScreen.java | 24 +- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 262 ++++++++++----------- .../me/shedaniel/rei/gui/OverlaySearchField.java | 42 ++-- .../shedaniel/rei/gui/PreRecipeViewingScreen.java | 60 ++--- .../shedaniel/rei/gui/RecipeDisplayExporter.java | 62 ++--- .../java/me/shedaniel/rei/gui/RecipeScreen.java | 4 +- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 146 ++++++------ .../rei/gui/VillagerRecipeViewingScreen.java | 82 +++---- .../shedaniel/rei/gui/WarningAndErrorScreen.java | 120 +++++----- .../gui/config/entry/FilteringAddRuleScreen.java | 70 +++--- .../rei/gui/config/entry/FilteringEntry.java | 32 +-- .../config/entry/FilteringRuleOptionsScreen.java | 80 +++---- .../rei/gui/config/entry/FilteringRulesScreen.java | 98 ++++---- .../rei/gui/config/entry/FilteringScreen.java | 130 +++++----- .../rei/gui/config/entry/NoFilteringEntry.java | 28 +-- .../gui/config/entry/RecipeScreenTypeEntry.java | 38 +-- .../rei/gui/config/entry/ReloadPluginsEntry.java | 34 +-- .../rei/gui/credits/CreditsEntryListWidget.java | 38 +-- .../shedaniel/rei/gui/credits/CreditsScreen.java | 62 ++--- .../java/me/shedaniel/rei/gui/modules/Menu.java | 26 +- .../entries/EntryStackSubsetsMenuEntry.java | 14 +- .../rei/gui/modules/entries/GameModeMenuEntry.java | 32 +-- .../gui/modules/entries/SubSubsetsMenuEntry.java | 48 ++-- .../rei/gui/modules/entries/WeatherMenuEntry.java | 28 +-- .../rei/gui/plugin/DefaultRuntimePlugin.java | 24 +- .../rei/gui/toast/CopyRecipeIdentifierToast.java | 28 +-- .../rei/gui/toast/ExportRecipeIdentifierToast.java | 28 +-- .../me/shedaniel/rei/gui/widget/ButtonWidget.java | 62 ++--- .../rei/gui/widget/ClickableLabelWidget.java | 24 +- .../shedaniel/rei/gui/widget/DraggableWidget.java | 12 +- .../rei/gui/widget/EntryListEntryWidget.java | 18 +- .../shedaniel/rei/gui/widget/EntryListWidget.java | 98 ++++---- .../me/shedaniel/rei/gui/widget/EntryWidget.java | 48 ++-- .../rei/gui/widget/FavoritesListWidget.java | 36 +-- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 36 +-- .../me/shedaniel/rei/gui/widget/PanelWidget.java | 30 +-- .../me/shedaniel/rei/gui/widget/QueuedTooltip.java | 20 +- .../rei/gui/widget/RecipeArrowWidget.java | 20 +- .../rei/gui/widget/RecipeChoosePageWidget.java | 40 ++-- .../me/shedaniel/rei/gui/widget/TabWidget.java | 22 +- .../me/shedaniel/rei/impl/AbstractEntryStack.java | 8 +- .../shedaniel/rei/impl/BaseBoundsHandlerImpl.java | 34 +-- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 152 ++++++------ .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 64 ++--- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 10 +- .../me/shedaniel/rei/impl/DisplayHelperImpl.java | 10 +- .../me/shedaniel/rei/impl/EmptyEntryStack.java | 8 +- .../me/shedaniel/rei/impl/EntryRegistryImpl.java | 14 +- .../me/shedaniel/rei/impl/FluidEntryStack.java | 74 +++--- .../me/shedaniel/rei/impl/InternalWidgets.java | 64 ++--- .../java/me/shedaniel/rei/impl/ItemEntryStack.java | 108 ++++----- .../me/shedaniel/rei/impl/OptimalEntryStack.java | 12 +- .../me/shedaniel/rei/impl/RecipeHelperImpl.java | 124 +++++----- .../java/me/shedaniel/rei/impl/ScreenHelper.java | 54 ++--- .../java/me/shedaniel/rei/impl/SearchArgument.java | 8 +- .../me/shedaniel/rei/impl/SimpleFluidRenderer.java | 22 +- .../rei/impl/filtering/FilteringRule.java | 32 +-- .../impl/filtering/rules/ManualFilteringRule.java | 12 +- .../impl/filtering/rules/SearchFilteringRule.java | 28 +-- .../me/shedaniel/rei/impl/search/ModArgument.java | 4 +- .../me/shedaniel/rei/impl/search/TagArgument.java | 14 +- .../rei/impl/subsets/SubsetsRegistryImpl.java | 4 +- .../me/shedaniel/rei/impl/widgets/ArrowWidget.java | 20 +- .../rei/impl/widgets/BurningFireWidget.java | 20 +- .../shedaniel/rei/impl/widgets/ButtonWidget.java | 74 +++--- .../shedaniel/rei/impl/widgets/DrawableWidget.java | 8 +- .../widgets/FillRectangleDrawableConsumer.java | 28 +-- .../me/shedaniel/rei/impl/widgets/LabelWidget.java | 46 ++-- .../me/shedaniel/rei/impl/widgets/PanelWidget.java | 42 ++-- .../rei/impl/widgets/TexturedDrawableConsumer.java | 38 ++- .../me/shedaniel/rei/mixin/MixinItemStack.java | 4 +- .../autocrafting/DefaultCategoryHandler.java | 53 ++--- .../me/shedaniel/rei/server/InputSlotCrafter.java | 56 ++--- .../shedaniel/rei/tests/plugin/REITestPlugin.java | 12 +- 77 files changed, 1828 insertions(+), 1834 deletions(-) (limited to 'RoughlyEnoughItems-runtime/src/main/java') diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 3a28fa405..a3bead190 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -49,31 +49,31 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.fabricmc.loader.api.FabricLoader; 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.ContainerScreen; -import net.minecraft.client.gui.screen.ingame.CraftingTableScreen; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.client.gui.screen.recipebook.RecipeBookGhostSlots; -import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; -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.fluid.Fluid; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.RecipeManager; -import net.minecraft.screen.slot.Slot; -import net.minecraft.text.LiteralText; -import net.minecraft.text.StringVisitable; -import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.CraftingScreen; +import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; +import net.minecraft.client.gui.screens.inventory.InventoryScreen; +import net.minecraft.client.gui.screens.recipebook.GhostRecipe; +import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; +import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.inventory.CraftingMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.level.material.Fluid; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; @@ -87,7 +87,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.BiFunction; -import java.util.function.Supplier; import static me.shedaniel.rei.impl.Internals.attachInstance; @@ -96,7 +95,7 @@ import static me.shedaniel.rei.impl.Internals.attachInstance; public class RoughlyEnoughItemsCore implements ClientModInitializer { @ApiStatus.Internal public static final Logger LOGGER = LogManager.getFormatterLogger("REI"); - private static final Map plugins = Maps.newHashMap(); + private static final Map plugins = Maps.newHashMap(); private static final ExecutorService SYNC_RECIPES = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "REI-SyncRecipes")); @ApiStatus.Experimental public static boolean isLeftModePressed = false; @@ -145,7 +144,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } @Override - public Button createButton(Rectangle bounds, Text text) { + public Button createButton(Rectangle bounds, Component text) { return new ButtonWidget(bounds, text); } @@ -155,7 +154,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } @Override - public Label createLabel(Point point, StringVisitable text) { + public Label createLabel(Point point, FormattedText text) { return new LabelWidget(point, text); } @@ -170,7 +169,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } @Override - public DrawableConsumer createTexturedConsumer(Identifier texture, int x, int y, int width, int height, float u, float v, int uWidth, int vHeight, int textureWidth, int textureHeight) { + public DrawableConsumer createTexturedConsumer(ResourceLocation texture, int x, int y, int width, int height, float u, float v, int uWidth, int vHeight, int textureWidth, int textureHeight) { return new TexturedDrawableConsumer(texture, x, y, width, height, u, v, uWidth, vHeight, textureWidth, textureHeight); } @@ -179,7 +178,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return new FillRectangleDrawableConsumer(rectangle, color); } }, Internals.WidgetsProvider.class); - attachInstance((BiFunction<@Nullable Point, Collection, Tooltip>) QueuedTooltip::create, "tooltipProvider"); + attachInstance((BiFunction<@Nullable Point, Collection, Tooltip>) QueuedTooltip::create, "tooltipProvider"); } /** @@ -199,8 +198,8 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return new LinkedList<>(plugins.values()); } - public static Optional getPluginIdentifier(REIPluginEntry plugin) { - for (Identifier identifier : plugins.keySet()) + public static Optional getPluginIdentifier(REIPluginEntry plugin) { + for (ResourceLocation identifier : plugins.keySet()) if (identifier != null && plugins.get(identifier).equals(plugin)) return Optional.of(identifier); return Optional.empty(); @@ -208,7 +207,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { public static boolean hasPermissionToUsePackets() { try { - MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(0); + Minecraft.getInstance().getConnection().getSuggestionsProvider().hasPermission(0); return hasOperatorPermission() && canUsePackets(); } catch (NullPointerException e) { return true; @@ -217,7 +216,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { public static boolean hasOperatorPermission() { try { - return MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(1); + return Minecraft.getInstance().getConnection().getSuggestionsProvider().hasPermission(1); } catch (NullPointerException e) { return true; } @@ -236,7 +235,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } lastSync[0] = System.currentTimeMillis(); } - RecipeManager recipeManager = MinecraftClient.getInstance().getNetworkHandler().getRecipeManager(); + RecipeManager recipeManager = Minecraft.getInstance().getConnection().getRecipeManager(); if (ConfigObject.getInstance().doesRegisterRecipesInAnotherThread()) { CompletableFuture.runAsync(() -> ((RecipeHelperImpl) RecipeHelper.getInstance()).tryRecipesLoaded(recipeManager), SYNC_RECIPES); } else { @@ -250,7 +249,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } public static boolean canDeleteItems() { - return hasPermissionToUsePackets() || MinecraftClient.getInstance().interactionManager.hasCreativeInventory(); + return hasPermissionToUsePackets() || Minecraft.getInstance().gameMode.hasInfiniteItems(); } @SuppressWarnings("deprecation") @@ -273,16 +272,16 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } Executor.run(() -> () -> { ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> { - ItemStack stack = packetByteBuf.readItemStack(); - String player = packetByteBuf.readString(32767); - packetContext.getPlayer().addMessage(new LiteralText(I18n.translate("text.rei.cheat_items").replaceAll("\\{item_name}", EntryStack.create(stack.copy()).asFormattedText().getString()).replaceAll("\\{item_count}", stack.copy().getCount() + "").replaceAll("\\{player_name}", player)), false); + ItemStack stack = packetByteBuf.readItem(); + String player = packetByteBuf.readUtf(32767); + packetContext.getPlayer().displayClientMessage(new TextComponent(I18n.get("text.rei.cheat_items").replaceAll("\\{item_name}", EntryStack.create(stack.copy()).asFormattedText().getString()).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 CraftingTableScreen) { - RecipeBookWidget recipeBookGui = ((RecipeBookProvider) currentScreen).getRecipeBookWidget(); - RecipeBookGhostSlots ghostSlots = recipeBookGui.ghostSlots; - ghostSlots.reset(); + Screen currentScreen = Minecraft.getInstance().screen; + if (currentScreen instanceof CraftingScreen) { + RecipeBookComponent recipeBookGui = ((RecipeUpdateListener) currentScreen).getRecipeBookComponent(); + GhostRecipe ghostSlots = recipeBookGui.ghostRecipe; + ghostSlots.clear(); List> input = Lists.newArrayList(); int mapSize = packetByteBuf.readInt(); @@ -290,18 +289,18 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { List list = Lists.newArrayList(); int count = packetByteBuf.readInt(); for (int j = 0; j < count; j++) { - list.add(packetByteBuf.readItemStack()); + list.add(packetByteBuf.readItem()); } input.add(list); } - ghostSlots.addSlot(Ingredient.ofItems(Items.STONE), 381203812, 12738291); - CraftingTableContainer container = ((CraftingTableScreen) currentScreen).getContainer(); + ghostSlots.addIngredient(Ingredient.of(Items.STONE), 381203812, 12738291); + CraftingMenu container = ((CraftingScreen) currentScreen).getMenu(); for (int i = 0; i < input.size(); i++) { List stacks = input.get(i); if (!stacks.isEmpty()) { - Slot slot = container.getSlot(i + container.getCraftingResultSlotIndex() + 1); - ghostSlots.addSlot(Ingredient.ofStacks(stacks.toArray(new ItemStack[0])), slot.xPosition, slot.yPosition); + Slot slot = container.getSlot(i + container.getResultSlotIndex() + 1); + ghostSlots.addIngredient(Ingredient.of(stacks.toArray(new ItemStack[0])), slot.x, slot.y); } } } @@ -379,9 +378,9 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { for (OverlayDecider decider : DisplayHelper.getInstance().getAllOverlayDeciders()) { if (!decider.isHandingScreen(screen)) continue; - ActionResult result = decider.shouldScreenBeOverlayed(screen); - if (result != ActionResult.PASS) - return result == ActionResult.FAIL || REIHelper.getInstance().getPreviousContainerScreen() == null; + InteractionResult result = decider.shouldScreenBeOverlayed(screen); + if (result != InteractionResult.PASS) + return result == InteractionResult.FAIL || REIHelper.getInstance().getPreviousContainerScreen() == null; } } catch (ConcurrentModificationException ignored) { } @@ -389,24 +388,24 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } private void registerClothEvents() { - final Identifier recipeButtonTex = new Identifier("textures/gui/recipe_button.png"); + final ResourceLocation recipeButtonTex = new ResourceLocation("textures/gui/recipe_button.png"); 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 ContainerScreen && abstractButtonWidget instanceof TexturedButtonWidget) - if (((TexturedButtonWidget) abstractButtonWidget).texture.equals(recipeButtonTex)) - return ActionResult.FAIL; - return ActionResult.PASS; + if (ConfigObject.getInstance().doesDisableRecipeBook() && screen instanceof AbstractContainerScreen && abstractButtonWidget instanceof ImageButton) + if (((ImageButton) abstractButtonWidget).resourceLocation.equals(recipeButtonTex)) + return InteractionResult.FAIL; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_INIT_POST.register((minecraftClient, screen, screenHooks) -> { if (shouldReturn(screen)) return; - if (screen instanceof InventoryScreen && minecraftClient.interactionManager.hasCreativeInventory()) + if (screen instanceof InventoryScreen && minecraftClient.gameMode.hasInfiniteItems()) return; - if (screen instanceof ContainerScreen) - ScreenHelper.setPreviousContainerScreen((ContainerScreen) screen); + if (screen instanceof AbstractContainerScreen) + ScreenHelper.setPreviousContainerScreen((AbstractContainerScreen) screen); boolean alreadyAdded = false; - for (Element element : Lists.newArrayList(screenHooks.cloth$getChildren())) + for (GuiEventListener element : Lists.newArrayList(screenHooks.cloth$getChildren())) if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass())) if (alreadyAdded) screenHooks.cloth$getChildren().remove(element); @@ -422,46 +421,46 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { }); ClothClientHooks.SCREEN_MOUSE_DRAGGED.register((minecraftClient, screen, v, v1, i, v2, v3) -> { if (shouldReturn(screen)) - return ActionResult.PASS; + return InteractionResult.PASS; if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseDragged(v, v1, i, v2, v3)) - return ActionResult.SUCCESS; - return ActionResult.PASS; + return InteractionResult.SUCCESS; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_MOUSE_CLICKED.register((minecraftClient, screen, v, v1, i) -> { isLeftModePressed = true; if (ScreenHelper.getOptionalOverlay().isPresent()) - if (screen instanceof CreativeInventoryScreen) + if (screen instanceof CreativeModeInventoryScreen) if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseClicked(v, v1, i)) { screen.setFocused(ScreenHelper.getLastOverlay()); if (i == 0) screen.setDragging(true); - return ActionResult.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResult.PASS; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_MOUSE_RELEASED.register((minecraftClient, screen, v, v1, i) -> { isLeftModePressed = false; if (shouldReturn(screen)) - return ActionResult.PASS; + return InteractionResult.PASS; if (ScreenHelper.getOptionalOverlay().isPresent()) if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseReleased(v, v1, i)) { - return ActionResult.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResult.PASS; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_MOUSE_SCROLLED.register((minecraftClient, screen, v, v1, v2) -> { if (shouldReturn(screen)) - return ActionResult.PASS; + return InteractionResult.PASS; if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseScrolled(v, v1, v2)) - return ActionResult.SUCCESS; - return ActionResult.PASS; + return InteractionResult.SUCCESS; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_CHAR_TYPED.register((minecraftClient, screen, character, keyCode) -> { if (shouldReturn(screen)) - return ActionResult.PASS; + return InteractionResult.PASS; if (ScreenHelper.getLastOverlay().charTyped(character, keyCode)) - return ActionResult.SUCCESS; - return ActionResult.PASS; + return InteractionResult.SUCCESS; + return InteractionResult.PASS; }); ClothClientHooks.SCREEN_LATE_RENDER.register((matrices, minecraftClient, screen, i, i1, v) -> { if (shouldReturn(screen)) @@ -472,17 +471,17 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { }); ClothClientHooks.SCREEN_KEY_PRESSED.register((minecraftClient, screen, i, i1, i2) -> { if (shouldReturn(screen)) - return ActionResult.PASS; - if (screen instanceof ContainerScreen && ConfigObject.getInstance().doesDisableRecipeBook() && ConfigObject.getInstance().doesFixTabCloseContainer()) - if (i == 258 && minecraftClient.options.keyInventory.matchesKey(i, i1)) { + return InteractionResult.PASS; + if (screen instanceof AbstractContainerScreen && ConfigObject.getInstance().doesDisableRecipeBook() && ConfigObject.getInstance().doesFixTabCloseContainer()) + if (i == 258 && minecraftClient.options.keyInventory.matches(i, i1)) { minecraftClient.player.closeContainer(); - return ActionResult.SUCCESS; + return InteractionResult.SUCCESS; } - if (screen.getFocused() != null && screen.getFocused() instanceof TextFieldWidget || (screen.getFocused() instanceof RecipeBookWidget && ((RecipeBookWidget) screen.getFocused()).searchField != null && ((RecipeBookWidget) screen.getFocused()).searchField.isFocused())) - return ActionResult.PASS; + if (screen.getFocused() != null && screen.getFocused() instanceof EditBox || (screen.getFocused() instanceof RecipeBookComponent && ((RecipeBookComponent) screen.getFocused()).searchBox != null && ((RecipeBookComponent) screen.getFocused()).searchBox.isFocused())) + return InteractionResult.PASS; if (ScreenHelper.getLastOverlay().keyPressed(i, i1, i2)) - return ActionResult.SUCCESS; - return ActionResult.PASS; + return InteractionResult.SUCCESS; + return InteractionResult.PASS; }); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 07936f4eb..9704c1516 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -30,30 +30,30 @@ 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.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.util.Util; -import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.math.MathHelper; +import net.minecraft.ChatFormatting; +import net.minecraft.Util; +import net.minecraft.core.NonNullList; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.inventory.RecipeBookMenu; +import net.minecraft.world.item.ItemStack; import java.util.List; public class RoughlyEnoughItemsNetwork implements ModInitializer { - public static final Identifier DELETE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "delete_item"); - public static final Identifier CREATE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "create_item"); - public static final Identifier CREATE_ITEMS_GRAB_PACKET = new Identifier("roughlyenoughitems", "create_item_grab"); - public static final Identifier CREATE_ITEMS_MESSAGE_PACKET = new Identifier("roughlyenoughitems", "ci_msg"); - public static final Identifier MOVE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "move_items"); - public static final Identifier NOT_ENOUGH_ITEMS_PACKET = new Identifier("roughlyenoughitems", "og_not_enough"); + public static final ResourceLocation DELETE_ITEMS_PACKET = new ResourceLocation("roughlyenoughitems", "delete_item"); + public static final ResourceLocation CREATE_ITEMS_PACKET = new ResourceLocation("roughlyenoughitems", "create_item"); + public static final ResourceLocation CREATE_ITEMS_GRAB_PACKET = new ResourceLocation("roughlyenoughitems", "create_item_grab"); + public static final ResourceLocation CREATE_ITEMS_MESSAGE_PACKET = new ResourceLocation("roughlyenoughitems", "ci_msg"); + public static final ResourceLocation MOVE_ITEMS_PACKET = new ResourceLocation("roughlyenoughitems", "move_items"); + public static final ResourceLocation NOT_ENOUGH_ITEMS_PACKET = new ResourceLocation("roughlyenoughitems", "og_not_enough"); @Override public void onInitialize() { @@ -65,84 +65,84 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer { Executor.run(() -> () -> { FabricLoader.getInstance().getEntrypoints("rei_containers", Runnable.class).forEach(Runnable::run); ServerSidePacketRegistry.INSTANCE.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> { - ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); - if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) { - player.addMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false); + ServerPlayer player = (ServerPlayer) packetContext.getPlayer(); + if (player.getServer().getProfilePermissions(player.getGameProfile()) < player.getServer().getOperatorUserPermissionLevel()) { + player.displayClientMessage(new TranslatableComponent("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - if (!player.inventory.getCursorStack().isEmpty()) { - player.inventory.setCursorStack(ItemStack.EMPTY); - player.updateCursorStack(); + if (!player.inventory.getCarried().isEmpty()) { + player.inventory.setCarried(ItemStack.EMPTY); + player.broadcastCarriedItem(); } }); ServerSidePacketRegistry.INSTANCE.register(CREATE_ITEMS_PACKET, (packetContext, packetByteBuf) -> { - ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); - if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) { - player.addMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false); + ServerPlayer player = (ServerPlayer) packetContext.getPlayer(); + if (player.getServer().getProfilePermissions(player.getGameProfile()) < player.getServer().getOperatorUserPermissionLevel()) { + player.displayClientMessage(new TranslatableComponent("text.rei.no_permission_cheat").withStyle(ChatFormatting.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)); + ItemStack stack = packetByteBuf.readItem(); + if (player.inventory.add(stack.copy())) { + ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(stack.copy()).writeUtf(player.getScoreboardName(), 32767)); } else - player.addMessage(new TranslatableText("text.rei.failed_cheat_items"), false); + player.displayClientMessage(new TranslatableComponent("text.rei.failed_cheat_items"), false); }); ServerSidePacketRegistry.INSTANCE.register(CREATE_ITEMS_GRAB_PACKET, (packetContext, packetByteBuf) -> { - ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); - if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) { - player.addMessage(new TranslatableText("text.rei.no_permission_cheat").formatted(Formatting.RED), false); + ServerPlayer player = (ServerPlayer) packetContext.getPlayer(); + if (player.getServer().getProfilePermissions(player.getGameProfile()) < player.getServer().getOperatorUserPermissionLevel()) { + player.displayClientMessage(new TranslatableComponent("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - PlayerInventory inventory = player.inventory; - ItemStack itemStack = packetByteBuf.readItemStack(); + Inventory inventory = player.inventory; + ItemStack itemStack = packetByteBuf.readItem(); ItemStack stack = itemStack.copy(); - if (!inventory.getCursorStack().isEmpty() && ItemStack.areItemsEqual(inventory.getCursorStack(), stack) && ItemStack.areTagsEqual(inventory.getCursorStack(), stack)) { - stack.setCount(MathHelper.clamp(stack.getCount() + inventory.getCursorStack().getCount(), 1, stack.getMaxCount())); - } else if (!inventory.getCursorStack().isEmpty()) { + if (!inventory.getCarried().isEmpty() && ItemStack.isSameIgnoreDurability(inventory.getCarried(), stack) && ItemStack.tagMatches(inventory.getCarried(), stack)) { + stack.setCount(Mth.clamp(stack.getCount() + inventory.getCarried().getCount(), 1, stack.getMaxStackSize())); + } else if (!inventory.getCarried().isEmpty()) { return; } - inventory.setCursorStack(stack.copy()); - player.updateCursorStack(); - ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(itemStack.copy()).writeString(player.getEntityName(), 32767)); + inventory.setCarried(stack.copy()); + player.broadcastCarriedItem(); + ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(itemStack.copy()).writeUtf(player.getScoreboardName(), 32767)); }); ServerSidePacketRegistry.INSTANCE.register(MOVE_ITEMS_PACKET, (packetContext, packetByteBuf) -> { - Identifier category = packetByteBuf.readIdentifier(); - ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); - Container container = player.container; - PlayerContainer playerContainer = player.playerContainer; + ResourceLocation category = packetByteBuf.readResourceLocation(); + ServerPlayer player = (ServerPlayer) packetContext.getPlayer(); + AbstractContainerMenu container = player.containerMenu; + InventoryMenu playerContainer = player.inventoryMenu; try { boolean shift = packetByteBuf.readBoolean(); - DefaultedList> input = DefaultedList.of(); + NonNullList> input = NonNullList.create(); int mapSize = packetByteBuf.readInt(); for (int i = 0; i < mapSize; i++) { List list = Lists.newArrayList(); int count = packetByteBuf.readInt(); for (int j = 0; j < count; j++) { - list.add(packetByteBuf.readItemStack()); + list.add(packetByteBuf.readItem()); } input.add(list); } try { InputSlotCrafter.start(category, container, player, input, shift); } catch (InputSlotCrafter.NotEnoughMaterialsException e) { - if (!(container instanceof CraftingContainer)) + if (!(container instanceof RecipeBookMenu)) return; - PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeInt(input.size()); for (List stacks : input) { buf.writeInt(stacks.size()); for (ItemStack stack : stacks) { - buf.writeItemStack(stack); + buf.writeItem(stack); } } if (ServerSidePacketRegistry.INSTANCE.canPlayerReceive(player, NOT_ENOUGH_ITEMS_PACKET)) { ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NOT_ENOUGH_ITEMS_PACKET, buf); } } catch (IllegalStateException e) { - player.sendMessage(new TranslatableText(e.getMessage()).formatted(Formatting.RED), Util.NIL_UUID); + player.sendMessage(new TranslatableComponent(e.getMessage()).withStyle(ChatFormatting.RED), Util.NIL_UUID); } catch (Exception e) { - player.sendMessage(new TranslatableText("error.rei.internal.error", e.getMessage()).formatted(Formatting.RED), Util.NIL_UUID); + player.sendMessage(new TranslatableComponent("error.rei.internal.error", e.getMessage()).withStyle(ChatFormatting.RED), Util.NIL_UUID); e.printStackTrace(); } } catch (Exception e) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java index 2f5240d09..f290132d9 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java @@ -25,7 +25,7 @@ package me.shedaniel.rei; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.util.Pair; +import net.minecraft.util.Tuple; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; @@ -41,8 +41,8 @@ public class RoughlyEnoughItemsState { public static final Logger LOGGER = LogManager.getFormatterLogger("REI"); - private static List> errors = new ArrayList<>(); - private static List> warnings = new ArrayList<>(); + private static List> errors = new ArrayList<>(); + private static List> warnings = new ArrayList<>(); private static Set errorSet = new LinkedHashSet<>(); private static Set warningSet = new LinkedHashSet<>(); private static List continueCallbacks = new ArrayList<>(); @@ -51,7 +51,7 @@ public class RoughlyEnoughItemsState { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || FabricLoader.getInstance().isDevelopmentEnvironment()) throw new RuntimeException(reason); if (RoughlyEnoughItemsState.errorSet.add(reason + " " + null)) { - RoughlyEnoughItemsState.errors.add(new Pair<>(reason, null)); + RoughlyEnoughItemsState.errors.add(new Tuple<>(reason, null)); LOGGER.error(reason); } } @@ -60,21 +60,21 @@ public class RoughlyEnoughItemsState { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || FabricLoader.getInstance().isDevelopmentEnvironment()) throw new RuntimeException(reason + " " + link); if (RoughlyEnoughItemsState.errorSet.add(reason + " " + link)) { - RoughlyEnoughItemsState.errors.add(new Pair<>(reason, link)); + RoughlyEnoughItemsState.errors.add(new Tuple<>(reason, link)); LOGGER.error(reason + " " + link); } } public static void warn(String reason) { if (RoughlyEnoughItemsState.warningSet.add(reason + " " + null)) { - RoughlyEnoughItemsState.warnings.add(new Pair<>(reason, null)); + RoughlyEnoughItemsState.warnings.add(new Tuple<>(reason, null)); LOGGER.warn(reason); } } public static void warn(String reason, String link) { if (RoughlyEnoughItemsState.warningSet.add(reason + " " + link)) { - RoughlyEnoughItemsState.warnings.add(new Pair<>(reason, link)); + RoughlyEnoughItemsState.warnings.add(new Tuple<>(reason, link)); LOGGER.warn(reason + " " + link); } } @@ -83,11 +83,11 @@ public class RoughlyEnoughItemsState { continueCallbacks.add(runnable); } - public static List> getErrors() { + public static List> getErrors() { return errors; } - public static List> getWarnings() { + public static List> getWarnings() { return warnings; } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ConfigReloadingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ConfigReloadingScreen.java index 12d1fa039..813494c26 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ConfigReloadingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ConfigReloadingScreen.java @@ -23,12 +23,12 @@ package me.shedaniel.rei.gui; +import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.rei.api.RecipeHelper; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.client.util.NarratorManager; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Util; +import net.minecraft.Util; +import net.minecraft.client.gui.chat.NarratorChatListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.resources.language.I18n; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal @@ -37,7 +37,7 @@ public class ConfigReloadingScreen extends Screen { private Screen parent; public ConfigReloadingScreen(Screen parent) { - super(NarratorManager.EMPTY); + super(NarratorChatListener.NO_TITLE); this.parent = parent; } @@ -47,13 +47,13 @@ public class ConfigReloadingScreen extends Screen { } @Override - public void render(MatrixStack matrices, int int_1, int int_2, float float_1) { - this.renderBackgroundTexture(0); + public void render(PoseStack matrices, int int_1, int int_2, float float_1) { + this.renderDirtBackground(0); if (!RecipeHelper.getInstance().arePluginsLoading()) - client.openScreen(parent); - this.drawCenteredString(matrices, this.textRenderer, I18n.translate("text.rei.config.is.reloading"), this.width / 2, this.height / 2 - 50, 16777215); + minecraft.setScreen(parent); + this.drawCenteredString(matrices, this.font, I18n.get("text.rei.config.is.reloading"), this.width / 2, this.height / 2 - 50, 16777215); String string_3; - switch ((int) (Util.getMeasuringTimeMs() / 300L % 4L)) { + switch ((int) (Util.getMillis() / 300L % 4L)) { case 0: default: string_3 = "O o o"; @@ -65,7 +65,7 @@ public class ConfigReloadingScreen extends Screen { case 2: string_3 = "o o O"; } - this.drawCenteredString(matrices, this.textRenderer, string_3, this.width / 2, this.height / 2 - 41, 8421504); + this.drawCenteredString(matrices, this.font, string_3, this.width / 2, this.height / 2 - 41, 8421504); super.render(matrices, int_1, int_2, float_1); } } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 36ef7ecea..5e0af4f96 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -24,7 +24,12 @@ package me.shedaniel.rei.gui; import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector4f; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -43,32 +48,27 @@ import me.shedaniel.rei.impl.InternalWidgets; import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.impl.Weather; import me.shedaniel.rei.utils.CollectionUtils; -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.ContainerScreen; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.client.util.NarratorManager; -import net.minecraft.client.util.Window; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.client.util.math.Vector4f; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.slot.Slot; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.world.GameMode; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.chat.NarratorChatListener; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.FormattedCharSequence; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.block.Blocks; import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -82,7 +82,7 @@ import java.util.List; @ApiStatus.Internal public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverlay { - private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); + private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); private static final List TOOLTIPS = Lists.newArrayList(); private static final List AFTER_RENDER = Lists.newArrayList(); private static final EntryListWidget ENTRY_LIST_WIDGET = new EntryListWidget(); @@ -91,11 +91,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl public boolean shouldReInit = false; private int tooltipWidth; private int tooltipHeight; - private List tooltipLines; - public final TriConsumer renderTooltipCallback = (matrices, mouse, aFloat) -> { + private List tooltipLines; + public final TriConsumer renderTooltipCallback = (matrices, mouse, aFloat) -> { RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); - matrices.push(); + matrices.pushPose(); matrices.translate(0, 0, 999); int x = mouse.x; int y = mouse.y; @@ -109,14 +109,14 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl this.fillGradient(matrices, x - 3, y - 3, x + tooltipWidth + 3, y - 3 + 1, 1347420415, 1347420415); this.fillGradient(matrices, x - 3, y + tooltipHeight + 2, x + tooltipWidth + 3, y + tooltipHeight + 3, 1344798847, 1344798847); int currentY = y; - VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); - Matrix4f matrix = matrices.peek().getModel(); + MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + Matrix4f matrix = matrices.last().pose(); for (int lineIndex = 0; lineIndex < tooltipLines.size(); lineIndex++) { - font.draw(tooltipLines.get(lineIndex), x, currentY, -1, true, matrix, immediate, false, 0, 15728880); + font.drawInBatch(tooltipLines.get(lineIndex), x, currentY, -1, true, matrix, immediate, false, 0, 15728880); currentY += lineIndex == 0 ? 12 : 10; } - immediate.draw(); - matrices.pop(); + immediate.endBatch(); + matrices.popPose(); RenderSystem.enableDepthTest(); RenderSystem.enableRescaleNormal(); }; @@ -191,8 +191,8 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl this.weatherMenu = null; this.renderWeatherMenu = false; this.weatherButton = null; - this.window = MinecraftClient.getInstance().getWindow(); - this.bounds = DisplayHelper.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), MinecraftClient.getInstance().currentScreen); + this.window = Minecraft.getInstance().getWindow(); + this.bounds = DisplayHelper.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen); widgets.add(ENTRY_LIST_WIDGET); if (ConfigObject.getInstance().isFavoritesEnabled()) { if (favoritesListWidget == null) @@ -207,7 +207,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl this.widgets.add(ScreenHelper.getSearchField()); ScreenHelper.getSearchField().setChangedListener(s -> ENTRY_LIST_WIDGET.updateSearch(s, false)); if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { - widgets.add(leftButton = Widgets.createButton(new Rectangle(bounds.x, bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), new TranslatableText("text.rei.left_arrow")) + widgets.add(leftButton = Widgets.createButton(new Rectangle(bounds.x, bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), new TranslatableComponent("text.rei.left_arrow")) .onClick(button -> { ENTRY_LIST_WIDGET.previousPage(); if (ENTRY_LIST_WIDGET.getPage() < 0) @@ -215,9 +215,9 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl ENTRY_LIST_WIDGET.updateEntriesPosition(); }) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y)) - .tooltipLine(I18n.translate("text.rei.previous_page")) + .tooltipLine(I18n.get("text.rei.previous_page")) .focusable(false)); - widgets.add(rightButton = Widgets.createButton(new Rectangle(bounds.x + bounds.width - 18, bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), new TranslatableText("text.rei.right_arrow")) + widgets.add(rightButton = Widgets.createButton(new Rectangle(bounds.x + bounds.width - 18, bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), new TranslatableComponent("text.rei.right_arrow")) .onClick(button -> { ENTRY_LIST_WIDGET.nextPage(); if (ENTRY_LIST_WIDGET.getPage() >= ENTRY_LIST_WIDGET.getTotalPages()) @@ -225,14 +225,14 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl ENTRY_LIST_WIDGET.updateEntriesPosition(); }) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y)) - .tooltipLine(I18n.translate("text.rei.next_page")) + .tooltipLine(I18n.get("text.rei.next_page")) .focusable(false)); } final Rectangle configButtonArea = getConfigButtonArea(); Widget tmp; widgets.add(tmp = InternalWidgets.wrapLateRenderable(InternalWidgets.mergeWidgets( - Widgets.createButton(configButtonArea, NarratorManager.EMPTY) + Widgets.createButton(configButtonArea, NarratorChatListener.NO_TITLE) .onClick(button -> { if (Screen.hasShiftDown()) { ClientHelper.getInstance().setCheating(!ClientHelper.getInstance().isCheating()); @@ -250,37 +250,37 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl .focusable(false) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y)) .tooltipSupplier(button -> { - String tooltips = I18n.translate("text.rei.config_tooltip"); + String tooltips = I18n.get("text.rei.config_tooltip"); tooltips += "\n "; if (!ClientHelper.getInstance().isCheating()) - tooltips += "\n" + I18n.translate("text.rei.cheating_disabled"); + tooltips += "\n" + I18n.get("text.rei.cheating_disabled"); else if (!RoughlyEnoughItemsCore.hasOperatorPermission()) { - if (minecraft.interactionManager.hasCreativeInventory()) - tooltips += "\n" + I18n.translate("text.rei.cheating_limited_creative_enabled"); - else tooltips += "\n" + I18n.translate("text.rei.cheating_enabled_no_perms"); + if (minecraft.gameMode.hasInfiniteItems()) + tooltips += "\n" + I18n.get("text.rei.cheating_limited_creative_enabled"); + else tooltips += "\n" + I18n.get("text.rei.cheating_enabled_no_perms"); } else if (RoughlyEnoughItemsCore.hasPermissionToUsePackets()) - tooltips += "\n" + I18n.translate("text.rei.cheating_enabled"); + tooltips += "\n" + I18n.get("text.rei.cheating_enabled"); else - tooltips += "\n" + I18n.translate("text.rei.cheating_limited_enabled"); + tooltips += "\n" + I18n.get("text.rei.cheating_limited_enabled"); return tooltips; }), Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - helper.setZOffset(helper.getZOffset() + 1); - MinecraftClient.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE); - helper.drawTexture(matrices, configButtonArea.x + 3, configButtonArea.y + 3, 0, 0, 14, 14); + helper.setBlitOffset(helper.getBlitOffset() + 1); + Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); + helper.blit(matrices, configButtonArea.x + 3, configButtonArea.y + 3, 0, 0, 14, 14); }) ) )); tmp.setZ(600); if (ConfigObject.getInstance().doesShowUtilsButtons()) { - widgets.add(gameModeButton = Widgets.createButton(ConfigObject.getInstance().isLowerConfigButton() ? new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20) : new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 55 : 35, 10, 20, 20), NarratorManager.EMPTY) + widgets.add(gameModeButton = Widgets.createButton(ConfigObject.getInstance().isLowerConfigButton() ? new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 10, 20, 20) : new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 55 : 35, 10, 20, 20), NarratorChatListener.NO_TITLE) .onRender((matrices, button) -> { boolean tmpRender = renderGameModeMenu; renderGameModeMenu = !renderWeatherMenu && (button.isFocused() || button.containsMouse(PointHelper.ofMouse()) || (wrappedGameModeMenu != null && wrappedGameModeMenu.containsMouse(PointHelper.ofMouse()))); if (tmpRender != renderGameModeMenu) { if (renderGameModeMenu) { this.gameModeMenu = new Menu(new Point(button.getBounds().x, button.getBounds().getMaxY()), - CollectionUtils.filterAndMap(Arrays.asList(GameMode.values()), mode -> mode != GameMode.NOT_SET, GameModeMenuEntry::new)); + CollectionUtils.filterAndMap(Arrays.asList(GameType.values()), mode -> mode != GameType.NOT_SET, GameModeMenuEntry::new)); if (ConfigObject.getInstance().isLeftHandSidePanel()) this.gameModeMenu.menuStartPoint.x -= this.gameModeMenu.getBounds().width - this.gameModeButton.getBounds().width; this.wrappedGameModeMenu = InternalWidgets.wrapTranslate(InternalWidgets.wrapLateRenderable(gameModeMenu), 0, 0, 600); @@ -289,12 +289,12 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl removeGameModeMenu(); } } - button.setText(new LiteralText(getGameModeShortText(getCurrentGameMode()))); + button.setText(new TextComponent(getGameModeShortText(getCurrentGameMode()))); }) .focusable(false) - .tooltipLine(I18n.translate("text.rei.gamemode_button.tooltip.all")) + .tooltipLine(I18n.get("text.rei.gamemode_button.tooltip.all")) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y))); - widgets.add(weatherButton = Widgets.createButton(new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 35, 20, 20), NarratorManager.EMPTY) + widgets.add(weatherButton = Widgets.createButton(new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 35, 20, 20), NarratorChatListener.NO_TITLE) .onRender((matrices, button) -> { boolean tmpRender = renderWeatherMenu; renderWeatherMenu = !renderGameModeMenu && (button.isFocused() || button.containsMouse(PointHelper.ofMouse()) || (wrappedWeatherMenu != null && wrappedWeatherMenu.containsMouse(PointHelper.ofMouse()))); @@ -311,18 +311,18 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } } }) - .tooltipLine(I18n.translate("text.rei.weather_button.tooltip.all")) + .tooltipLine(I18n.get("text.rei.weather_button.tooltip.all")) .focusable(false) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y))); widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - MinecraftClient.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE); + Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - helper.drawTexture(matrices, weatherButton.getBounds().x + 3, weatherButton.getBounds().y + 3, getCurrentWeather().getId() * 14, 14, 14, 14); + helper.blit(matrices, weatherButton.getBounds().x + 3, weatherButton.getBounds().y + 3, getCurrentWeather().getId() * 14, 14, 14, 14); })); } subsetsButtonBounds = getSubsetsButtonBounds(); if (ConfigObject.getInstance().isSubsetsEnabled()) { - widgets.add(InternalWidgets.wrapLateRenderable(InternalWidgets.wrapTranslate(Widgets.createButton(subsetsButtonBounds, ((ClientHelperImpl) ClientHelper.getInstance()).isAprilFools.get() ? new TranslatableText("text.rei.tiny_potato") : new TranslatableText("text.rei.subsets")) + widgets.add(InternalWidgets.wrapLateRenderable(InternalWidgets.wrapTranslate(Widgets.createButton(subsetsButtonBounds, ((ClientHelperImpl) ClientHelper.getInstance()).isAprilFools.get() ? new TranslatableComponent("text.rei.tiny_potato") : new TranslatableComponent("text.rei.subsets")) .onClick(button -> { if (subsetsMenu == null) {