From a35425108d9813f64779b519fedd4744a7eb6072 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 28 May 2023 04:09:32 +0800 Subject: Update to 1.20-pre6 --- .../client/categories/DefaultBrewingCategory.java | 10 +++---- .../categories/DefaultCompostingCategory.java | 5 ++-- .../client/categories/DefaultFuelCategory.java | 12 ++++---- .../categories/DefaultInformationCategory.java | 32 +++++++++++----------- .../beacon/DefaultBeaconBaseCategory.java | 16 +++++------ .../beacon/DefaultBeaconPaymentCategory.java | 16 +++++------ .../client/categories/tag/DefaultTagCategory.java | 14 ++++++---- .../categories/tag/ReferenceTagNodeWidget.java | 13 ++++----- .../client/categories/tag/TagTreeWidget.java | 16 +++++------ .../client/categories/tag/ValueTagNodeWidget.java | 16 +++++------ .../client/favorites/GameModeFavoriteEntry.java | 30 ++++++++++---------- .../plugin/client/favorites/TimeFavoriteEntry.java | 29 +++++++++----------- .../client/favorites/WeatherFavoriteEntry.java | 29 +++++++++----------- 13 files changed, 119 insertions(+), 119 deletions(-) (limited to 'default-plugin/src/main') 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 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 } @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= 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 { + 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, EntryStack> mapper = holder -> { EntryStack stack = ((Function, 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 extends TagNodeWidget { } @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 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 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); childWidget.getBounds().setLocation(getBounds().getCenterX() - childrenTotalWidth / 2 + x, this.rootWidget.getBounds().getMaxY() + 16); - if (this.overflowBounds.intersects(MatrixUtils.transform(poses.last().pose(), childWidget.getBounds()))) { - childWidget.render(poses, mouseX, mouseY, delta); + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), childWidget.getBounds()))) { + childWidget.render(graphics, mouseX, mouseY, delta); } x += childWidget.getBounds().width + 6; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java index 3f8ae3b9e..a108bdaa6 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java @@ -24,13 +24,13 @@ package me.shedaniel.rei.plugin.client.categories.tag; import com.google.common.base.Predicates; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.*; 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; import net.minecraft.core.HolderSet; @@ -81,19 +81,19 @@ public class ValueTagNodeWidget extends TagNodeWidget { } @Override - public void render(PoseStack poses, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { Rectangle bounds = getBounds(); - if (this.overflowBounds.intersects(MatrixUtils.transform(poses.last().pose(), bounds))) { - poses.pushPose(); - poses.translate(bounds.x, bounds.y, 0); + if (this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), bounds))) { + graphics.pose().pushPose(); + graphics.pose().translate(bounds.x, bounds.y, 0); Point mouse = new Point(mouseX - bounds.x, mouseY - bounds.y); for (Widget widget : this.widgets) { if (!(widget instanceof WidgetWithBounds withBounds) || - this.overflowBounds.intersects(MatrixUtils.transform(poses.last().pose(), withBounds.getBounds()))) { - widget.render(poses, mouse.x, mouse.y, delta); + this.overflowBounds.intersects(MatrixUtils.transform(graphics.pose().last().pose(), withBounds.getBounds()))) { + widget.render(graphics, mouse.x, mouse.y, delta); } } - poses.popPose(); + graphics.pose().popPose(); } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index 85accd118..d9ae50fe5 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.plugin.client.favorites; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.DataResult; import com.mojang.serialization.Lifecycle; import me.shedaniel.math.Rectangle; @@ -33,7 +32,6 @@ import me.shedaniel.rei.api.client.favorites.CompoundFavoriteRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; @@ -41,6 +39,7 @@ import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.nbt.CompoundTag; @@ -101,23 +100,26 @@ public class GameModeFavoriteEntry extends FavoriteEntry { private static Renderer getRenderer(int id) { GameType type = GameType.byId(id); - 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) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - matrices.pushPose(); - matrices.translate(bounds.getCenterX(), bounds.getCenterY(), 0); - matrices.scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); - renderGameModeText(matrices, type, 0, 0, color); - matrices.popPose(); + graphics.pose().pushPose(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + renderGameModeText(graphics, type, 0, 0, color); + graphics.pose().popPose(); } } - private void renderGameModeText(PoseStack matrices, GameType type, int centerX, int centerY, int color) { + private void renderGameModeText(GuiGraphics graphics, GameType type, int centerX, int centerY, int color) { Component s = Component.translatable("text.rei.short_gamemode." + type.getName()); Font font = Minecraft.getInstance().font; - font.draw(matrices, s, centerX - font.width(s) / 2f + 0.5f, centerY - 3.5f, color); + graphics.pose().pushPose(); + graphics.pose().translate(centerX - font.width(s) / 2f + 0.5f, centerY - 3.5f, 0); + graphics.drawString(font, s, 0, 0, color, false); + graphics.pose().popPose(); } @Override @@ -256,10 +258,10 @@ public class GameModeFavoriteEntry extends FavoriteEntry { } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { boolean disabled = this.minecraft.gameMode.getPlayerMode() == gameMode; if (selected && !disabled) { - fill(matrices, x, y, x + width, y + 12, -12237499); + graphics.fill(x, y, x + width, y + 12, -12237499); } if (!disabled && selected && containsMouse) { REIRuntime.getInstance().queueTooltip(Tooltip.create(Component.translatable("text.rei.gamemode_button.tooltip.entry", text))); @@ -268,7 +270,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry { if (disabled) { s = ChatFormatting.STRIKETHROUGH + s; } - font.draw(matrices, s, x + 2, y + 2, selected && !disabled ? 16777215 : 8947848); + graphics.drawString(font, s, x + 2, y + 2, selected && !disabled ? 16777215 : 8947848, false); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java index 69f5c9aa9..94139cf6e 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java @@ -23,8 +23,6 @@ package me.shedaniel.rei.plugin.client.favorites; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.DataResult; import com.mojang.serialization.Lifecycle; import me.shedaniel.math.Rectangle; @@ -34,12 +32,12 @@ import me.shedaniel.rei.api.client.favorites.CompoundFavoriteRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.language.I18n; @@ -136,22 +134,21 @@ public class TimeFavoriteEntry extends FavoriteEntry { private static Renderer getRenderer(int id) { Time time = Time.values()[id]; - 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) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - matrices.pushPose(); - matrices.translate(bounds.getCenterX(), bounds.getCenterY(), 0); - matrices.scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); - renderTimeIcon(matrices, time, 0, 0, color); - matrices.popPose(); + graphics.pose().pushPose(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + renderTimeIcon(graphics, time, 0, 0, color); + graphics.pose().popPose(); } } - private void renderTimeIcon(PoseStack matrices, Time time, int centerX, int centerY, int color) { - RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); - blit(matrices, centerX - 7, centerY - 7, time.ordinal() * 14 + 42, 14, 14, 14, 256, 256); + private void renderTimeIcon(GuiGraphics graphics, Time time, int centerX, int centerY, int color) { + graphics.blit(CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, time.ordinal() * 14 + 42, 14, 14, 14, 256, 256); } @Override @@ -290,14 +287,14 @@ public class TimeFavoriteEntry extends FavoriteEntry { } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (selected) { - fill(matrices, x, y, x + width, y + 12, -12237499); + graphics.fill(x, y, x + width, y + 12, -12237499); } if (selected && containsMouse) { REIRuntime.getInstance().queueTooltip(Tooltip.create(Component.translatable("text.rei.time_button.tooltip.entry", text))); } - font.draw(matrices, text, x + 2, y + 2, selected ? 16777215 : 8947848); + graphics.drawString(font, text, x + 2, y + 2, selected ? 16777215 : 8947848, false); } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index ce5fac685..94ea48476 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -23,8 +23,6 @@ package me.shedaniel.rei.plugin.client.favorites; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.DataResult; import com.mojang.serialization.Lifecycle; import me.shedaniel.math.Rectangle; @@ -34,12 +32,12 @@ import me.shedaniel.rei.api.client.favorites.CompoundFavoriteRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.language.I18n; @@ -112,22 +110,21 @@ public class WeatherFavoriteEntry extends FavoriteEntry { private static Renderer getRenderer(int id) { Weather weather = Weather.byId(id); - 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) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; if (bounds.width > 4 && bounds.height > 4) { - matrices.pushPose(); - matrices.translate(bounds.getCenterX(), bounds.getCenterY(), 0); - matrices.scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); - renderWeatherIcon(matrices, weather, 0, 0, color); - matrices.popPose(); + graphics.pose().pushPose(); + graphics.pose().translate(bounds.getCenterX(), bounds.getCenterY(), 0); + graphics.pose().scale(bounds.getWidth() / 18f, bounds.getHeight() / 18f, 1); + renderWeatherIcon(graphics, weather, 0, 0, color); + graphics.pose().popPose(); } } - private void renderWeatherIcon(PoseStack matrices, Weather type, int centerX, int centerY, int color) { - RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); - blit(matrices, centerX - 7, centerY - 7, type.getId() * 14, 14, 14, 14, 256, 256); + private void renderWeatherIcon(GuiGraphics graphics, Weather type, int centerX, int centerY, int color) { + graphics.blit(CHEST_GUI_TEXTURE, centerX - 7, centerY - 7, type.getId() * 14, 14, 14, 14, 256, 256); } @Override @@ -299,14 +296,14 @@ public class WeatherFavoriteEntry extends FavoriteEntry { } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (selected) { - fill(matrices, x, y, x + width, y + 12, -12237499); + graphics.fill(x, y, x + width, y + 12, -12237499); } if (selected && containsMouse) { REIRuntime.getInstance().queueTooltip(Tooltip.create(Component.translatable("text.rei.weather_button.tooltip.entry", text))); } - font.draw(matrices, text, x + 2, y + 2, selected ? 16777215 : 8947848); + graphics.drawString(font, text, x + 2, y + 2, selected ? 16777215 : 8947848, false); } @Override -- cgit