diff options
Diffstat (limited to 'default-plugin/src')
15 files changed, 139 insertions, 155 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java index 2f902826c..1ddc6d6eb 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java @@ -43,7 +43,6 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; import me.shedaniel.rei.api.client.registry.transfer.simple.SimpleTransferHandler; -import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; @@ -108,6 +107,7 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.ApiStatus; +import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.function.Supplier; import java.util.function.UnaryOperator; @@ -145,28 +145,19 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin @Override public void registerEntries(EntryRegistry registry) { - if (Minecraft.getInstance().player == null || Minecraft.getInstance().player.connection == null) - return; - Minecraft.getInstance().executeBlocking(() -> { - CreativeModeTabs.tryRebuildTabContents(Minecraft.getInstance().player.connection.enabledFeatures(), - Minecraft.getInstance().options.operatorItemsTab().get() && Minecraft.getInstance().player.canUseGameMasterBlocks(), - BasicDisplay.registryAccess()); - }); Multimap<Item, EntryStack<ItemStack>> items = Multimaps.newListMultimap(new Reference2ObjectOpenHashMap<>() , ArrayList::new); - for (CreativeModeTab tab : CreativeModeTabs.allTabs()) { - if (tab.getType() != CreativeModeTab.Type.HOTBAR && tab.getType() != CreativeModeTab.Type.INVENTORY) { - try { - for (ItemStack stack : tab.getDisplayItems()) { - try { - items.put(stack.getItem(), EntryStacks.of(stack)); - } catch (Exception ignore) { - } + for (Map.Entry<CreativeModeTab, Collection<ItemStack>> entry : collectTabs().entrySet()) { + try { + for (ItemStack stack : entry.getValue()) { + try { + items.put(stack.getItem(), EntryStacks.of(stack)); + } catch (Exception ignore) { } - } catch (Exception exception) { - exception.printStackTrace(); } + } catch (Exception exception) { + exception.printStackTrace(); } } @@ -191,6 +182,17 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin } } + private static Map<CreativeModeTab, Collection<ItemStack>> collectTabs() { + try { + return (Map<CreativeModeTab, Collection<ItemStack>>) Class.forName(Platform.isForge() ? "me.shedaniel.rei.impl.client.forge.CreativeModeTabCollectorImpl" + : "me.shedaniel.rei.impl.client.fabric.CreativeModeTabCollectorImpl") + .getDeclaredMethod("collectTabs") + .invoke(null); + } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + @Override public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) { registry.group(new ResourceLocation("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"), @@ -307,7 +309,6 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, DefaultBlastingDisplay::new); registry.registerRecipeFiller(CampfireCookingRecipe.class, RecipeType.CAMPFIRE_COOKING, DefaultCampfireDisplay::new); registry.registerRecipeFiller(StonecutterRecipe.class, RecipeType.STONECUTTING, DefaultStoneCuttingDisplay::new); - registry.registerRecipeFiller(LegacyUpgradeRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new); registry.registerRecipeFiller(SmithingTransformRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new); registry.registerRecipeFiller(SmithingTrimRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new); registry.registerFiller(AnvilRecipe.class, DefaultAnvilDisplay::new); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java index 19d614393..e44fc7126 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; @@ -39,6 +38,7 @@ import me.shedaniel.rei.plugin.common.displays.brewing.DefaultBrewingDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; @@ -67,11 +67,11 @@ public class DefaultBrewingCategory implements DisplayCategory<DefaultBrewingDis Point startPoint = new Point(bounds.getCenterX() - 52, bounds.getCenterY() - 29); List<Widget> widgets = Lists.newArrayList(); widgets.add(Widgets.createRecipeBase(bounds)); - widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - RenderSystem.setShaderTexture(0, REIRuntime.getInstance().getDefaultDisplayTexture()); - helper.blit(matrices, startPoint.x, startPoint.y, 0, 108, 103, 59); + widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + ResourceLocation texture = REIRuntime.getInstance().getDefaultDisplayTexture(); + graphics.blit(texture, startPoint.x, startPoint.y, 0, 108, 103, 59); int width = Mth.ceil(System.currentTimeMillis() / 250d % 18d); - helper.blit(matrices, startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4); + graphics.blit(texture, startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4); })); widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entry(EntryStacks.of(Items.BLAZE_POWDER)).disableBackground().markInput()); widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 1)).entries(display.getInputEntries().get(0)).disableBackground().markInput()); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java index c0d2a08b6..27005fee2 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java @@ -41,6 +41,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; @@ -78,8 +79,8 @@ public class DefaultCompostingCategory implements DisplayCategory<DefaultCompost } @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, text.getVisualOrderText(), rectangle.x + 5, rectangle.y + 6, -1); + public void render(GuiGraphics graphics, Rectangle rectangle, int mouseX, int mouseY, float delta) { + graphics.drawString(Minecraft.getInstance().font, text.getVisualOrderText(), rectangle.x + 5, rectangle.y + 6, -1, false); } }; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java index ba2329722..2f1157a13 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories; import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.DisplayRenderer; @@ -38,6 +37,7 @@ import me.shedaniel.rei.plugin.common.displays.DefaultFuelDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; @@ -103,11 +103,13 @@ public class DefaultFuelCategory implements DisplayCategory<DefaultFuelDisplay> } @Override - public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - slot.setZ(getZ() + 50); + public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 50); slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2); - slot.render(matrices, mouseX, mouseY, delta); - Minecraft.getInstance().font.drawShadow(matrices, text.getVisualOrderText(), bounds.x + 25, bounds.y + 8, -1); + slot.render(graphics, mouseX, mouseY, delta); + graphics.pose().popPose(); + graphics.drawString(Minecraft.getInstance().font, text.getVisualOrderText(), bounds.x + 25, bounds.y + 8, -1); } }; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java index 7c7399df0..38de0e376 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java @@ -31,7 +31,6 @@ import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.DisplayRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.CloseableScissors; @@ -45,6 +44,7 @@ import me.shedaniel.rei.plugin.common.displays.DefaultInformationDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; @@ -89,23 +89,23 @@ public class DefaultInformationCategory implements DisplayCategory<DefaultInform } @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1); + public void render(GuiGraphics graphics, Rectangle rectangle, int mouseX, int mouseY, float delta) { + graphics.drawString(Minecraft.getInstance().font, name, rectangle.x + 5, rectangle.y + 6, -1, false); } }; } @Override public Renderer getIcon() { - return new AbstractRenderer() { + return new Renderer() { @Override - public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { RenderSystem.setShaderTexture(0, REIRuntime.getInstance().getDefaultDisplayTexture()); - matrices.pushPose(); - matrices.translate(-1.2f, -1, 0); - Matrix4f matrix = matrices.last().pose(); + graphics.pose().pushPose(); + graphics.pose().translate(-1.2f, -1, 0); + Matrix4f matrix = graphics.pose().last().pose(); DefaultInformationCategory.innerBlit(matrix, bounds.getCenterX() - 8, bounds.getCenterX() + 8, bounds.getCenterY() - 8, bounds.getCenterY() + 8, 0, 116f / 256f, (116f + 16f) / 256f, 0f, 16f / 256f); - matrices.popPose(); + graphics.pose().popPose(); } }; } @@ -189,28 +189,28 @@ public class DefaultInformationCategory implements DisplayCategory<DefaultInform } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + try (CloseableScissors scissors = scissor(graphics, innerBounds)) { int currentY = -scrolling.scrollAmountInt() + innerBounds.y; for (FormattedCharSequence text : texts) { if (text != null && currentY + font.lineHeight >= innerBounds.y && currentY <= innerBounds.getMaxY()) { - font.draw(matrices, text, innerBounds.x + 2, currentY + 2, REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF090909); + graphics.drawString(font, text, innerBounds.x + 2, currentY + 2, REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF090909, false); } currentY += text == null ? 4 : font.lineHeight; } } if (scrolling.hasScrollBar()) { if (scrolling.scrollAmount() > 8) { - fillGradient(matrices, innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.y + 16, 0xFFC6C6C6, 0x00C6C6C6); + graphics.fillGradient(innerBounds.x, innerBounds.y, innerBounds.getMaxX(), innerBounds.y + 16, 0xFFC6C6C6, 0x00C6C6C6); } if (scrolling.getMaxScroll() - scrolling.scrollAmount() > 8) { - fillGradient(matrices, innerBounds.x, innerBounds.getMaxY() - 16, innerBounds.getMaxX(), innerBounds.getMaxY(), 0x00C6C6C6, 0xFFC6C6C6); + graphics.fillGradient(innerBounds.x, innerBounds.getMaxY() - 16, innerBounds.getMaxX(), innerBounds.getMaxY(), 0x00C6C6C6, 0xFFC6C6C6); } } - try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { - scrolling.renderScrollBar(0, 1, 1f); + try (CloseableScissors scissors = scissor(graphics, scrolling.getBounds())) { + scrolling.renderScrollBar(graphics, 0, 1, 1f); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java index 7c49b9233..0c068776d 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories.beacon; import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -40,6 +39,7 @@ import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.common.BuiltinPlugin; import me.shedaniel.rei.plugin.common.displays.beacon.DefaultBeaconBaseDisplay; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -74,8 +74,8 @@ public class DefaultBeaconBaseCategory implements DisplayCategory<DefaultBeaconB } @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1); + public void render(GuiGraphics graphics, Rectangle rectangle, int mouseX, int mouseY, float delta) { + graphics.drawString(Minecraft.getInstance().font, name, rectangle.x + 5, rectangle.y + 6, -1, false); } }; } @@ -150,10 +150,10 @@ public class DefaultBeaconBaseCategory implements DisplayCategory<DefaultBeaconB } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + try (CloseableScissors scissors = scissor(graphics, innerBounds)) { for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { for (int x = 0; x < 8; x++) { int index = y * 8 + x; @@ -161,12 +161,12 @@ public class DefaultBeaconBaseCategory implements DisplayCategory<DefaultBeaconB break; Slot widget = widgets.get(index); widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); - widget.render(matrices, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); } } } - try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { - scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); + try (CloseableScissors scissors = scissor(graphics, scrolling.getBounds())) { + scrolling.renderScrollBar(graphics, 0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java index 5d74bfea1..c70d6e3bc 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories.beacon; import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; @@ -40,6 +39,7 @@ import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.common.BuiltinPlugin; import me.shedaniel.rei.plugin.common.displays.beacon.DefaultBeaconPaymentDisplay; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -74,8 +74,8 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory<DefaultBeac } @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1); + public void render(GuiGraphics graphics, Rectangle rectangle, int mouseX, int mouseY, float delta) { + graphics.drawString(Minecraft.getInstance().font, name, rectangle.x + 5, rectangle.y + 6, -1, false); } }; } @@ -150,10 +150,10 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory<DefaultBeac } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + try (CloseableScissors scissors = scissor(graphics, innerBounds)) { for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { for (int x = 0; x < 8; x++) { int index = y * 8 + x; @@ -161,12 +161,12 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory<DefaultBeac break; Slot widget = widgets.get(index); widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); - widget.render(matrices, mouseX, mouseY, delta); + widget.render(graphics, mouseX, mouseY, delta); } } } - try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { - scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); + try (CloseableScissors scissors = scissor(graphics, scrolling.getBounds())) { + scrolling.renderScrollBar(graphics, 0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java index f14b1d833..7f0466cd8 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java @@ -24,13 +24,11 @@ package me.shedaniel.rei.plugin.client.categories.tag; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.FloatingRectangle; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; @@ -45,6 +43,7 @@ import me.shedaniel.rei.plugin.common.displays.tag.TagNode; import me.shedaniel.rei.plugin.common.displays.tag.TagNodes; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -99,7 +98,7 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, } }, 1400); - widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { + widgets.add(Widgets.createDrawableWidget((matrices, mouseX, mouseY, delta) -> { innerBounds.setBounds(recipeBounds.x + 6 + 14, recipeBounds.y + 6, recipeBounds.width - 12 - 14, recipeBounds.height - 12); overflowBounds.setBounds(innerBounds.x + 1, innerBounds.y + 1, innerBounds.width - 2, innerBounds.height - 2); expandButtonBounds.setBounds(recipeBounds.x + 5, recipeBounds.y + 6, 13, 13); @@ -134,14 +133,17 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, Function<Holder<?>, EntryStack<?>> mapper = holder -> { EntryStack<?> stack = ((Function<Holder<?>, EntryStack<?>>) displayMapper).apply(holder); if (stack.isEmpty()) { - return ClientEntryStacks.of(new AbstractRenderer() { + return ClientEntryStacks.of(new Renderer() { @Override - public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) { Minecraft instance = Minecraft.getInstance(); Font font = instance.font; String text = "?"; int width = font.width(text); - font.draw(matrices, text, bounds.getCenterX() - width / 2f + 0.2f, bounds.getCenterY() - font.lineHeight / 2f + 1f, REIRuntime.getInstance().isDarkThemeEnabled() ? -4473925 : -12566464); + graphics.pose().pushPose(); + graphics.pose().translate(bounds.getCenterX() - width / 2f + 0.2f, bounds.getCenterY() - font.lineHeight / 2f + 1f, 0); + graphics.drawString(font, text, 0, 0, REIRuntime.getInstance().isDarkThemeEnabled() ? -4473925 : -12566464, false); + graphics.pose().popPose(); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java index 97df68e75..128300f11 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ReferenceTagNodeWidget.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.plugin.client.categories.tag; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; @@ -33,6 +32,7 @@ import me.shedaniel.rei.api.client.util.MatrixUtils; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.plugin.common.displays.tag.TagNode; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.core.Holder; @@ -68,15 +68,14 @@ public class ReferenceTagNodeWidget<S, T> extends TagNodeWidget<S, T> { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { - if (this.overflowBounds.intersects(MatrixUtils.transform(poses.last().pose(), getBounds()))) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), getBounds()))) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, new ResourceLocation("textures/gui/advancements/widgets.png")); - this.blit(poses, bounds.x, bounds.y, 1, 128 + 27, 24, 24); + graphics.blit(new ResourceLocation("textures/gui/advancements/widgets.png"), bounds.x, bounds.y, 1, 128 + 27, 24, 24); this.slot.getBounds().setLocation(bounds.getCenterX() - this.slot.getBounds().getWidth() / 2, bounds.y + (bounds.height - this.slot.getBounds().getHeight()) / 2 + 1); - this.slot.render(poses, mouseX, mouseY, delta); + this.slot.render(graphics, mouseX, mouseY, delta); if (this.containsMouse(mouseX, mouseY)) { - Tooltip.create(Component.literal("#" + this.node.getReference().location().toString())).queue(); + Tooltip.create(Component.literal("#" + this.node.getReference().location().toString())).queue(); } } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java index 3733fbedf..9b5c2747e 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/TagTreeWidget.java @@ -23,12 +23,12 @@ package me.shedaniel.rei.plugin.client.categories.tag; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.util.MatrixUtils; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.plugin.common.displays.tag.TagNode; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.core.Holder; @@ -75,24 +75,24 @@ public class TagTreeWidget<S, T> extends WidgetWithBounds { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.rootWidget.getBounds().setLocation(getBounds().getCenterX() - this.rootWidget.getBounds().getWidth() / 2, getBounds().y); - this.rootWidget.render(poses, mouseX, mouseY, delta); + this.rootWidget.render(graphics, mouseX, mouseY, delta); if (childWidgets.isEmpty()) return; - vLine(poses, rootWidget.getBounds().getCenterX(), rootWidget.getBounds().getMaxY(), rootWidget.getBounds().getMaxY() + 6, 0xFFFFFFFF); + graphics.vLine(rootWidget.getBounds().getCenterX(), rootWidget.getBounds().getMaxY(), rootWidget.getBounds().getMaxY() + 6, 0xFFFFFFFF); int childrenTotalWidth = childWidgets.stream().map(WidgetWithBounds::getBounds).mapToInt(value -> value.width + 6).sum() - 6; - hLine(poses, rootWidget.getBounds().getCenterX() - childrenTotalWidth / 2 + childWidgets.get(0).getBounds().width / 2, + graphics.hLine(rootWidget.getBounds().getCenterX() - childrenTotalWidth / 2 + childWidgets.get(0).getBounds().width / 2, rootWidget.getBounds().getCenterX() + childrenTotalWidth / 2 - childWidgets.get(childWidgets.size() - 1).getBounds().width / 2, rootWidget.getBounds().getMaxY() + 6, 0xFFFFFFFF); int x = 0; for (TagTreeWidget<S, T> childWidget : this.childWidgets) { - vLine(poses, getBounds().getCenterX() - childrenTotalWidth / 2 + x + childWidget.getBounds().width / 2, + graphics.vLine(getBounds().getCenterX() - childrenTotalWidth / 2 + x + childWidget.getBounds().width / 2, rootWidget.getBounds().getMaxY() + 6, rootWidget.getBounds().getMaxY() + 16, 0xFFFFFFFF); |
