From 5e5da284022a7b52391e55a51535247116398bb1 Mon Sep 17 00:00:00 2001 From: arichornloverALT <> Date: Wed, 28 Aug 2024 02:13:45 -0500 Subject: [PATCH 1/6] Release 1.19.4-1.7.1 --- common/build.gradle | 2 +- .../wily/legacy/client/LegacyGuiGraphics.java | 8 +- .../java/wily/legacy/client/LegacyTip.java | 28 ++-- .../wily/legacy/client/screen/BookPanel.java | 28 ++-- .../client/screen/ConfirmationScreen.java | 10 +- .../legacy/client/screen/ControlTooltip.java | 22 +-- .../screen/ControllerMappingScreen.java | 20 +-- .../legacy/client/screen/CreationList.java | 14 +- .../client/screen/CreativeModeScreen.java | 36 ++--- .../client/screen/CustomRecipeIconHolder.java | 8 +- .../legacy/client/screen/DisplayRecipe.java | 22 +-- .../client/screen/FlatWorldLayerSelector.java | 56 ++++---- .../client/screen/HostOptionsScreen.java | 36 ++--- .../legacy/client/screen/JoinGameScreen.java | 14 +- .../legacy/client/screen/KeyboardScreen.java | 68 ++++----- .../client/screen/LeaderboardsScreen.java | 100 ++++++------- .../screen/LegacyAdvancementsScreen.java | 46 +++--- .../screen/LegacyBuffetWorldScreen.java | 30 ++-- .../client/screen/LegacyCraftingScreen.java | 84 +++++------ .../screen/LegacyFlatPresetsScreen.java | 30 ++-- .../client/screen/LegacyFlatWorldScreen.java | 56 ++++---- .../client/screen/LegacyIconHolder.java | 34 ++--- .../client/screen/LegacyKeyBindsScreen.java | 20 +-- .../client/screen/LegacyLanguageScreen.java | 8 +- .../client/screen/LegacyLoadingScreen.java | 24 ++-- .../client/screen/LegacyLoomScreen.java | 72 +++++----- .../client/screen/LegacyMerchantScreen.java | 76 +++++----- .../legacy/client/screen/LegacyScreen.java | 16 +-- .../client/screen/LegacyScrollRenderer.java | 4 +- .../client/screen/LegacySliderButton.java | 7 +- .../screen/LegacyStonecutterScreen.java | 40 +++--- .../legacy/client/screen/LegacyTabButton.java | 52 +++---- .../legacy/client/screen/LoadSaveScreen.java | 32 ++--- .../wily/legacy/client/screen/ModsScreen.java | 28 ++-- .../client/screen/OverlayPanelScreen.java | 14 +- .../legacy/client/screen/PackSelector.java | 26 ++-- .../java/wily/legacy/client/screen/Panel.java | 10 +- .../legacy/client/screen/PlayGameScreen.java | 34 ++--- .../client/screen/RecipeIconHolder.java | 10 +- .../client/screen/SaveOptionsScreen.java | 2 - .../client/screen/SaveRenderableList.java | 56 ++++---- .../client/screen/ScrollableRenderer.java | 4 +- .../client/screen/ServerEditScreen.java | 8 +- .../client/screen/ServerRenderableList.java | 66 ++++----- .../client/screen/SimpleLayoutRenderable.java | 10 +- .../wily/legacy/client/screen/TabList.java | 4 +- .../wily/legacy/client/screen/TickBox.java | 18 +-- .../legacy/client/screen/WidgetPanel.java | 2 +- .../client/screen/WorldMoreOptionsScreen.java | 20 +-- .../compat/FriendsServerRenderableList.java | 20 +-- .../screen/compat/WorldHostFriendsScreen.java | 32 ++--- .../wily/legacy/init/LegacyRegistries.java | 2 +- .../legacy/mixin/AbstractButtonMixin.java | 4 +- .../mixin/AbstractContainerScreenMixin.java | 20 +-- .../mixin/AbstractFurnaceScreenMixin.java | 56 ++++---- .../mixin/AbstractSignEditScreenMixin.java | 25 ++-- .../mixin/AbstractSliderButtonMixin.java | 16 +-- .../legacy/mixin/AdvancementToastMixin.java | 26 ++-- .../wily/legacy/mixin/AnvilScreenMixin.java | 46 +++--- .../wily/legacy/mixin/BeaconScreenMixin.java | 42 +++--- .../legacy/mixin/BookEditScreenMixin.java | 30 ++-- .../legacy/mixin/BookViewScreenMixin.java | 14 +- .../legacy/mixin/BossHealthOverlayMixin.java | 44 +++--- .../legacy/mixin/BrewingStandScreenMixin.java | 50 +++---- .../mixin/CartographyTableScreenMixin.java | 28 ++-- .../wily/legacy/mixin/ChatComponentMixin.java | 8 +- .../wily/legacy/mixin/ChatScreenMixin.java | 14 +- .../mixin/ClientPacketListenerMixin.java | 8 +- .../legacy/mixin/ContainerScreenMixin.java | 8 +- .../legacy/mixin/CraftingScreenMixin.java | 18 +-- .../legacy/mixin/CreateWorldScreenMixin.java | 12 +- .../mixin/CyclingSlotBackgroundMixin.java | 14 +- .../wily/legacy/mixin/DeathScreenMixin.java | 24 ++-- .../java/wily/legacy/mixin/EditBoxMixin.java | 10 +- .../EffectRenderingInventoryScreenMixin.java | 16 +-- .../legacy/mixin/EnchantmentScreenMixin.java | 54 +++---- .../wily/legacy/mixin/GameRendererMixin.java | 7 +- .../legacy/mixin/GrindstoneScreenMixin.java | 20 +-- .../wily/legacy/mixin/GuiGraphicsMixin.java | 9 +- .../main/java/wily/legacy/mixin/GuiMixin.java | 136 +++++++++--------- .../mixin/HorseInventoryScreenMixin.java | 6 +- .../legacy/mixin/InventoryScreenMixin.java | 10 +- .../mixin/LegacyLoadingScreenMixin.java | 6 +- .../legacy/mixin/LoadingOverlayMixin.java | 20 +-- .../wily/legacy/mixin/LoomScreenMixin.java | 71 +++++---- .../legacy/mixin/MerchantScreenMixin.java | 108 +++++++------- .../wily/legacy/mixin/MinecraftMixin.java | 10 +- .../mixin/PackSelectionScreenMixin.java | 50 +++---- .../wily/legacy/mixin/PauseScreenMixin.java | 8 +- .../mixin/RecipeBookComponentMixin.java | 6 +- .../wily/legacy/mixin/RecipeToastMixin.java | 24 ++-- .../java/wily/legacy/mixin/ScreenMixin.java | 22 +-- .../legacy/mixin/SmithingScreenMixin.java | 46 +++--- .../legacy/mixin/SplashRendererMixin.java | 4 +- .../legacy/mixin/StonecutterScreenMixin.java | 46 +++--- .../wily/legacy/mixin/TitleScreenMixin.java | 18 ++- .../legacy/mixin/ToastComponentMixin.java | 3 +- .../wily/legacy/mixin/TutorialToastMixin.java | 4 +- .../java/wily/legacy/util/ScreenUtil.java | 104 +++++++------- gradle.properties | 12 +- 100 files changed, 1398 insertions(+), 1408 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index b16e005b..abbfa128 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -10,7 +10,7 @@ dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modCompileOnly("maven.modrinth:world-host:0.4.13+1.20.4-fabric") + modCompileOnly("maven.modrinth:world-host:0.4.14+1.19.4-fabric") compileOnly(sdl_dependency) } diff --git a/common/src/main/java/wily/legacy/client/LegacyGuiGraphics.java b/common/src/main/java/wily/legacy/client/LegacyGuiGraphics.java index 42d5443b..6d5e42e3 100644 --- a/common/src/main/java/wily/legacy/client/LegacyGuiGraphics.java +++ b/common/src/main/java/wily/legacy/client/LegacyGuiGraphics.java @@ -1,8 +1,8 @@ package wily.legacy.client; import com.mojang.blaze3d.platform.NativeImage; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -18,11 +18,11 @@ public interface LegacyGuiGraphics { Map> spriteTilesCache = new ConcurrentHashMap<>(); - static LegacyGuiGraphics of(GuiGraphics guiGraphics) { - return (LegacyGuiGraphics) guiGraphics; + static LegacyGuiGraphics of(PoseStack poseStack) { + return (LegacyGuiGraphics) poseStack; } - GuiGraphics self(); + PoseStack self(); default void blitSprite(ResourceLocation resourceLocation, int i, int j, int k, int l) { this.blitSprite(resourceLocation, i, j, 0, k, l); } diff --git a/common/src/main/java/wily/legacy/client/LegacyTip.java b/common/src/main/java/wily/legacy/client/LegacyTip.java index 22b90e91..9f1bfa68 100644 --- a/common/src/main/java/wily/legacy/client/LegacyTip.java +++ b/common/src/main/java/wily/legacy/client/LegacyTip.java @@ -1,8 +1,8 @@ package wily.legacy.client; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastComponent; @@ -102,8 +102,8 @@ public int height() { } @Override - public Visibility render(GuiGraphics guiGraphics, ToastComponent toastComponent, long l) { - renderTip(guiGraphics,0,0,0,l); + public Visibility render(PoseStack poseStack, ToastComponent toastComponent, long l) { + renderTip(poseStack,0,0,0,l); return visibility; } @@ -113,18 +113,18 @@ public int slotCount() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - renderTip(guiGraphics, i, j, f,Util.getMillis() - createdTime); + public void render(PoseStack poseStack, int i, int j, float f) { + renderTip(poseStack, i, j, f,Util.getMillis() - createdTime); } - public void renderTip(GuiGraphics guiGraphics, int i, int j, float f, float l) { + public void renderTip(PoseStack poseStack, int i, int j, float f, float l) { if (canRemove.get() || l >= disappearTime) visibility = Visibility.HIDE; - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX(),getY(),800); - ScreenUtil.renderPointerPanel(guiGraphics,0,0,getWidth(),getHeight()); - if (!title.getString().isEmpty()) guiGraphics.drawString(minecraft.font,title,13,13,0xFFFFFF); - if (centered) tipLabel.renderCentered(guiGraphics,width / 2, title.getString().isEmpty() ? 13 : 25,12,0xFFFFFF); - else tipLabel.renderLeftAlignedNoShadow(guiGraphics,13,title.getString().isEmpty() ? 13 : 25, 12,0xFFFFFF); - if (holder != null) holder.render(guiGraphics,i,j,f); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(getX(),getY(),800); + ScreenUtil.renderPointerPanel(poseStack,0,0,getWidth(),getHeight()); + if (!title.getString().isEmpty()) poseStack.drawString(minecraft.font,title,13,13,0xFFFFFF); + if (centered) tipLabel.renderCentered(poseStack,width / 2, title.getString().isEmpty() ? 13 : 25,12,0xFFFFFF); + else tipLabel.renderLeftAlignedNoShadow(poseStack,13,title.getString().isEmpty() ? 13 : 25, 12,0xFFFFFF); + if (holder != null) holder.render(poseStack,i,j,f); + poseStack.pose().popPose(); } } diff --git a/common/src/main/java/wily/legacy/client/screen/BookPanel.java b/common/src/main/java/wily/legacy/client/screen/BookPanel.java index 67619166..1db27e87 100644 --- a/common/src/main/java/wily/legacy/client/screen/BookPanel.java +++ b/common/src/main/java/wily/legacy/client/screen/BookPanel.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; @@ -21,25 +21,25 @@ public BookPanel(Screen screen) { this.screen = screen; } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX(),getY(),0); - guiGraphics.pose().scale(getWidth() / 146f,getHeight() / 180f,1f); - guiGraphics.blit(BookViewScreen.BOOK_LOCATION,0,0,20,1,146,180); - guiGraphics.pose().popPose(); + public void render(PoseStack poseStack, int i, int j, float f) { + poseStack.pose().pushPose(); + poseStack.pose().translate(getX(),getY(),0); + poseStack.pose().scale(getWidth() / 146f,getHeight() / 180f,1f); + poseStack.blit(BookViewScreen.BOOK_LOCATION,0,0,20,1,146,180); + poseStack.pose().popPose(); } public PageButton createLegacyPageButton(int i, int j, boolean bl, Button.OnPress onPress, boolean bl2){ return new PageButton(i,j,bl,onPress,bl2){ private long lastPressTime; @Override - public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + public void renderWidget(PoseStack poseStack, int i, int j, float f) { isHovered = Util.getMillis() - lastPressTime <= 300 || clicked(i,j); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX(),getY(),1.5f); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - guiGraphics.pose().translate(-getX(),-getY(),1.5f); - super.renderWidget(guiGraphics, i, j, f); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(getX(),getY(),1.5f); + poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.pose().translate(-getX(),-getY(),1.5f); + super.renderWidget(poseStack, i, j, f); + poseStack.pose().popPose(); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/ConfirmationScreen.java b/common/src/main/java/wily/legacy/client/screen/ConfirmationScreen.java index bf19716a..da356107 100644 --- a/common/src/main/java/wily/legacy/client/screen/ConfirmationScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/ConfirmationScreen.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.screens.Screen; @@ -58,9 +58,9 @@ protected void initButtons(){ okButton = addRenderableWidget(Button.builder(Component.translatable("gui.ok"),b-> {if (okAction.test(b)) onClose();}).bounds(panel.x + (panel.width - 200) / 2, panel.y + panel.height - 30,200,20).build()); } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - ScreenUtil.renderScrollingString(guiGraphics,font,title,panel.x + 15, panel.y + 15,panel.x + panel.width - 15, panel.y + 26, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - messageLabel.renderLeftAlignedNoShadow(guiGraphics,panel.x + 15, panel.y + messageYOffset, 12, CommonColor.INVENTORY_GRAY_TEXT.get()); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + ScreenUtil.renderScrollingString(poseStack,font,title,panel.x + 15, panel.y + 15,panel.x + panel.width - 15, panel.y + 26, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + messageLabel.renderLeftAlignedNoShadow(poseStack,panel.x + 15, panel.y + messageYOffset, 12, CommonColor.INVENTORY_GRAY_TEXT.get()); } } diff --git a/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java b/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java index 4c657b5d..718bf205 100644 --- a/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java +++ b/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java @@ -6,6 +6,7 @@ import com.google.gson.JsonPrimitive; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import net.minecraft.ChatFormatting; import net.minecraft.Util; @@ -13,7 +14,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.Renderable; @@ -132,7 +132,7 @@ static ControlTooltip create(LegacyKeyMapping mapping,Supplier action } interface Icon { - int render(GuiGraphics graphics, int x, int y, boolean allowPressed, boolean simulate); + int render(PoseStack graphics, int x, int y, boolean allowPressed, boolean simulate); static Icon of(Component component){ return (graphics, x, y, allowPressed, simulate) -> { @@ -170,7 +170,7 @@ public Component getActualIcon(char[] chars, boolean allowPressed, ControlType t } @Override - public int render(GuiGraphics graphics, int x, int y, boolean allowPressed, boolean simulate){ + public int render(PoseStack graphics, int x, int y, boolean allowPressed, boolean simulate){ Component c = getComponent(allowPressed); Component co = getOverlayComponent(allowPressed); Font font = Minecraft.getInstance().font; @@ -281,26 +281,26 @@ public boolean allowPressed(){ return minecraft.screen != null; } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { + public void render(PoseStack poseStack, int i, int j, float f) { if (!ScreenUtil.getLegacyOptions().inGameTooltips().get() && minecraft.screen == null) return; int xDiff = 0; RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); - guiGraphics.setColor(1.0f,1.0f,1.0f,Math.max(minecraft.screen == null ? 0.0f : 0.2f, ScreenUtil.getHUDOpacity())); - guiGraphics.pose().pushPose(); + poseStack.setColor(1.0f,1.0f,1.0f,Math.max(minecraft.screen == null ? 0.0f : 0.2f, ScreenUtil.getHUDOpacity())); + poseStack.pose().pushPose(); double hudDiff = (1 - ScreenUtil.getLegacyOptions().hudDistance().get()) * 60D; - guiGraphics.pose().translate(-Math.min(hudDiff,30), Math.min(hudDiff,16),0); + poseStack.pose().translate(-Math.min(hudDiff,30), Math.min(hudDiff,16),0); for (ControlTooltip tooltip : tooltips) { Icon icon; Component action; int controlWidth; - if ((icon = tooltip.getIcon()) == null || (action = tooltip.getAction()) == null || (controlWidth = icon.render(guiGraphics,32 + xDiff, guiGraphics.guiHeight() - 29,allowPressed(),false)) <= 0) continue; - guiGraphics.drawString(minecraft.font,action,32 + xDiff + 2 + controlWidth, guiGraphics.guiHeight() - 29, CommonColor.WIDGET_TEXT.get()); + if ((icon = tooltip.getIcon()) == null || (action = tooltip.getAction()) == null || (controlWidth = icon.render(poseStack,32 + xDiff, poseStack.guiHeight() - 29,allowPressed(),false)) <= 0) continue; + poseStack.drawString(minecraft.font,action,32 + xDiff + 2 + controlWidth, poseStack.guiHeight() - 29, CommonColor.WIDGET_TEXT.get()); xDiff +=controlWidth + minecraft.font.width(action) + 12; RenderSystem.disableBlend(); } - guiGraphics.pose().popPose(); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + poseStack.pose().popPose(); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); RenderSystem.enableDepthTest(); } diff --git a/common/src/main/java/wily/legacy/client/screen/ControllerMappingScreen.java b/common/src/main/java/wily/legacy/client/screen/ControllerMappingScreen.java index b89ff6b7..bec5c4ba 100644 --- a/common/src/main/java/wily/legacy/client/screen/ControllerMappingScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/ControllerMappingScreen.java @@ -2,10 +2,10 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.KeyMapping; import net.minecraft.client.Options; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -56,17 +56,17 @@ public ControllerMappingScreen(Screen parent, Options options) { LegacyKeyMapping mapping = (LegacyKeyMapping) keyMapping; renderableVList.addRenderable(new AbstractButton(0,0,240,20,mapping.getDisplayName()) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { if (!isFocused() && isPressed()) selectedKey = null; - super.renderWidget(guiGraphics, i, j, f); + super.renderWidget(poseStack, i, j, f); Component c = isPressed() ? SELECTION : ((LegacyKeyMapping) keyMapping).getBinding() == null ? NONE : null; if (c != null){ - guiGraphics.drawString(font,c, getX() + width - 20 - font.width(c) / 2, getY() + (height - font.lineHeight) / 2 + 1,0xFFFFFF); + poseStack.drawString(font,c, getX() + width - 20 - font.width(c) / 2, getY() + (height - font.lineHeight) / 2 + 1,0xFFFFFF); return; } ControlTooltip.Icon icon = ((LegacyKeyMapping) keyMapping).getBinding().bindingState.getIcon(); RenderSystem.enableBlend(); - icon.render(guiGraphics, getX() + width - 20 - icon.render(guiGraphics,0,0,false,true) / 2, getY() + (height - font.lineHeight) / 2 + 1,false,false); + icon.render(poseStack, getX() + width - 20 - icon.render(poseStack,0,0,false,true) / 2, getY() + (height - font.lineHeight) / 2 + 1,false,false); RenderSystem.disableBlend(); } private boolean isPressed(){ @@ -81,8 +81,8 @@ public void onPress() { } else if (!ControlType.getActiveType().isKbm()) selectedKey = mapping; } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + 8, this.getY(), getX() + getWidth(), this.getY() + this.getHeight(), j,true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), this.getX() + 8, this.getY(), getX() + getWidth(), this.getY() + this.getHeight(), j,true); } @Override protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) { @@ -93,8 +93,8 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); } @Override @@ -114,7 +114,7 @@ protected void init() { panel.height = Math.min(height,293); panel.init(); addRenderableOnly(panel); - addRenderableOnly(((guiGraphics, i, j, f) -> guiGraphics.drawString(font,Legacy4JPlatform.getModInfo("minecraft").getVersion() + " " + Legacy4J.VERSION.get(),panel.getX() + panel.getWidth() + 81, panel.getY() + panel.getHeight() - 7,CommonColor.INVENTORY_GRAY_TEXT.get(),false))); + addRenderableOnly(((poseStack, i, j, f) -> poseStack.drawString(font,Legacy4JPlatform.getModInfo("minecraft").getVersion() + " " + Legacy4J.VERSION.get(),panel.getX() + panel.getWidth() + 81, panel.getY() + panel.getHeight() - 7,CommonColor.INVENTORY_GRAY_TEXT.get(),false))); getRenderableVList().init(this,panel.x + 7,panel.y + 6,panel.width - 14,panel.height); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/CreationList.java b/common/src/main/java/wily/legacy/client/screen/CreationList.java index ac9a8824..489ac27a 100644 --- a/common/src/main/java/wily/legacy/client/screen/CreationList.java +++ b/common/src/main/java/wily/legacy/client/screen/CreationList.java @@ -1,9 +1,9 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -59,20 +59,20 @@ public static void addIconButton(RenderableVList list, ResourceLocation iconSpri AbstractButton button; list.addRenderable(button = new AbstractButton(0,0,270,30,message) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(iconSprite, getX() + 5, getY() + 5, 20, 20); + LegacyGuiGraphics.of(poseStack).blitSprite(iconSprite, getX() + 5, getY() + 5, 20, 20); RenderSystem.disableBlend(); if (Minecraft.getInstance().options.touchscreen().get().booleanValue() || isHovered) { - guiGraphics.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); } } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { int k = this.getX() + 35; int l = this.getX() + this.getWidth(); - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), k, this.getY(), l, this.getY() + this.getHeight(), j, true); + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), k, this.getY(), l, this.getY() + this.getHeight(), j, true); } @Override public void onPress() { diff --git a/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java b/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java index c603d246..c2c03765 100644 --- a/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java @@ -2,8 +2,8 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.CreativeInventoryListener; import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; @@ -136,39 +136,39 @@ public void fillCreativeGrid(){ } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 296.5f, topPos + 27.5f, 0f); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 296.5f, topPos + 27.5f, 0f); Stocker.Sizeable scroll = tabsScrolledList.get(page.get() * 8 + tabList.selectedTab); if (scroll.max > 0) { if (scroll.get() != scroll.max) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.DOWN,0, 139); + scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN,0, 139); if (scroll.get() > 0) - scrollRenderer.renderScroll(guiGraphics,ScreenDirection.UP, 0, -11); - }else guiGraphics.setColor(1.0f,1.0f,1.0f,0.5f); + scrollRenderer.renderScroll(poseStack,ScreenDirection.UP, 0, -11); + }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, 0, 0,13,135); - guiGraphics.pose().translate(-2f, -1f + (scroll.max > 0 ? scroll.get() * 121.5f / scroll.max : 0), 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL,0,0, 16,16); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, 0, 0,13,135); + poseStack.pose().translate(-2f, -1f + (scroll.max > 0 ? scroll.get() * 121.5f / scroll.max : 0), 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); - this.renderTooltip(guiGraphics, i, j); + poseStack.pose().popPose(); + this.renderTooltip(poseStack, i, j); } @Override - protected void renderLabels(GuiGraphics guiGraphics, int i, int j) { + protected void renderLabels(PoseStack poseStack, int i, int j) { Component tabTitle = tabList.tabButtons.get(tabList.selectedTab).getMessage(); - guiGraphics.drawString(this.font, tabTitle, (imageWidth - font.width(tabTitle)) / 2, 12, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, tabTitle, (imageWidth - font.width(tabTitle)) / 2, 12, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } @Override - protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { + protected void renderBg(PoseStack poseStack, float f, int i, int j) { } diff --git a/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java b/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java index 8c3d40b7..e1f88b81 100644 --- a/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java +++ b/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -125,7 +125,7 @@ public boolean mouseScrolled(double d, double e, double f, double g) { return false; } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (itemIcon.isEmpty() || isFocused()) { nextItem = nextItem(); previousItem = previousItem(); @@ -143,7 +143,7 @@ protected boolean hasItem(ItemStack stack) { return !stack.isEmpty() && minecraft.player.getInventory().items.stream().filter(s-> ItemStack.isSameItemSameTags(s,stack)).mapToInt(ItemStack::getCount).sum() >= stack.getCount(); } @Override - public void renderItem(GuiGraphics graphics, int i, int j, float f) { + public void renderItem(PoseStack graphics, int i, int j, float f) { ScreenUtil.secureTranslucentRender(graphics,!itemIcon.isEmpty() && !hasItem(itemIcon),0.5f,(u)-> renderItem(graphics,itemIcon,getX(),getY(),false)); } public boolean canAddIngredient(){ @@ -171,7 +171,7 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void renderSelection(GuiGraphics graphics, int i, int j, float f) { + public void renderSelection(PoseStack graphics, int i, int j, float f) { super.renderSelection(graphics, i, j, f); if (!itemIcon.isEmpty() && hasItem(itemIcon) && minecraft.screen instanceof LegacyMenuAccess a){ Slot s = a.getMenu().getSlot(findInventoryMatchSlot()); diff --git a/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java b/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java index c8f201d2..49a7852b 100644 --- a/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java +++ b/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.recipebook.GhostRecipe; import net.minecraft.client.renderer.RenderType; @@ -25,25 +25,25 @@ public void addIngredient(Ingredient ingredient, Slot slot) { addIngredient(ingredient, slot.x, slot.y); ingredientSlots.add(slot); } - public void render(GuiGraphics guiGraphics, Minecraft minecraft, int leftPos, int topPos, boolean bigResultSlot, float f) { + public void render(PoseStack poseStack, Minecraft minecraft, int leftPos, int topPos, boolean bigResultSlot, float f) { if (!Screen.hasControlDown()) { this.time += f; } for (int k = 0; k < this.ingredients.size(); ++k) { GhostIngredient ghostIngredient = this.ingredients.get(k); LegacyIconHolder holder = ScreenUtil.iconHolderRenderer.slotBounds(ingredientSlots.get(k)); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(ghostIngredient.getX() + leftPos, ghostIngredient.getY() + topPos, 0); - holder.applyOffset(guiGraphics); - guiGraphics.pose().scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); + poseStack.pose().pushPose(); + poseStack.pose().translate(ghostIngredient.getX() + leftPos, ghostIngredient.getY() + topPos, 0); + holder.applyOffset(poseStack); + poseStack.pose().scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); - guiGraphics.fill(0, 0, 16, 16, 0x30FF0000); + poseStack.fill(0, 0, 16, 16, 0x30FF0000); ItemStack itemStack = ghostIngredient.getItem(); - guiGraphics.renderFakeItem(itemStack, 0, 0); - guiGraphics.fill(RenderType.guiGhostRecipeOverlay(), 0, 0, 16,16, 0x30FFFFFF); + poseStack.renderFakeItem(itemStack, 0, 0); + poseStack.fill(RenderType.guiGhostRecipeOverlay(), 0, 0, 16,16, 0x30FFFFFF); if (k == 0) - guiGraphics.renderItemDecorations(minecraft.font, itemStack, 0, 0); - guiGraphics.pose().popPose(); + poseStack.renderItemDecorations(minecraft.font, itemStack, 0, 0); + poseStack.pose().popPose(); } } } diff --git a/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java b/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java index 78a153d4..0bc4be20 100644 --- a/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java +++ b/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.navigation.ScreenRectangle; @@ -155,55 +155,55 @@ public void setHoveredSlot(Slot hoveredSlot) { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); setHoveredSlot(null); menu.slots.forEach(s-> { LegacyIconHolder holder = ScreenUtil.iconHolderRenderer.slotBounds(panel.x, panel.y, s); if (!s.getItem().isEmpty()) holder.itemIcon = s.getItem(); - holder.render(guiGraphics,i,j,f); + holder.render(poseStack,i,j,f); if (holder.isHovered) { - if (s.isHighlightable()) holder.renderHighlight(guiGraphics); + if (s.isHighlightable()) holder.renderHighlight(poseStack); setHoveredSlot(s); } }); if (hoveredSlot != null && !hoveredSlot.getItem().isEmpty()) - guiGraphics.renderTooltip(font, hoveredSlot.getItem(), i, j); + poseStack.renderTooltip(font, hoveredSlot.getItem(), i, j); } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); - panel.render(guiGraphics, i, j, f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 20, panel. y + 187, 275, 27); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); + panel.render(poseStack, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 20, panel. y + 187, 275, 27); - guiGraphics.drawString(this.font, this.title,panel.x + (panel.width - font.width(title)) / 2,panel. y + 8, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.title,panel.x + (panel.width - font.width(title)) / 2,panel. y + 8, CommonColor.INVENTORY_GRAY_TEXT.get(), false); Component layerCount = Component.translatable("legacy.menu.create_flat_world.layer_count", selectedLayer.count); - guiGraphics.drawString(this.font, layerCount,panel.x + 49 - font.width(layerCount),panel. y + 197, 0xFFFFFF, true); - guiGraphics.drawString(this.font, selectedLayer.getItem().getDescription(),panel.x + 70,panel. y + 197, 0xFFFFFF, true); + poseStack.drawString(this.font, layerCount,panel.x + 49 - font.width(layerCount),panel. y + 197, 0xFFFFFF, true); + poseStack.drawString(this.font, selectedLayer.getItem().getDescription(),panel.x + 70,panel. y + 197, 0xFFFFFF, true); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + 50, panel.y + 190,0); - guiGraphics.pose().scale(1.25f,1.25f,1.25f); - guiGraphics.renderItem(selectedLayer,0, 0); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + 50, panel.y + 190,0); + poseStack.pose().scale(1.25f,1.25f,1.25f); + poseStack.renderItem(selectedLayer,0, 0); + poseStack.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + 299.5, panel.y + 23, 0f); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + 299.5, panel.y + 23, 0f); if (scrolledList.max > 0) { if (scrolledList.get() != scrolledList.max) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.DOWN, 0, 139); + scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN, 0, 139); if (scrolledList.get() > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.UP,0,-11); - }else guiGraphics.setColor(1.0f,1.0f,1.0f,0.5f); + scrollRenderer.renderScroll(poseStack, ScreenDirection.UP,0,-11); + }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,135); - guiGraphics.pose().translate(-2f, -1f + (scrolledList.max > 0 ? scrolledList.get() * 121.5f / scrolledList.max : 0), 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL,0,0, 16,16); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,135); + poseStack.pose().translate(-2f, -1f + (scrolledList.max > 0 ? scrolledList.get() * 121.5f / scrolledList.max : 0), 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/HostOptionsScreen.java b/common/src/main/java/wily/legacy/client/screen/HostOptionsScreen.java index 6992fb54..6fb72f1c 100644 --- a/common/src/main/java/wily/legacy/client/screen/HostOptionsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/HostOptionsScreen.java @@ -3,9 +3,9 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; @@ -84,11 +84,11 @@ public boolean keyPressed(int i, int j, int k) { return super.keyPressed(i, j, k); } - public static void drawPlayerIcon(GameProfile profile, GuiGraphics guiGraphics, int x, int y){ + public static void drawPlayerIcon(GameProfile profile, PoseStack poseStack, int x, int y){ float[] color = Legacy4JClient.getVisualPlayerColor(((LegacyPlayerInfo)Minecraft.getInstance().getConnection().getPlayerInfo(profile.getId()))); - guiGraphics.setColor(color[0],color[1],color[2],1.0f); + poseStack.setColor(color[0],color[1],color[2],1.0f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.MAP_PLAYER,x,y, 20,20); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.MAP_PLAYER,x,y, 20,20); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1.0f,1.0f,1.0f,1.0f); } @@ -116,10 +116,10 @@ public boolean isPauseScreen() { return false; } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - panel.render(guiGraphics,i,j,f); - drawPlayerIcon(profile,guiGraphics, panel.x + 7,panel.y + 5); - guiGraphics.drawString(font,profile.getName(),panel.x + 31, panel.y + 12, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + panel.render(poseStack,i,j,f); + drawPlayerIcon(profile,poseStack, panel.x + 7,panel.y + 5); + poseStack.drawString(font,profile.getName(),panel.x + 31, panel.y + 12, CommonColor.INVENTORY_GRAY_TEXT.get(),false); } }; List gameTypes = Arrays.stream(GameType.values()).toList(); @@ -151,14 +151,14 @@ protected void addPlayerButtons(boolean includeClient, BiConsumer label.renderLeftAligned(guiGraphics, panel.x + panel.width + 3, panel.y + 13, 12, 0xFFFFFF)); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + super.renderDefaultBackground(poseStack, i, j, f); + tooltipBox.render(poseStack,i,j,f); + scrollableRenderer.render(poseStack,panel.x + panel.width + 3, panel.y + 13,tooltipBox.width - 10, tooltipBox.getHeight() - 44, ()-> label.renderLeftAligned(poseStack, panel.x + panel.width + 3, panel.y + 13, 12, 0xFFFFFF)); } } diff --git a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java index 3fea64be..466a09ab 100644 --- a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java @@ -2,17 +2,17 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.Screen; @@ -153,9 +153,9 @@ protected void init() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - if (getFocused() instanceof CharButton c) c.renderTooltip(guiGraphics, i, j, f); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + if (getFocused() instanceof CharButton c) c.renderTooltip(poseStack, i, j, f); } @Override @@ -176,25 +176,25 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderDefaultBackground(guiGraphics, i, j, f); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + super.renderDefaultBackground(poseStack, i, j, f); RenderSystem.enableBlend(); - guiGraphics.setColor(1f,1f,1f,0.8f); - panel.render(guiGraphics,i,j,f); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.getX() + 4.5f,panel.getY() + 25.5,0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0,0,53, 123); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,panel.getWidth() - 62,0,53, 123); - guiGraphics.pose().translate(-4.5f,0,0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,(panel.getWidth() - 267) / 2,-1,267, 125); - guiGraphics.pose().popPose(); + poseStack.setColor(1f,1f,1f,0.8f); + panel.render(poseStack,i,j,f); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.getX() + 4.5f,panel.getY() + 25.5,0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0,0,53, 123); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,panel.getWidth() - 62,0,53, 123); + poseStack.pose().translate(-4.5f,0,0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,(panel.getWidth() - 267) / 2,-1,267, 125); + poseStack.pose().popPose(); RenderSystem.disableBlend(); - guiGraphics.setColor(1f,1f,1f,1f); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.getX() + (panel.getWidth() - font.width(KEYBOARD) * 1.5f) / 2,panel.getY() + 8,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - guiGraphics.drawString(font,KEYBOARD,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.pose().popPose(); + poseStack.setColor(1f,1f,1f,1f); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.getX() + (panel.getWidth() - font.width(KEYBOARD) * 1.5f) / 2,panel.getY() + 8,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.drawString(font,KEYBOARD,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.pose().popPose(); } public record CharButtonBuilder(int width, String chars, String shiftChars, ControllerBinding binding, ResourceLocation iconSprite, SoundEvent downSound){ @@ -221,7 +221,7 @@ public boolean matches(char c){ return chars.contains(String.valueOf(c)) || (shiftChars != null && shiftChars.contains(String.valueOf(c))); } - public void renderTooltip(GuiGraphics guiGraphics, int i, int j, float f){ + public void renderTooltip(PoseStack poseStack, int i, int j, float f){ if (pressTime >= 6 && getSelectedChars().length() > 1){ int width = 18; char[] chars = getSelectedChars().toCharArray(); @@ -230,14 +230,14 @@ public void renderTooltip(GuiGraphics guiGraphics, int i, int j, float f){ width += font.width(s) + (i1 == 0 ? 0 : 2); } int diffX = 0; - ScreenUtil.renderPointerPanel(guiGraphics, getX() + (getWidth() - width) / 2, getY() - 17,width,15); + ScreenUtil.renderPointerPanel(poseStack, getX() + (getWidth() - width) / 2, getY() - 17,width,15); for (char c : chars) { String s = String.valueOf(c); - guiGraphics.drawString(font,s,getX() + (getWidth() - width) / 2 + diffX + 9, getY() - 14,c == getSelectedChar() ? 0xFFFF00 : 0xFFFFFF); + poseStack.drawString(font,s,getX() + (getWidth() - width) / 2 + diffX + 9, getY() - 14,c == getSelectedChar() ? 0xFFFF00 : 0xFFFFFF); diffX += font.width(s) + 2; } - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.LEFT,getX() + (getWidth() - width) / 2 + 2, getY() - 15); - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT,getX() + (getWidth() - width) / 2 + width -9, getY() - 15); + scrollRenderer.renderScroll(poseStack, ScreenDirection.LEFT,getX() + (getWidth() - width) / 2 + 2, getY() - 15); + scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT,getX() + (getWidth() - width) / 2 + width -9, getY() - 15); } } @@ -305,10 +305,10 @@ public KeyButton(int key, int height, Supplier keyListener, Co } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(getSprite(),getX(),getY(),getWidth(),getHeight()); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + LegacyGuiGraphics.of(poseStack).blitSprite(getSprite(),getX(),getY(),getWidth(),getHeight()); RenderSystem.enableBlend(); - renderString(guiGraphics,Minecraft.getInstance().font, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); + renderString(poseStack,Minecraft.getInstance().font, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); RenderSystem.disableBlend(); } public ResourceLocation getSprite(){ @@ -376,18 +376,18 @@ public boolean keyReleased(int i, int j, int k) { } } - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { int bindingOffset = 0; - if (binding != null && Legacy4JClient.controllerManager.connectedController != null) bindingOffset = binding.bindingState.getIcon().render(guiGraphics,getX() + i, getY() + (getHeight() - 9) / 2 + 1,true,false); + if (binding != null && Legacy4JClient.controllerManager.connectedController != null) bindingOffset = binding.bindingState.getIcon().render(poseStack,getX() + i, getY() + (getHeight() - 9) / 2 + 1,true,false); - if (iconSprite == null) renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + i + bindingOffset, this.getY(), this.getX() + this.getWidth() - i, this.getY() + this.getHeight(), j); + if (iconSprite == null) renderScrollingString(poseStack, font, this.getMessage(), this.getX() + i + bindingOffset, this.getY(), this.getX() + this.getWidth() - i, this.getY() + this.getHeight(), j); else { TextureAtlasSprite sprite = Legacy4JClient.sprites.textureAtlas.texturesByName.getOrDefault(iconSprite,null); if (sprite == null) return; try (SpriteContents contents = sprite.contents()){ RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(iconSprite, getX() + (getWidth() - contents.width()) / 2 + Math.max(0,i + bindingOffset - (getWidth() - contents.width()) / 2), getY() + (getHeight() - contents.height()) / 2,contents.width(),contents.height()); + LegacyGuiGraphics.of(poseStack).blitSprite(iconSprite, getX() + (getWidth() - contents.width()) / 2 + Math.max(0,i + bindingOffset - (getWidth() - contents.width()) / 2), getY() + (getHeight() - contents.height()) / 2,contents.width(),contents.height()); RenderSystem.disableBlend(); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java b/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java index 8483c4e8..adc3635e 100644 --- a/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java @@ -6,9 +6,9 @@ import com.google.gson.JsonPrimitive; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -66,8 +66,8 @@ public LeaderboardsScreen(Screen parent) { rebuildRenderableVList(Minecraft.getInstance()); } - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderTransparentBackground(guiGraphics); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderTransparentBackground(poseStack); } @Override @@ -147,12 +147,12 @@ public void rebuildRenderableVList(Minecraft minecraft){ String rank =i + 1 + ""; renderableVList.renderables.add(new AbstractWidget(0,0,551,20,Component.literal(info.legacyMinecraft$getProfile().getName())) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { int y = getY() + (getHeight() - font.lineHeight) / 2 + 1; - LegacyGuiGraphics.of(guiGraphics).blitSprite(isHoveredOrFocused() ? LegacySprites.LEADERBOARD_BUTTON_HIGHLIGHTED : LegacySprites.LEADERBOARD_BUTTON,getX(),getY(),getWidth(),getHeight()); - guiGraphics.drawString(font,rank,getX() + 40 - font.width(rank) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); - guiGraphics.drawString(font,getMessage(),getX() + 120 -(font.width(getMessage())) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); - guiGraphics.drawString(font,getMessage(),getX() + 120 -(font.width(getMessage())) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); + LegacyGuiGraphics.of(poseStack).blitSprite(isHoveredOrFocused() ? LegacySprites.LEADERBOARD_BUTTON_HIGHLIGHTED : LegacySprites.LEADERBOARD_BUTTON,getX(),getY(),getWidth(),getHeight()); + poseStack.drawString(font,rank,getX() + 40 - font.width(rank) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); + poseStack.drawString(font,getMessage(),getX() + 120 -(font.width(getMessage())) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); + poseStack.drawString(font,getMessage(),getX() + 120 -(font.width(getMessage())) / 2, y, ScreenUtil.getDefaultTextColor(!isHoveredOrFocused())); int added = 0; Component hoveredValue = null; for (int index = page; index < statsBoards.get(selectedStatBoard).statsList.size(); index++) { @@ -161,11 +161,11 @@ protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { Component value = ControlTooltip.CONTROL_ICON_FUNCTION.apply(stat.format((Legacy4JClient.isModEnabledOnServer() ? info.getStatsMap() : minecraft.player.getStats().stats).getInt(stat)),Style.EMPTY); SimpleLayoutRenderable renderable = statsBoards.get(selectedStatBoard).renderables.get(index); int w = font.width(value); - ScreenUtil.renderScrollingString(guiGraphics,font, value,renderable.getX() + Math.max(0,renderable.getWidth() - w) / 2, getY(),renderable.getX() + Math.min(renderable.getWidth(),(renderable.getWidth() - w)/ 2 + getWidth()), getY() + getHeight(), ScreenUtil.getDefaultTextColor(!isHoveredOrFocused()),true); + ScreenUtil.renderScrollingString(poseStack,font, value,renderable.getX() + Math.max(0,renderable.getWidth() - w) / 2, getY(),renderable.getX() + Math.min(renderable.getWidth(),(renderable.getWidth() - w)/ 2 + getWidth()), getY() + getHeight(), ScreenUtil.getDefaultTextColor(!isHoveredOrFocused()),true); if (ScreenUtil.isMouseOver(i,j,renderable.getX() + Math.max(0,renderable.getWidth() - w) / 2, getY(),Math.min(renderable.getWidth(),w), getHeight())) hoveredValue = value; added++; } - if (hoveredValue != null) guiGraphics.renderTooltip(font,hoveredValue,i,j); + if (hoveredValue != null) poseStack.renderTooltip(font,hoveredValue,i,j); } @Override @@ -180,50 +180,50 @@ protected void init() { super.init(); if (Legacy4JClient.isModEnabledOnServer()) CommonNetwork.sendToServer(new PlayerInfoSync(0,minecraft.player)); else minecraft.getConnection().send(new ServerboundClientCommandPacket(ServerboundClientCommandPacket.Action.REQUEST_STATS)); - addRenderableOnly((guiGraphics, i, j, f) -> { - ScreenUtil.renderPointerPanel(guiGraphics,panel.x + 8,panel.y - 18,166,18); - ScreenUtil.renderPointerPanel(guiGraphics,panel.x + (panel.width - 211) / 2,panel.y - 18,211,18); - ScreenUtil.renderPointerPanel(guiGraphics,panel.x + panel.width - 174 ,panel.y - 18,166,18); + addRenderableOnly((poseStack, i, j, f) -> { + ScreenUtil.renderPointerPanel(poseStack,panel.x + 8,panel.y - 18,166,18); + ScreenUtil.renderPointerPanel(poseStack,panel.x + (panel.width - 211) / 2,panel.y - 18,211,18); + ScreenUtil.renderPointerPanel(poseStack,panel.x + panel.width - 174 ,panel.y - 18,166,18); if (!statsBoards.isEmpty() && selectedStatBoard < statsBoards.size()){ StatsBoard board = statsBoards.get(selectedStatBoard); - guiGraphics.pose().pushPose(); + poseStack.pose().pushPose(); Component filter = Component.translatable("legacy.menu.leaderboard.filter", myScore ? MY_SCORE : LegacyKeyBindsScreen.NONE); - guiGraphics.pose().translate(panel.x + 91 - font.width(filter) / 4f, panel.y - 12,0); - guiGraphics.pose().scale(2/3f,2/3f,2/3f); - guiGraphics.drawString(font,filter,0, 0,0xFFFFFF); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + (panel.width - font.width(board.displayName) / 2f) / 2, panel.y - 12,0); - guiGraphics.pose().scale(2/3f,2/3f,2/3f); - guiGraphics.drawString(font,board.displayName,0, 0,0xFFFFFF); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); + poseStack.pose().translate(panel.x + 91 - font.width(filter) / 4f, panel.y - 12,0); + poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.drawString(font,filter,0, 0,0xFFFFFF); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + (panel.width - font.width(board.displayName) / 2f) / 2, panel.y - 12,0); + poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.drawString(font,board.displayName,0, 0,0xFFFFFF); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); Component entries = Component.translatable("legacy.menu.leaderboard.entries",actualRankBoard.size()); - guiGraphics.pose().translate(panel.x + 477 - font.width(entries) / 4f, panel.y - 12,0); - guiGraphics.pose().scale(2/3f,2/3f,2/3f); - guiGraphics.drawString(font,entries,0, 0,0xFFFFFF); - guiGraphics.pose().popPose(); + poseStack.pose().translate(panel.x + 477 - font.width(entries) / 4f, panel.y - 12,0); + poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.drawString(font,entries,0, 0,0xFFFFFF); + poseStack.pose().popPose(); RenderSystem.enableBlend(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + (panel.width - 211) / 2f, panel.y - 12,0); - guiGraphics.pose().scale(0.5f,0.5f,0.5f); - (ControlType.getActiveType().isKbm() ? ControlTooltip.COMPOUND_ICON_FUNCTION.apply(new ControlTooltip.Icon[]{ControlTooltip.getKeyIcon(InputConstants.KEY_LEFT),ControlTooltip.SPACE_ICON, ControlTooltip.getKeyIcon(InputConstants.KEY_RIGHT)}) : ControllerBinding.LEFT_STICK.bindingState.getIcon()).render(guiGraphics,4,0,false, false); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + (panel.width - 211) / 2f, panel.y - 12,0); + poseStack.pose().scale(0.5f,0.5f,0.5f); + (ControlType.getActiveType().isKbm() ? ControlTooltip.COMPOUND_ICON_FUNCTION.apply(new ControlTooltip.Icon[]{ControlTooltip.getKeyIcon(InputConstants.KEY_LEFT),ControlTooltip.SPACE_ICON, ControlTooltip.getKeyIcon(InputConstants.KEY_RIGHT)}) : ControllerBinding.LEFT_STICK.bindingState.getIcon()).render(poseStack,4,0,false, false); if (statsInScreen < statsBoards.get(selectedStatBoard).renderables.size()) { ControlTooltip.Icon pageControl = ControlTooltip.COMPOUND_ICON_FUNCTION.apply(new ControlTooltip.Icon[]{ControlType.getActiveType().isKbm() ? ControlTooltip.getKeyIcon(InputConstants.KEY_LBRACKET) : ControllerBinding.LEFT_BUMPER.bindingState.getIcon(), ControlTooltip.SPACE_ICON, ControlType.getActiveType().isKbm() ? ControlTooltip.getKeyIcon(InputConstants.KEY_RBRACKET) : ControllerBinding.RIGHT_BUMPER.bindingState.getIcon()}); - pageControl.render(guiGraphics,422 - pageControl.render(guiGraphics,0,0,false,true) - 8, 0,false,false); + pageControl.render(poseStack,422 - pageControl.render(poseStack,0,0,false,true) - 8, 0,false,false); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); RenderSystem.disableBlend(); if (board.statsList.isEmpty()) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + (panel.width - font.width(NO_RESULTS) * 1.5f)/2f, panel.y + (panel.height - 13.5f) / 2f,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - guiGraphics.drawString(font,NO_RESULTS,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + (panel.width - font.width(NO_RESULTS) * 1.5f)/2f, panel.y + (panel.height - 13.5f) / 2f,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.drawString(font,NO_RESULTS,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.pose().popPose(); return; } - guiGraphics.drawString(font,RANK,panel.x + 40, panel.y + 20,CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.drawString(font,USERNAME,panel.x + 108, panel.y + 20,CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.drawString(font,RANK,panel.x + 40, panel.y + 20,CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.drawString(font,USERNAME,panel.x + 108, panel.y + 20,CommonColor.INVENTORY_GRAY_TEXT.get(),false); int totalWidth = 0; statsInScreen = 0; for (int index = page; index < board.renderables.size(); index++) { @@ -238,11 +238,11 @@ protected void init() { for (int index = page; index < page + statsInScreen; index++) { SimpleLayoutRenderable r = board.renderables.get(index); r.setPosition(panel.x + 182 + x,panel.y + 22 - r.height / 2); - r.render(guiGraphics,i,j,f); + r.render(poseStack,i,j,f); if (r.isHovered(i,j)) hovered = index; x+= r.getWidth() + (351 - totalWidth) / statsInScreen; } - if (hovered != null) guiGraphics.renderTooltip(font, board.statsList.get(hovered).getValue() instanceof EntityType e ? e.getDescription() : board.statsList.get(hovered).getValue() instanceof ItemLike item && item.asItem() != Items.AIR ? item.asItem().getDescription() : ControlTooltip.getAction("stat." + board.statsList.get(hovered).getValue().toString().replace(':', '.')), i, j); + if (hovered != null) poseStack.renderTooltip(font, board.statsList.get(hovered).getValue() instanceof EntityType e ? e.getDescription() : board.statsList.get(hovered).getValue() instanceof ItemLike item && item.asItem() != Items.AIR ? item.asItem().getDescription() : ControlTooltip.getAction("stat." + board.statsList.get(hovered).getValue().toString().replace(':', '.')), i, j); } }); renderableVList.init(this,panel.x + 9,panel.y + 39,551,226); @@ -282,12 +282,12 @@ public SimpleLayoutRenderable getRenderable(Stat stat){ return LegacyIconHolder.entityHolder(0,0,24,24, e); } Component name = Component.translatable("stat." + stat.getValue().toString().replace(':', '.')); - return SimpleLayoutRenderable.create(Minecraft.getInstance().font.width(name) * 2/3 + 2,7, (l)->((guiGraphics, i, j, f) -> { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(l.getX() + 1,l.getY(),0); - guiGraphics.pose().scale(2/3f,2/3f,2/3f); - guiGraphics.drawString(Minecraft.getInstance().font,name,0,0,CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.pose().popPose(); + return SimpleLayoutRenderable.create(Minecraft.getInstance().font.width(name) * 2/3 + 2,7, (l)->((poseStack, i, j, f) -> { + poseStack.pose().pushPose(); + poseStack.pose().translate(l.getX() + 1,l.getY(),0); + poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.drawString(Minecraft.getInstance().font,name,0,0,CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.pose().popPose(); })); } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java index d342b904..ae82e683 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java @@ -2,8 +2,8 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.advancements.*; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -61,8 +61,8 @@ public LegacyAdvancementsScreen(Screen parent, ClientAdvancements advancements) } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderTransparentBackground(guiGraphics); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderTransparentBackground(poseStack); } public static int getRootDistance(Advancement advancement) { @@ -86,29 +86,29 @@ protected void addAdvancementButton(Advancement root, Advancement node){ renderableVLists.get(root).addRenderable(w = new AbstractWidget(0, 0, 38, 38, info.getTitle()) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { if (isFocused()) { selectedAdvancement = node; - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(-1.5f, -1.5f, 0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_HIGHLIGHT, getX(), getY(), 41, 41); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(-1.5f, -1.5f, 0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_HIGHLIGHT, getX(), getY(), 41, 41); + poseStack.pose().popPose(); } RenderSystem.enableBlend(); - if (!unlocked) guiGraphics.setColor(1.0f, 1.0f, 1.0f, 0.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL, getX(), getY(), getWidth(), getHeight()); + if (!unlocked) poseStack.setColor(1.0f, 1.0f, 1.0f, 0.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL, getX(), getY(), getWidth(), getHeight()); RenderSystem.disableDepthTest(); if (!unlocked) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PADLOCK, getX() + (getWidth() - 32) / 2, getY() + (getHeight() - 32) / 2, 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PADLOCK, getX() + (getWidth() - 32) / 2, getY() + (getHeight() - 32) / 2, 32, 32); RenderSystem.enableDepthTest(); RenderSystem.disableBlend(); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, 1.0f); + poseStack.setColor(1.0f, 1.0f, 1.0f, 1.0f); if (!unlocked) return; - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX() + (getWidth() - 32) / 2f, getY() + (getHeight() - 32) / 2f, 0); - guiGraphics.pose().scale(2f, 2f, 2f); - guiGraphics.renderFakeItem(info.getIcon(), 0, 0); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(getX() + (getWidth() - 32) / 2f, getY() + (getHeight() - 32) / 2f, 0); + poseStack.pose().scale(2f, 2f, 2f); + poseStack.renderFakeItem(info.getIcon(), 0, 0); + poseStack.pose().popPose(); } @@ -132,13 +132,13 @@ protected void init() { addRenderableWidget(tabList); super.init(); panel.y +=18; - addRenderableOnly(((guiGraphics, i, j, f) ->{ - guiGraphics.drawString(font,showDescription ? tabList.tabButtons.get(tabList.selectedTab).getMessage() : getTitle(),panel.x + (panel.width - font.width(showDescription ? tabList.tabButtons.get(tabList.selectedTab).getMessage() : getTitle()))/ 2,panel.y + 10, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - if (selectedRoot != null) Optional.ofNullable(selectedRoot.getDisplay()).map(DisplayInfo::getBackground).ifPresent(b -> guiGraphics.blit(b,panel.x + 14, panel.y + 24,0,0,422,23,16,16)); - ScreenUtil.renderPanelTranslucentRecess(guiGraphics,panel.x + 12, panel.y + 22, 426, 27); - if (selectedAdvancement != null) Optional.ofNullable(selectedAdvancement.getDisplay()).ifPresent(info-> guiGraphics.drawString(font,info.getTitle(),panel.x + (panel.width - font.width(info.getTitle()))/ 2,panel.y + 32,0xFFFFFF)); + addRenderableOnly(((poseStack, i, j, f) ->{ + poseStack.drawString(font,showDescription ? tabList.tabButtons.get(tabList.selectedTab).getMessage() : getTitle(),panel.x + (panel.width - font.width(showDescription ? tabList.tabButtons.get(tabList.selectedTab).getMessage() : getTitle()))/ 2,panel.y + 10, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + if (selectedRoot != null) Optional.ofNullable(selectedRoot.getDisplay()).map(DisplayInfo::getBackground).ifPresent(b -> poseStack.blit(b,panel.x + 14, panel.y + 24,0,0,422,23,16,16)); + ScreenUtil.renderPanelTranslucentRecess(poseStack,panel.x + 12, panel.y + 22, 426, 27); + if (selectedAdvancement != null) Optional.ofNullable(selectedAdvancement.getDisplay()).ifPresent(info-> poseStack.drawString(font,info.getTitle(),panel.x + (panel.width - font.width(info.getTitle()))/ 2,panel.y + 32,0xFFFFFF)); RenderSystem.disableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 12, panel.y + 50, 426, 186); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 12, panel.y + 50, 426, 186); })); tabList.init(panel.x,panel.y - 37,panel.width,(b,i)->{ int index = tabList.tabButtons.indexOf(b); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java index c57e4555..fa5412a1 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java @@ -1,11 +1,11 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -41,26 +41,26 @@ public void onPress() { } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); ItemStack s = LegacyBiomeOverride.getOrDefault(biome.unwrapKey()).icon(); if (!s.isEmpty()){ - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX() + 26, getY() + 5,0); - guiGraphics.pose().scale(1.25f,1.25f,1.25f); - guiGraphics.renderItem(s,0, 0); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(getX() + 26, getY() + 5,0); + poseStack.pose().scale(1.25f,1.25f,1.25f); + poseStack.renderItem(s,0, 0); + poseStack.pose().popPose(); } RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(TickBox.SPRITES[isHoveredOrFocused() ? 1 : 0], this.getX() + 6, this.getY() + (height - 12) / 2, 12, 12); - if (selectedBiome == biome) LegacyGuiGraphics.of(guiGraphics).blitSprite(TickBox.TICK, this.getX() + 6, this.getY() + (height - 12) / 2, 14, 12); + LegacyGuiGraphics.of(poseStack).blitSprite(TickBox.SPRITES[isHoveredOrFocused() ? 1 : 0], this.getX() + 6, this.getY() + (height - 12) / 2, 12, 12); + if (selectedBiome == biome) LegacyGuiGraphics.of(poseStack).blitSprite(TickBox.TICK, this.getX() + 6, this.getY() + (height - 12) / 2, 14, 12); RenderSystem.disableBlend(); } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { int k = this.getX() + 54; int l = this.getX() + this.getWidth(); - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), k, this.getY(), l, this.getY() + this.getHeight(), j,true); + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), k, this.getY(), l, this.getY() + this.getHeight(), j,true); } @Override protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) { @@ -69,15 +69,15 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp }); } - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); } @Override protected void init() { panel.height = Math.min(height,248); addRenderableOnly(panel); panel.init(); - addRenderableOnly(((guiGraphics, i, j, f) -> LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); + addRenderableOnly(((poseStack, i, j, f) -> LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); getRenderableVList().init(this,panel.x + 11,panel.y + 11,260, panel.height - 5); } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java index 758e83c7..11855a24 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -274,12 +274,6 @@ public LegacyCraftingScreen(LegacyCraftingMenu abstractContainerMenu, Inventory canCraft(ingredientsGrid,true); }).enableAddIngredients(h->h.addedIngredientsItems.size() < 4)); } - public static ItemStack createDecoratedPotItem(DecoratedPotBlockEntity.Decorations decorations) { - ItemStack itemStack = Items.DECORATED_POT.getDefaultInstance(); - CompoundTag compoundTag = decorations.save(new CompoundTag()); - BlockItem.setBlockEntityData(itemStack, BlockEntityType.DECORATED_POT, compoundTag); - return itemStack; - } @Override public void addControlTooltips(Renderer renderer) { Event.super.addControlTooltips(renderer); @@ -366,42 +360,42 @@ public static boolean is2x2Recipe(CraftingRecipe recipe){ } @Override - protected void renderLabels(GuiGraphics guiGraphics, int i, int j) { + protected void renderLabels(PoseStack poseStack, int i, int j) { Component title = getTabList() == craftingTabList ? getTabList().tabButtons.get(getTabList().selectedTab).getMessage() : getFocused() instanceof CustomCraftingIconHolder h ? h.getDisplayName() : Component.empty(); - guiGraphics.drawString(this.font, title,((groupTabList.selectedTab == 0 ? imageWidth : imageWidth / 2) - font.width(title)) / 2,17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - if (infoType.get() <= 0) guiGraphics.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, title,((groupTabList.selectedTab == 0 ? imageWidth : imageWidth / 2) - font.width(title)) / 2,17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + if (infoType.get() <= 0) poseStack.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); else { if (selectedCraftingButton < getCraftingButtons().size() && getCraftingButtons().get(selectedCraftingButton) instanceof RecipeIconHolder h) { if (infoType.get() == 1 && ScreenUtil.hasTip(h.getFocusedResult())) { List l = font.split(ScreenUtil.getTip(h.getFocusedResult()), 152); for (int i1 = 0; i1 < l.size(); i1++) { if (i1 > 7) break; - guiGraphics.drawString(font, l.get(i1), 181, 108 + i1 * 12, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(font, l.get(i1), 181, 108 + i1 * 12, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } } else if (infoType.get() == 2) { - guiGraphics.drawString(this.font, INGREDIENTS, (355 + 160 - font.width(INGREDIENTS))/ 2, 108, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, INGREDIENTS, (355 + 160 - font.width(INGREDIENTS))/ 2, 108, CommonColor.INVENTORY_GRAY_TEXT.get(), false); if (h.getFocusedRecipe() != null) { compactItemStackList.clear(); RecipeMenu.handleCompactItemStackList(compactItemStackList, () -> h.getFocusedRecipe().getIngredients().stream().map(RecipeIconHolder::getActualItem).iterator()); for (int i1 = 0; i1 < compactItemStackList.size(); i1++) { if (i1 > 4) break; ItemStack ing = compactItemStackList.get(i1); - ScreenUtil.iconHolderRenderer.itemHolder(180, 124 + 15 * i1, 14, 14, ing, false, Offset.ZERO).render(guiGraphics, i, j, 0); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(198, 128 + 15 * i1, 0); - guiGraphics.pose().scale(2 / 3f, 2 / 3f, 2 / 3f); - guiGraphics.drawString(font, ing.getHoverName(), 0, 0, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - guiGraphics.pose().popPose(); + ScreenUtil.iconHolderRenderer.itemHolder(180, 124 + 15 * i1, 14, 14, ing, false, Offset.ZERO).render(poseStack, i, j, 0); + poseStack.pose().pushPose(); + poseStack.pose().translate(198, 128 + 15 * i1, 0); + poseStack.pose().scale(2 / 3f, 2 / 3f, 2 / 3f); + poseStack.drawString(font, ing.getHoverName(), 0, 0, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.pose().popPose(); } } } } } - guiGraphics.pose().translate(-leftPos,-topPos,0); - getCraftingButtons().forEach(b-> b.render(guiGraphics,i,j,0)); - if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(guiGraphics, i, j, 0); - guiGraphics.pose().translate(leftPos,topPos,0); + poseStack.pose().translate(-leftPos,-topPos,0); + getCraftingButtons().forEach(b-> b.render(poseStack,i,j,0)); + if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(poseStack, i, j, 0); + poseStack.pose().translate(leftPos,topPos,0); } @Override @@ -488,7 +482,7 @@ protected void addCraftingButtons(){ RecipeIconHolder h; craftingButtons.add(h = new RecipeIconHolder<>(leftPos + 13 + i * 27, topPos + 38) { @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (isFocused()) selectedCraftingButton = index; super.render(graphics, i, j, f); } @@ -571,7 +565,7 @@ public ItemStack getResultStack() { return resultStack; } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (isFocused()) selectedCraftingButton = getCraftingButtons().indexOf(this); super.render(graphics, i, j, f); } @@ -589,22 +583,22 @@ public boolean mouseScrolled(double d, double e, double g) { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Override - protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { - groupTabList.render(guiGraphics, i, j, f); - getTabList().render(guiGraphics, i, j, f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL, leftPos, topPos, imageWidth, imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 9, topPos + 103, 163, 105); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 176, topPos + 103, 163, 105); - if (groupTabList.selectedTab != 0) LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 8, 163, 93); - LegacyGuiGraphics.of(guiGraphics).blitSprite(SMALL_ARROW, leftPos + (is2x2 ? 87 : 97), topPos + 161, 16, 13); + protected void renderBg(PoseStack poseStack, float f, int i, int j) { + groupTabList.render(poseStack, i, j, f); + getTabList().render(poseStack, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL, leftPos, topPos, imageWidth, imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 9, topPos + 103, 163, 105); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 176, topPos + 103, 163, 105); + if (groupTabList.selectedTab != 0) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 8, 163, 93); + LegacyGuiGraphics.of(poseStack).blitSprite(SMALL_ARROW, leftPos + (is2x2 ? 87 : 97), topPos + 161, 16, 13); if (groupTabList.selectedTab == 0) { if (craftingButtonsOffset.get() > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.LEFT, leftPos + 5, topPos + 45); + scrollRenderer.renderScroll(poseStack, ScreenDirection.LEFT, leftPos + 5, topPos + 45); if (craftingButtonsOffset.max > 0 && craftingButtonsOffset.get() < craftingButtonsOffset.max) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); + scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); } } @@ -644,28 +638,28 @@ public List getCraftingButtons(){ }; } @Override - public void render(GuiGraphics guiGraphics + public void render(PoseStack poseStack , int i, int j, float f) { - super.render(guiGraphics, i, j, f); + super.render(poseStack, i, j, f); for (int index = 0; index < ingredientsGrid.size(); index++) - ScreenUtil.iconHolderRenderer.itemHolder(leftPos + (is2x2 ? 33 : 21) + index % gridDimension * 23, topPos + (is2x2 ? 145 : 133) + index / gridDimension * 23, 23, 23, getActualItem(ingredientsGrid.get(index)), (!onlyCraftableRecipes || groupTabList.selectedTab != 0) && !getActualItem(ingredientsGrid.get(index)).isEmpty() && warningSlots[index], new Offset(0.5, is2x2 ? 0 : 0.5, 0)).render(guiGraphics, i, j, f);; - ScreenUtil.iconHolderRenderer.itemHolder(leftPos + (is2x2 ? 113 : 124), topPos + 151, 36, 36, resultStack, (!onlyCraftableRecipes || groupTabList.selectedTab != 0) && ingredientsGrid.stream().anyMatch(ing-> !ing.isEmpty()) && !canCraft(ingredientsGrid,false), new Offset(0.5, 0, 0)).render(guiGraphics, i, j, f); + ScreenUtil.iconHolderRenderer.itemHolder(leftPos + (is2x2 ? 33 : 21) + index % gridDimension * 23, topPos + (is2x2 ? 145 : 133) + index / gridDimension * 23, 23, 23, getActualItem(ingredientsGrid.get(index)), (!onlyCraftableRecipes || groupTabList.selectedTab != 0) && !getActualItem(ingredientsGrid.get(index)).isEmpty() && warningSlots[index], new Offset(0.5, is2x2 ? 0 : 0.5, 0)).render(poseStack, i, j, f);; + ScreenUtil.iconHolderRenderer.itemHolder(leftPos + (is2x2 ? 113 : 124), topPos + 151, 36, 36, resultStack, (!onlyCraftableRecipes || groupTabList.selectedTab != 0) && ingredientsGrid.stream().anyMatch(ing-> !ing.isEmpty()) && !canCraft(ingredientsGrid,false), new Offset(0.5, 0, 0)).render(poseStack, i, j, f); if (!resultStack.isEmpty()) { Component resultName = resultStack.getHoverName(); - ScreenUtil.renderScrollingString(guiGraphics, font, resultName, leftPos + 11 + Math.max(163 - font.width(resultName), 0) / 2, topPos + 114, leftPos + 170, topPos + 125, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + ScreenUtil.renderScrollingString(poseStack, font, resultName, leftPos + 11 + Math.max(163 - font.width(resultName), 0) / 2, topPos + 114, leftPos + 170, topPos + 125, CommonColor.INVENTORY_GRAY_TEXT.get(), false); if (groupTabList.selectedTab != 0){ List list = resultStack.getTooltipLines(minecraft.player, TooltipFlag.NORMAL); for (int i1 = 0; i1 < list.size(); i1++) { if (26 + i1 * 13 >= 93) break; Component c = list.get(i1); - ScreenUtil.renderScrollingString(guiGraphics, font, c.copy().setStyle(Style.EMPTY), leftPos + 180, topPos + 15 + i1 * 13, leftPos + 335, topPos + 26 + i1 * 13, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + ScreenUtil.renderScrollingString(poseStack, font, c.copy().setStyle(Style.EMPTY), leftPos + 180, topPos + 15 + i1 * 13, leftPos + 335, topPos + 26 + i1 * 13, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } } - if (ScreenUtil.isMouseOver(i,j,leftPos + (is2x2 ? 113 : 124), topPos + 151,36,36)) guiGraphics.renderTooltip(font, resultStack,i,j); + if (ScreenUtil.isMouseOver(i,j,leftPos + (is2x2 ? 113 : 124), topPos + 151,36,36)) poseStack.renderTooltip(font, resultStack,i,j); } - for (int index = 0; index < ingredientsGrid.size(); index++) if (!getActualItem(ingredientsGrid.get(index)).isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + (is2x2 ? 33 : 21) + index % gridDimension * 23, topPos + (is2x2 ? 145 : 133) + index / gridDimension * 23,23,23)) guiGraphics.renderTooltip(font,getActualItem(ingredientsGrid.get(index)),i,j); - getCraftingButtons().forEach(h -> h.renderTooltip(minecraft, guiGraphics, i, j)); + for (int index = 0; index < ingredientsGrid.size(); index++) if (!getActualItem(ingredientsGrid.get(index)).isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + (is2x2 ? 33 : 21) + index % gridDimension * 23, topPos + (is2x2 ? 145 : 133) + index / gridDimension * 23,23,23)) poseStack.renderTooltip(font,getActualItem(ingredientsGrid.get(index)),i,j); + getCraftingButtons().forEach(h -> h.renderTooltip(minecraft, poseStack, i, j)); - renderTooltip(guiGraphics, i, j); + renderTooltip(poseStack, i, j); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java index 664249d2..44c542cf 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -33,19 +33,19 @@ public LegacyFlatPresetsScreen(Screen parent, HolderLookup.RegistryLookup { + addRenderableOnly(((poseStack, i, j, f) -> { if (ScreenUtil.hasTooltipBoxes()) { if (tooltipBoxLabel != null && getChildAt(i,j).map(g-> g instanceof AbstractWidget w ? w.getTooltip() : null).isEmpty() && (!(getFocused() instanceof AbstractWidget w) || w.getTooltip() == null)) tooltipBoxLabel = null; - ScreenUtil.renderPointerPanel(guiGraphics,panel.x + panel.width - 2, panel.y + 5,194,panel.height - 10); - if (tooltipBoxLabel != null) tooltipBoxLabel.renderLeftAligned(guiGraphics, panel.x + panel.width + 3, panel.y + 13,12,0xFFFFFF); + ScreenUtil.renderPointerPanel(poseStack,panel.x + panel.width - 2, panel.y + 5,194,panel.height - 10); + if (tooltipBoxLabel != null) tooltipBoxLabel.renderLeftAligned(poseStack, panel.x + panel.width + 3, panel.y + 13,12,0xFFFFFF); } })); addRenderableOnly(panel); panel.init(); - addRenderableOnly(((guiGraphics, i, j, f) -> LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); + addRenderableOnly(((poseStack, i, j, f) -> LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); getRenderableVList().init(this,panel.x + 11,panel.y + 11,260, panel.height - 5); tabList.init(panel.x,panel.y - 24, panel.width); this.generator.updateLayers(); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyIconHolder.java b/common/src/main/java/wily/legacy/client/screen/LegacyIconHolder.java index c69cf52f..c67914b1 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyIconHolder.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyIconHolder.java @@ -1,13 +1,13 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.navigation.ScreenRectangle; import net.minecraft.client.renderer.RenderType; @@ -106,7 +106,7 @@ public static LegacyIconHolder entityHolder(int x, int y, int width, int height, Entity entity; @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { super.render(graphics, i, j, f); if (entity == null && Minecraft.getInstance().level != null) entity = entityType.create(Minecraft.getInstance().level); if (entity != null) renderEntity(graphics, entity, i, j, f); @@ -138,7 +138,7 @@ public boolean canSizeIcon(){ return Math.min(getWidth(),getHeight()) > 21; } - public void applyOffset(GuiGraphics graphics){ + public void applyOffset(PoseStack graphics){ if (!offset.equals(Offset.ZERO)) offset.apply(graphics.pose()); } public boolean isWarning(){ @@ -152,7 +152,7 @@ public ResourceLocation getIconHolderSprite(){ } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { isHovered = ScreenUtil.isMouseOver(i, j, getXCorner(), getYCorner(), width, height); ResourceLocation sprite = getIconHolderSprite(); if (sprite != null){ @@ -167,7 +167,7 @@ public void render(GuiGraphics graphics, int i, int j, float f) { } renderItem(graphics,i,j,f); } - public void renderIcon(ResourceLocation location,GuiGraphics graphics, boolean scaled, int width, int height){ + public void renderIcon(ResourceLocation location,PoseStack graphics, boolean scaled, int width, int height){ graphics.pose().pushPose(); graphics.pose().translate(getX(), getY(),0); applyOffset(graphics); @@ -177,17 +177,17 @@ public void renderIcon(ResourceLocation location,GuiGraphics graphics, boolean s LegacyGuiGraphics.of(graphics).blitSprite(location, 0, 0, width, height); graphics.pose().popPose(); } - public void renderItem(GuiGraphics graphics, int i, int j, float f){ + public void renderItem(PoseStack graphics, int i, int j, float f){ renderItem(graphics,itemIcon,getX(),getY(),isWarning()); } - public void renderItem(GuiGraphics graphics, ItemStack item, int x, int y, boolean isWarning){ + public void renderItem(PoseStack graphics, ItemStack item, int x, int y, boolean isWarning){ if (!item.isEmpty()) renderItem(graphics,()->{ graphics.renderFakeItem(item, 0,0); if (allowItemDecorations) graphics.renderItemDecorations(Minecraft.getInstance().font, item,0,0); },x,y,isWarning); } - public void renderItem(GuiGraphics graphics, Runnable itemRender, int x, int y, boolean isWarning){ + public void renderItem(PoseStack graphics, Runnable itemRender, int x, int y, boolean isWarning){ renderScaled(graphics,x,y,itemRender); if (isWarning) { RenderSystem.disableDepthTest(); @@ -198,7 +198,7 @@ public void renderItem(GuiGraphics graphics, Runnable itemRender, int x, int y, RenderSystem.enableDepthTest(); } } - public void renderEntity(GuiGraphics graphics, Entity entity, int i, int j, float f){ + public void renderEntity(PoseStack graphics, Entity entity, int i, int j, float f){ entity.setYRot(180); entity.yRotO = entity.getYRot(); entity.setXRot(entity.xRotO = 0 ); @@ -211,7 +211,7 @@ public void renderEntity(GuiGraphics graphics, Entity entity, int i, int j, floa ScreenUtil.renderEntity(graphics,getX() + getWidth() / 2f,getYCorner() + Math.min(getSelectableWidth(),getSelectableHeight()),(int)Math.min(getSelectableWidth(),getSelectableHeight()),f, new Vector3f(),new Quaternionf().rotationXYZ(0.0f, (float) Math.PI/ 4, (float) Math.PI), null, entity,true); graphics.disableScissor(); } - public void renderSelection(GuiGraphics graphics, int i, int j, float f){ + public void renderSelection(PoseStack graphics, int i, int j, float f){ graphics.pose().pushPose(); graphics.pose().translate(getXCorner() - 4.5f, getYCorner() - 4.5f, 0f); applyOffset(graphics); @@ -220,10 +220,10 @@ public void renderSelection(GuiGraphics graphics, int i, int j, float f){ RenderSystem.enableDepthTest(); graphics.pose().popPose(); } - public void renderHighlight(GuiGraphics graphics, int color, int h){ + public void renderHighlight(PoseStack graphics, int color, int h){ renderScaled(graphics,getX(),getY(), ()->graphics.fillGradient(RenderType.gui(), 0, 0, 16,16, color, color, h)); } - public void renderScaled(GuiGraphics graphics, float x, float y, Runnable render){ + public void renderScaled(PoseStack graphics, float x, float y, Runnable render){ graphics.pose().pushPose(); graphics.pose().translate(x,y,0); applyOffset(graphics); @@ -231,16 +231,16 @@ public void renderScaled(GuiGraphics graphics, float x, float y, Runnable render render.run(); graphics.pose().popPose(); } - public void renderHighlight(GuiGraphics graphics, int h){ + public void renderHighlight(PoseStack graphics, int h){ renderHighlight(graphics,-2130706433,h); } - public void renderHighlight(GuiGraphics graphics){ + public void renderHighlight(PoseStack graphics){ renderHighlight(graphics,0); } - public void renderTooltip(Minecraft minecraft, GuiGraphics graphics,int i, int j){ + public void renderTooltip(Minecraft minecraft, PoseStack graphics,int i, int j){ if (isHovered || (allowFocusedItemTooltip && isFocused())) renderTooltip(minecraft,graphics,itemIcon, !isHovered ? (int) getMiddleX() : i,!isHovered ? (int) getMiddleY() : j); } - public void renderTooltip(Minecraft minecraft, GuiGraphics graphics,ItemStack stack, int i, int j){ + public void renderTooltip(Minecraft minecraft, PoseStack graphics,ItemStack stack, int i, int j){ if (!stack.isEmpty()) graphics.renderTooltip(minecraft.font, stack, i, j); } public boolean isHoveredOrFocused(){ diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyKeyBindsScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyKeyBindsScreen.java index 6f37a7a3..3f2b33b5 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyKeyBindsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyKeyBindsScreen.java @@ -2,10 +2,10 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.KeyMapping; import net.minecraft.client.Options; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -46,17 +46,17 @@ public LegacyKeyBindsScreen(Screen parent, Options options) { lastCategory = keyMapping.getCategory(); renderableVList.addRenderable(new AbstractButton(0,0,240,20,((LegacyKeyMapping)keyMapping).getDisplayName()) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { if (!isFocused() && isPressed()) selectedKey = null; - super.renderWidget(guiGraphics, i, j, f); + super.renderWidget(poseStack, i, j, f); ControlTooltip.Icon icon = ControlTooltip.getKeyIcon(((LegacyKeyMapping) keyMapping).getKey().getValue()); Component c = isPressed() ? SELECTION : icon == null ? NONE : null; if (c != null){ - guiGraphics.drawString(font,NONE, getX() + width - 20 - font.width(NONE) / 2, getY() + (height - font.lineHeight) / 2 + 1,0xFFFFFF); + poseStack.drawString(font,NONE, getX() + width - 20 - font.width(NONE) / 2, getY() + (height - font.lineHeight) / 2 + 1,0xFFFFFF); return; } RenderSystem.enableBlend(); - icon.render(guiGraphics, getX() + width - 20 - icon.render(guiGraphics,0,0,false,true) / 2, getY() + (height - font.lineHeight) / 2 + 1,false,false); + icon.render(poseStack, getX() + width - 20 - icon.render(poseStack,0,0,false,true) / 2, getY() + (height - font.lineHeight) / 2 + 1,false,false); RenderSystem.disableBlend(); } private boolean isPressed(){ @@ -68,8 +68,8 @@ public void onPress() { else selectedKey = keyMapping; } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + 8, this.getY(), getX() + getWidth(), this.getY() + this.getHeight(), j,true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), this.getX() + 8, this.getY(), getX() + getWidth(), this.getY() + this.getHeight(), j,true); } @Override protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) { @@ -104,8 +104,8 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); } @Override @@ -113,7 +113,7 @@ protected void init() { panel.height = Math.min(height,293); panel.init(); addRenderableOnly(panel); - addRenderableOnly(((guiGraphics, i, j, f) -> guiGraphics.drawString(font, Legacy4JPlatform.getModInfo("minecraft").getVersion() + " " + Legacy4J.VERSION.get(),panel.getX() + panel.getWidth() + 81, panel.getY() + panel.getHeight() - 7,CommonColor.INVENTORY_GRAY_TEXT.get(),false))); + addRenderableOnly(((poseStack, i, j, f) -> poseStack.drawString(font, Legacy4JPlatform.getModInfo("minecraft").getVersion() + " " + Legacy4J.VERSION.get(),panel.getX() + panel.getWidth() + 81, panel.getY() + panel.getHeight() - 7,CommonColor.INVENTORY_GRAY_TEXT.get(),false))); getRenderableVList().init(this,panel.x + 7,panel.y + 6,panel.width - 14,panel.height); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyLanguageScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyLanguageScreen.java index 08e3f378..7ca65912 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyLanguageScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyLanguageScreen.java @@ -1,6 +1,6 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -18,8 +18,8 @@ public LegacyLanguageScreen(Screen parent, LanguageManager manager) { manager.getLanguages().forEach(((s, languageInfo) -> { renderableVList.addRenderable(new AbstractButton(0,0,260,20,languageInfo.toComponent()) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); if (manager.getSelected().equals(s)) setFocused(true); } @@ -50,7 +50,7 @@ public void onClose() { protected void init() { panel.init(); addRenderableOnly(panel); - addRenderableOnly(((guiGraphics, i, j, f) -> LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 6, panel.y + 24, panel.width - 12, panel.height - 34))); + addRenderableOnly(((poseStack, i, j, f) -> LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 6, panel.y + 24, panel.width - 12, panel.height - 34))); getRenderableVList().init(this,panel.x + 10,panel.y + 30,panel.width - 20,panel.height - 28); addRenderableWidget(minecraft.options.forceUnicodeFont().createButton(minecraft.options,panel.x + 10, panel.y + 10, panel.width - 20)); } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java index 414c8669..564624e9 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java @@ -1,9 +1,9 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.GameNarrator; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -68,32 +68,32 @@ public boolean shouldCloseOnEsc() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { + public void render(PoseStack poseStack, int i, int j, float f) { RenderSystem.disableDepthTest(); - ScreenUtil.renderDefaultBackground(guiGraphics,true, true); - super.render(guiGraphics, i, j, f); + ScreenUtil.renderDefaultBackground(poseStack,true, true); + super.render(poseStack, i, j, f); int x = width / 2 - 160; int y = height / 2 + 16; if (!genericLoading) { if (progress != -1) { if (lastLoadingStage != null) - guiGraphics.drawString(minecraft.font, lastLoadingStage, x, height / 2 + 4, 16777215); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LOADING_BACKGROUND, x, y, 320, 10); + poseStack.drawString(minecraft.font, lastLoadingStage, x, height / 2 + 4, 16777215); + LegacyGuiGraphics.of(poseStack).blitSprite(LOADING_BACKGROUND, x, y, 320, 10); if (progress >= 0) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LOADING_BAR, x + 1, y + 1, (int) (318 * Math.max(0,Math.min(progress / 100F,1))), 8); + LegacyGuiGraphics.of(poseStack).blitSprite(LOADING_BAR, x + 1, y + 1, (int) (318 * Math.max(0,Math.min(progress / 100F,1))), 8); LegacyTip tip = getLoadingTip(); if (tip != null) { tip.setX((width - tip.width) / 2); tip.setY(y + 8 + ((height - (y + 8)) - tip.height) / 2); - tip.render(guiGraphics, i, j, f); + tip.render(poseStack, i, j, f); } } - }else ScreenUtil.drawGenericLoading(guiGraphics,(width - 75 )/ 2, height / 2); + }else ScreenUtil.drawGenericLoading(poseStack,(width - 75 )/ 2, height / 2); - guiGraphics.pose().scale(2.0F,2.0F,1.0F); + poseStack.pose().scale(2.0F,2.0F,1.0F); if (lastLoadingHeader != null) - ScreenUtil.drawOutlinedString(guiGraphics, minecraft.font, lastLoadingHeader, (width - minecraft.font.width(lastLoadingHeader) * 2) / 4, (height / 4 - 13), 0xFFFFFF, 0, 0.5f); - guiGraphics.pose().scale(0.5F,0.5F,1.0F); + ScreenUtil.drawOutlinedString(poseStack, minecraft.font, lastLoadingHeader, (width - minecraft.font.width(lastLoadingHeader) * 2) / 4, (height / 4 - 13), 0xFFFFFF, 0, 0.5f); + poseStack.pose().scale(0.5F,0.5F,1.0F); RenderSystem.enableDepthTest(); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java index 888151f2..0d107eac 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.Screen; @@ -94,7 +94,7 @@ int findInventoryMatchSlot() { } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (isFocused()) selectedCraftingButton = getCraftingButtons().indexOf(this); super.render(graphics, i, j, f); } @@ -231,15 +231,15 @@ public void setFocused(@Nullable GuiEventListener guiEventListener) { super.setFocused(guiEventListener); } @Override - protected void renderLabels(GuiGraphics guiGraphics, int i, int j) { + protected void renderLabels(PoseStack poseStack, int i, int j) { Component title = craftingTabList.selectedTab != 0 ? craftingTabList.tabButtons.get(craftingTabList.selectedTab).getMessage() : getFocused() instanceof CustomRecipeIconHolder h ? h.getDisplayName() : Component.empty(); - guiGraphics.drawString(this.font, title,((craftingTabList.selectedTab != 0 ? imageWidth : imageWidth / 2) - font.width(title)) / 2,17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - if (menu.inventoryActive) guiGraphics.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - else guiGraphics.drawString(this.font, PREVIEW, (355 + 160 - font.width(PREVIEW))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - guiGraphics.pose().translate(-leftPos,-topPos,0); - getCraftingButtons().forEach(b-> b.render(guiGraphics,i,j,0)); - if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(guiGraphics, i, j, 0); - guiGraphics.pose().translate(leftPos,topPos,0); + poseStack.drawString(this.font, title,((craftingTabList.selectedTab != 0 ? imageWidth : imageWidth / 2) - font.width(title)) / 2,17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + if (menu.inventoryActive) poseStack.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + else poseStack.drawString(this.font, PREVIEW, (355 + 160 - font.width(PREVIEW))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.pose().translate(-leftPos,-topPos,0); + getCraftingButtons().forEach(b-> b.render(poseStack,i,j,0)); + if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(poseStack, i, j, 0); + poseStack.pose().translate(leftPos,topPos,0); } @Override public void bindingStateTick(BindingState state) { @@ -321,7 +321,7 @@ protected void addCraftingButtons(){ RecipeIconHolder h; craftingButtons.add(h = new RecipeIconHolder<>(leftPos + 13 + i * 27, topPos + 38) { @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (isFocused()) selectedCraftingButton = index; super.render(graphics, i, j, f); } @@ -419,29 +419,29 @@ public RecipeType getType() { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Override - protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { - craftingTabList.render(guiGraphics, i, j, f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL, leftPos, topPos, imageWidth, imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 9, topPos + 103, 163, 105); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 103, 163, 105); + protected void renderBg(PoseStack poseStack, float f, int i, int j) { + craftingTabList.render(poseStack, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL, leftPos, topPos, imageWidth, imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 9, topPos + 103, 163, 105); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 103, 163, 105); if (!menu.inventoryActive && !previewStack.isEmpty()){ - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 220.5, topPos + 130.5,0); - guiGraphics.pose().scale(4.25f,4.25f,4.25f); - guiGraphics.renderItem(previewStack,0,0); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 220.5, topPos + 130.5,0); + poseStack.pose().scale(4.25f,4.25f,4.25f); + poseStack.renderItem(previewStack,0,0); + poseStack.pose().popPose(); } - if (craftingTabList.selectedTab == 0) LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 8, 163, 93); - LegacyGuiGraphics.of(guiGraphics).blitSprite(SMALL_ARROW, leftPos + 97, topPos + 161, 16, 13); + if (craftingTabList.selectedTab == 0) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 8, 163, 93); + LegacyGuiGraphics.of(poseStack).blitSprite(SMALL_ARROW, leftPos + 97, topPos + 161, 16, 13); if (craftingTabList.selectedTab != 0) { if (craftingButtonsOffset.get() > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.LEFT, leftPos + 5, topPos + 45); + scrollRenderer.renderScroll(poseStack, ScreenDirection.LEFT, leftPos + 5, topPos + 45); if (craftingButtonsOffset.max > 0 && craftingButtonsOffset.get() < craftingButtonsOffset.max) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); + scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); } } @@ -467,27 +467,27 @@ public List getCraftingButtons(){ return craftingTabList.selectedTab == 0 ? selectBannerButton : craftingButtons; } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); for (int index = 0; index < ingredientsGrid.size(); index++) - ScreenUtil.iconHolderRenderer.itemHolder(leftPos + 21 + index % 3 * 23, topPos + 133 + index / 3 * 23, 23, 23, getActualItem(ingredientsGrid.get(index)), !getActualItem(ingredientsGrid.get(index)).isEmpty() && warningSlots[index], new Offset(0.5, 0.5, 0)).render(guiGraphics, i, j, f);; - ScreenUtil.iconHolderRenderer.itemHolder(leftPos + 124, topPos + 151, 36, 36, resultStack, getFocused() instanceof RecipeIconHolder r && r.isValidIndex() && !r.canCraft(), new Offset(0.5, 0, 0)).render(guiGraphics, i, j, f); + ScreenUtil.iconHolderRenderer.itemHolder(leftPos + 21 + index % 3 * 23, topPos + 133 + index / 3 * 23, 23, 23, getActualItem(ingredientsGrid.get(index)), !getActualItem(ingredientsGrid.get(index)).isEmpty() && warningSlots[index], new Offset(0.5, 0.5, 0)).render(poseStack, i, j, f);; + ScreenUtil.iconHolderRenderer.itemHolder(leftPos + 124, topPos + 151, 36, 36, resultStack, getFocused() instanceof RecipeIconHolder r && r.isValidIndex() && !r.canCraft(), new Offset(0.5, 0, 0)).render(poseStack, i, j, f); if (!resultStack.isEmpty()) { Component resultName = resultStack.getHoverName(); - ScreenUtil.renderScrollingString(guiGraphics, font, resultName, leftPos + 11 + Math.max(163 - font.width(resultName), 0) / 2, topPos + 114, leftPos + 170, topPos + 125, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + ScreenUtil.renderScrollingString(poseStack, font, resultName, leftPos + 11 + Math.max(163 - font.width(resultName), 0) / 2, topPos + 114, leftPos + 170, topPos + 125, CommonColor.INVENTORY_GRAY_TEXT.get(), false); if (craftingTabList.selectedTab == 0){ List list = resultStack.getTooltipLines(minecraft.player, TooltipFlag.NORMAL); for (int i1 = 0; i1 < list.size(); i1++) { if (26 + i1 * 13 >= 93) break; Component c = list.get(i1); - ScreenUtil.renderScrollingString(guiGraphics, font, c.copy().setStyle(Style.EMPTY), leftPos + 180, topPos + 15 + i1 * 13, leftPos + 335, topPos + 26 + i1 * 13, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + ScreenUtil.renderScrollingString(poseStack, font, c.copy().setStyle(Style.EMPTY), leftPos + 180, topPos + 15 + i1 * 13, leftPos + 335, topPos + 26 + i1 * 13, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } } - if (ScreenUtil.isMouseOver(i,j,leftPos + 124, topPos + 151,36,36)) guiGraphics.renderTooltip(font, resultStack,i,j); + if (ScreenUtil.isMouseOver(i,j,leftPos + 124, topPos + 151,36,36)) poseStack.renderTooltip(font, resultStack,i,j); } - for (int index = 0; index < ingredientsGrid.size(); index++) if (!getActualItem(ingredientsGrid.get(index)).isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + 21 + index % 3 * 23, topPos + 133 + index / 3 * 23,23,23)) guiGraphics.renderTooltip(font,getActualItem(ingredientsGrid.get(index)),i,j); - getCraftingButtons().forEach(h -> h.renderTooltip(minecraft, guiGraphics, i, j)); + for (int index = 0; index < ingredientsGrid.size(); index++) if (!getActualItem(ingredientsGrid.get(index)).isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + 21 + index % 3 * 23, topPos + 133 + index / 3 * 23,23,23)) poseStack.renderTooltip(font,getActualItem(ingredientsGrid.get(index)),i,j); + getCraftingButtons().forEach(h -> h.renderTooltip(minecraft, poseStack, i, j)); - renderTooltip(guiGraphics, i, j); + renderTooltip(poseStack, i, j); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java index 5758d553..00cc8396 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java @@ -2,8 +2,8 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -111,7 +111,7 @@ private void updateSlotsDisplay(){ protected void addTradeButton(int index){ LegacyIconHolder h = new LegacyIconHolder(27,27){ @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { itemIcon = isValidIndex() ? menu.merchant.getOffers().get(getIndex()).getResult() : ItemStack.EMPTY; super.render(graphics, i, j, f); if (isValidIndex() && ((LegacyMerchantOffer)menu.merchant.getOffers().get(getIndex())).getRequiredLevel() > menu.merchantLevel) { @@ -126,13 +126,13 @@ public void render(GuiGraphics graphics, int i, int j, float f) { } @Override - public void renderItem(GuiGraphics graphics, int i, int j, float f) { + public void renderItem(PoseStack graphics, int i, int j, float f) { if(itemIcon.isEmpty()) return; ScreenUtil.secureTranslucentRender(graphics,isValidIndex() && menu.merchant.getOffers().get(getIndex()).isOutOfStock(),0.5f, (u)-> super.renderItem(graphics, i, j, f)); } @Override - public void renderSelection(GuiGraphics graphics, int i, int j, float f) { + public void renderSelection(PoseStack graphics, int i, int j, float f) { for (int index = 0; index < 3; index++) { MerchantOffer offer = getSelectedMerchantOffer(); if (index == 1 && (offer == null || offer.getCostB().isEmpty())) continue; @@ -163,7 +163,7 @@ private int getIndex(){ return tradingButtonsOffset.get() + index; } @Override - public void renderTooltip(Minecraft minecraft, GuiGraphics graphics, int i, int j) { + public void renderTooltip(Minecraft minecraft, PoseStack graphics, int i, int j) { super.renderTooltip(minecraft, graphics, i, j); if (!isFocused()) return; MerchantOffer offer = getSelectedMerchantOffer(); @@ -219,7 +219,7 @@ public void onPress() { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } public void init() { @@ -257,15 +257,15 @@ public int getSelectedOfferIndex(){ } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { + public void render(PoseStack poseStack, int i, int j, float f) { if (!menu.merchant.getOffers().isEmpty() && !initOffers){ initOffers = true; updateSlotsDisplay(); } - super.render(guiGraphics, i, j, f); - if (getFocused() instanceof LegacyIconHolder h) h.renderSelection(guiGraphics,i,j,f); - merchantTradeButtons.forEach(b-> b.renderTooltip(minecraft,guiGraphics,i,j)); - renderTooltip(guiGraphics,i,j); + super.render(poseStack, i, j, f); + if (getFocused() instanceof LegacyIconHolder h) h.renderSelection(poseStack,i,j,f); + merchantTradeButtons.forEach(b-> b.renderTooltip(minecraft,poseStack,i,j)); + renderTooltip(poseStack,i,j); } @Override @@ -280,70 +280,70 @@ public boolean mouseScrolled(double d, double e, double g) { } - private void renderProgressBar(GuiGraphics guiGraphics) { + private void renderProgressBar(PoseStack poseStack) { int k = this.menu.merchantLevel; int l = this.menu.merchant.getVillagerXp(); if (k >= 5) { return; } - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + (imageWidth - 1.5f* 161) / 2,topPos + 28,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_BACKGROUND, 0, 0, 0, 161, 4); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + (imageWidth - 1.5f* 161) / 2,topPos + 28,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_BACKGROUND, 0, 0, 0, 161, 4); int m = VillagerData.getMinXpPerLevel(k); if (l < m || !VillagerData.canLevelUp(k)) { return; } float f = 161.0f / (float)(VillagerData.getMaxXpPerLevel(k) - m); int o = Math.min(Mth.floor(f * (float)(l - m)), 161); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_CURRENT, 161, 4, 0, 0, 0, 0, 0, o, 4); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_CURRENT, 161, 4, 0, 0, 0, 0, 0, o, 4); int p = getSelectedMerchantOffer() != null ? getSelectedMerchantOffer().getXp() : 0; if (p > 0) { int q = Math.min(Mth.floor((float)p * f), 161 - o); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_RESULT, 161, 4, o, 0, o, 0, 0, q, 4); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_RESULT, 161, 4, o, 0, o, 0, 0, q, 4); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } @Override - public void renderLabels(GuiGraphics guiGraphics, int i, int j) { + public void renderLabels(PoseStack poseStack, int i, int j) { int k = this.menu.merchantLevel; if (k > 0 && k <= 5 && this.menu.showProgressBar) { MutableComponent component = Component.translatable("merchant.title", this.title, Component.translatable("merchant.level." + k)); - guiGraphics.drawString(this.font, component, (imageWidth - this.font.width(component)) / 2, titleLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, component, (imageWidth - this.font.width(component)) / 2, titleLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } else { - guiGraphics.drawString(this.font, this.title, titleLabelX, titleLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.title, titleLabelX, titleLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } - guiGraphics.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); if (getSelectedMerchantOffer() != null && menu.showProgressBar) { int level = ((LegacyMerchantOffer)getSelectedMerchantOffer()).getRequiredLevel(); if (level > 0) { Component c = Component.translatable("merchant.level." + level); - guiGraphics.drawString(this.font, c, 15 + (105 - font.width(c)) / 2, 100, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, c, 15 + (105 - font.width(c)) / 2, 100, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } } } @Override - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 12,topPos + 79,110,93); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 126,topPos + 79,157,93); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 47,topPos + 131,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ARROW,0,0,22,15); + public void renderBg(PoseStack poseStack, float f, int i, int j) { + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 12,topPos + 79,110,93); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 126,topPos + 79,157,93); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 47,topPos + 131,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ARROW,0,0,22,15); if (getSelectedMerchantOffer() != null && getSelectedMerchantOffer().isOutOfStock()) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ERROR_CROSS, 4, 0, 15, 15); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ERROR_CROSS, 4, 0, 15, 15); + poseStack.pose().popPose(); if (getSelectedMerchantOffer() instanceof LegacyMerchantOffer o && o.getRequiredLevel() > menu.merchantLevel) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PADLOCK, leftPos + 56, topPos + 134, 16, 16); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PADLOCK, leftPos + 56, topPos + 134, 16, 16); if (menu.showProgressBar) - renderProgressBar(guiGraphics); + renderProgressBar(poseStack); if (tradingButtonsOffset.get() > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.LEFT, leftPos + 5, topPos + 52); + scrollRenderer.renderScroll(poseStack, ScreenDirection.LEFT, leftPos + 5, topPos + 52); if (tradingButtonsOffset.max > 0 && tradingButtonsOffset.get() < tradingButtonsOffset.max) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT, leftPos + 283, topPos + 52); + scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT, leftPos + 283, topPos + 52); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyScreen.java index a4196a24..1fdc8ddb 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyScreen.java @@ -1,6 +1,6 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import wily.legacy.client.controller.Controller; @@ -13,19 +13,19 @@ public class LegacyScreen extends Screen implements Controller.Event, ControlToo protected LegacyScreen(Component component) { super(component); } - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f){ - ScreenUtil.renderDefaultBackground(guiGraphics); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f){ + ScreenUtil.renderDefaultBackground(poseStack); } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - renderDefaultBackground(guiGraphics, i, j, f); - super.render(guiGraphics, i, j, f); + public void render(PoseStack poseStack, int i, int j, float f) { + renderDefaultBackground(poseStack, i, j, f); + super.render(poseStack, i, j, f); } @Override - public void renderBackground(GuiGraphics guiGraphics) { - renderDefaultBackground(guiGraphics,0,0,0); + public void renderBackground(PoseStack poseStack) { + renderDefaultBackground(poseStack,0,0,0); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyScrollRenderer.java b/common/src/main/java/wily/legacy/client/screen/LegacyScrollRenderer.java index b491c0c0..0a43cf08 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyScrollRenderer.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyScrollRenderer.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenAxis; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.resources.ResourceLocation; @@ -19,7 +19,7 @@ public void updateScroll(ScreenDirection direction){ lastDirection = direction; lastScroll = (lastScrolled[direction.ordinal()] = Util.getMillis()); } - public void renderScroll(GuiGraphics graphics, ScreenDirection direction, int x, int y){ + public void renderScroll(PoseStack graphics, ScreenDirection direction, int x, int y){ boolean h =direction.getAxis() == ScreenAxis.HORIZONTAL; RenderSystem.enableBlend(); long l = lastScrolled[direction.ordinal()]; diff --git a/common/src/main/java/wily/legacy/client/screen/LegacySliderButton.java b/common/src/main/java/wily/legacy/client/screen/LegacySliderButton.java index daa711c7..d57f4838 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacySliderButton.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacySliderButton.java @@ -1,9 +1,8 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.network.chat.Component; import wily.legacy.Legacy4JClient; import wily.legacy.init.LegacyRegistries; @@ -55,9 +54,9 @@ protected void updateMessage() { } @Override - public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + public void renderWidget(PoseStack poseStack, int i, int j, float f) { setMessage(messageGetter.apply(this)); - super.renderWidget(guiGraphics, i, j, f); + super.renderWidget(poseStack, i, j, f); } public void setFocused(boolean bl) { diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyStonecutterScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyStonecutterScreen.java index 85ec7bf9..b2e8bb20 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyStonecutterScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyStonecutterScreen.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.network.chat.Component; @@ -107,28 +107,28 @@ public void init() { craftingButtonsOffset.max = Math.max(0,recipesByGroup.size() - 12); } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } - public void renderLabels(GuiGraphics guiGraphics, int i, int j) { - guiGraphics.drawString(this.font, title,(imageWidth - font.width(title)) / 2, 17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - guiGraphics.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 109, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + public void renderLabels(PoseStack poseStack, int i, int j) { + poseStack.drawString(this.font, title,(imageWidth - font.width(title)) / 2, 17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 109, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } @Override - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 9,topPos + 103,163,105); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 176,topPos + 103,163,105); - LegacyGuiGraphics.of(guiGraphics).blitSprite(ARROW,leftPos + 79,topPos + 158,22,15); - if (craftingButtonsOffset.get() > 0) scrollRenderer.renderScroll(guiGraphics, ScreenDirection.LEFT, leftPos + 5, topPos + 45); - if (craftingButtonsOffset.max > 0 && craftingButtonsOffset.get() < craftingButtonsOffset.max) scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); + public void renderBg(PoseStack poseStack, float f, int i, int j) { + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 9,topPos + 103,163,105); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 176,topPos + 103,163,105); + LegacyGuiGraphics.of(poseStack).blitSprite(ARROW,leftPos + 79,topPos + 158,22,15); + if (craftingButtonsOffset.get() > 0) scrollRenderer.renderScroll(poseStack, ScreenDirection.LEFT, leftPos + 5, topPos + 45); + if (craftingButtonsOffset.max > 0 && craftingButtonsOffset.get() < craftingButtonsOffset.max) scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT, leftPos + 337, topPos + 45); } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - craftingButtons.get(selectedCraftingButton).renderSelection(guiGraphics,i,j,f); - craftingButtons.forEach(h-> h.renderTooltip(minecraft,guiGraphics,i,j)); - renderTooltip(guiGraphics, i, j); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + craftingButtons.get(selectedCraftingButton).renderSelection(poseStack,i,j,f); + craftingButtons.forEach(h-> h.renderTooltip(minecraft,poseStack,i,j)); + renderTooltip(poseStack, i, j); } @Override @@ -155,7 +155,7 @@ protected void addCraftingButtons(){ RecipeIconHolder h; craftingButtons.add(h = new RecipeIconHolder<>(leftPos + 13 + i * 27, topPos + 38) { @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { if (isFocused()) selectedCraftingButton = index; super.render(graphics, i, j, f); } @@ -199,7 +199,7 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void renderTooltip(Minecraft minecraft, GuiGraphics graphics, int i, int j) { + public void renderTooltip(Minecraft minecraft, PoseStack graphics, int i, int j) { super.renderTooltip(minecraft, graphics, i, j); if (isFocused()) { if (!ingredientSlot.isEmpty() && ScreenUtil.isMouseOver(i,j, leftPos + 38, topPos + 149, 36,36)) @@ -210,7 +210,7 @@ public void renderTooltip(Minecraft minecraft, GuiGraphics graphics, int i, int } @Override - public void renderSelection(GuiGraphics graphics, int i, int j, float f) { + public void renderSelection(PoseStack graphics, int i, int j, float f) { boolean warning = !canCraft(getFocusedRecipe()); ScreenUtil.iconHolderRenderer.itemHolder(leftPos+38,topPos+149,36,36, getActualItem(ingredientSlot.get(0)), !onlyCraftableRecipes && !ingredientSlot.get(0).isEmpty() && warning, DISPLAY_OFFSET).render(graphics, i, j, f); ScreenUtil.iconHolderRenderer.itemHolder(leftPos+110,topPos+149,36,36,getFocusedResult(), warning, DISPLAY_OFFSET).render(graphics, i, j, f); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java b/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java index f80f3cc7..56008800 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java @@ -1,9 +1,9 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.Tooltip; @@ -51,48 +51,48 @@ public void onPress() { onPress.accept(this); } public static Function iconOf(Item item){ - return t-> (guiGraphics, i, j, f) -> t.renderItemIcon(item.getDefaultInstance(),guiGraphics); + return t-> (poseStack, i, j, f) -> t.renderItemIcon(item.getDefaultInstance(),poseStack); } public static Function iconOf(ItemStack stack){ - return t-> (guiGraphics, i, j, f) -> t.renderItemIcon(stack,guiGraphics); + return t-> (poseStack, i, j, f) -> t.renderItemIcon(stack,poseStack); } public static Function iconOf(ResourceLocation sprite){ - return t-> (guiGraphics, i, j, f) -> t.renderIconSprite(sprite,guiGraphics); + return t-> (poseStack, i, j, f) -> t.renderIconSprite(sprite,poseStack); } - public void renderString(GuiGraphics guiGraphics, Font font, int i, boolean shadow){ - guiGraphics.drawString(font,getMessage(),getX() + (width - font.width(getMessage())) / 2,getY() + (height - 7) / 2,i,shadow); + public void renderString(PoseStack poseStack, Font font, int i, boolean shadow){ + poseStack.drawString(font,getMessage(),getX() + (width - font.width(getMessage())) / 2,getY() + (height - 7) / 2,i,shadow); } - public void renderIconSprite(ResourceLocation icon, GuiGraphics guiGraphics){ - LegacyGuiGraphics.of(guiGraphics).blitSprite(icon, getX() + width / 2 - 12, getY() + height / 2 - 12, 24, 24); + public void renderIconSprite(ResourceLocation icon, PoseStack poseStack){ + LegacyGuiGraphics.of(poseStack).blitSprite(icon, getX() + width / 2 - 12, getY() + height / 2 - 12, 24, 24); } - public void renderItemIcon(ItemStack itemIcon, GuiGraphics guiGraphics){ - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX() + width / 2f - 12, getY() + height / 2f - 12, 0); - guiGraphics.pose().scale(1.5f, 1.5f, 1.5f); - guiGraphics.renderItem(itemIcon, 0, 0); - guiGraphics.pose().popPose(); + public void renderItemIcon(ItemStack itemIcon, PoseStack poseStack){ + poseStack.pose().pushPose(); + poseStack.pose().translate(getX() + width / 2f - 12, getY() + height / 2f - 12, 0); + poseStack.pose().scale(1.5f, 1.5f, 1.5f); + poseStack.renderItem(itemIcon, 0, 0); + poseStack.pose().popPose(); } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { Minecraft minecraft = Minecraft.getInstance(); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, this.alpha); + poseStack.setColor(1.0f, 1.0f, 1.0f, this.alpha); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); - guiGraphics.pose().pushPose(); + poseStack.pose().pushPose(); Offset translate = offset.apply(this); if (!translate.equals(Offset.ZERO)) { - translate.apply(guiGraphics.pose()); + translate.apply(poseStack.pose()); isHovered = isMouseOver(i,j); } - if (selected) guiGraphics.pose().translate(0F,0f,1F); - LegacyGuiGraphics.of(guiGraphics).blitSprite(SPRITES[type][selected ? 0 : 1], getX(), getY(), getWidth(), this.getHeight()); - if (!selected) guiGraphics.pose().translate(0,-1,0); + if (selected) poseStack.pose().translate(0F,0f,1F); + LegacyGuiGraphics.of(poseStack).blitSprite(SPRITES[type][selected ? 0 : 1], getX(), getY(), getWidth(), this.getHeight()); + if (!selected) poseStack.pose().translate(0,-1,0); if (active) { - if (icon == null) this.renderString(guiGraphics, minecraft.font, CommonColor.INVENTORY_GRAY_TEXT.get() | Mth.ceil(this.alpha * 255.0f) << 24); - else icon.apply(this).render(guiGraphics,i,j,f); + if (icon == null) this.renderString(poseStack, minecraft.font, CommonColor.INVENTORY_GRAY_TEXT.get() | Mth.ceil(this.alpha * 255.0f) << 24); + else icon.apply(this).render(poseStack,i,j,f); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } public boolean isMouseOver(double d, double e) { @@ -112,7 +112,7 @@ protected boolean clicked(double d, double e) { } @Override - public void renderString(GuiGraphics guiGraphics, Font font, int i) { - renderString(guiGraphics,font,i,false); + public void renderString(PoseStack poseStack, Font font, int i) { + renderString(poseStack,font,i,false); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java b/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java index f8c66e8d..86aa52c9 100644 --- a/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.screens.GenericDirtMessageScreen; @@ -211,21 +211,21 @@ public boolean mouseScrolled(double d, double e, double g) { } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderDefaultBackground(guiGraphics, i, j, f); - resourcePackSelector.renderTooltipBox(guiGraphics,panel); - panel.render(guiGraphics,i,j,f); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(0.5f,0,0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,panel.x + 12, panel.y + 9, 32,32); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(0,0.5f,0); - guiGraphics.blit(SaveRenderableList.iconCache.getUnchecked(summary).textureLocation(),panel.x + 14, panel.y + 10, 0,0,29,29,29,29); - guiGraphics.drawString(font,summary.getLevelName(),panel.x + 48, panel.y + 12, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.drawString(font,Component.translatable("legacy.menu.load_save.created_in", (summary.hasCheats() ? GameType.CREATIVE : GameType.SURVIVAL).getShortDisplayName()),panel.x + 48, panel.y + 29, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.pose().popPose(); - guiGraphics.drawString(font,Component.translatable("commands.seed.success",((LegacyWorldSettings)(Object)summary.getSettings()).getDisplaySeed()),panel.x + 13, panel.y + 49, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + super.renderDefaultBackground(poseStack, i, j, f); + resourcePackSelector.renderTooltipBox(poseStack,panel); + panel.render(poseStack,i,j,f); + poseStack.pose().pushPose(); + poseStack.pose().translate(0.5f,0,0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,panel.x + 12, panel.y + 9, 32,32); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(0,0.5f,0); + poseStack.blit(SaveRenderableList.iconCache.getUnchecked(summary).textureLocation(),panel.x + 14, panel.y + 10, 0,0,29,29,29,29); + poseStack.drawString(font,summary.getLevelName(),panel.x + 48, panel.y + 12, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.drawString(font,Component.translatable("legacy.menu.load_save.created_in", (summary.hasCheats() ? GameType.CREATIVE : GameType.SURVIVAL).getShortDisplayName()),panel.x + 48, panel.y + 29, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.pose().popPose(); + poseStack.drawString(font,Component.translatable("commands.seed.success",((LegacyWorldSettings)(Object)summary.getSettings()).getDisplaySeed()),panel.x + 13, panel.y + 49, CommonColor.INVENTORY_GRAY_TEXT.get(),false); } public static void loadWorld(Screen screen, Minecraft minecraft, LevelSummary summary) { diff --git a/common/src/main/java/wily/legacy/client/screen/ModsScreen.java b/common/src/main/java/wily/legacy/client/screen/ModsScreen.java index c621a7e4..be58d69b 100644 --- a/common/src/main/java/wily/legacy/client/screen/ModsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/ModsScreen.java @@ -5,8 +5,8 @@ import com.google.common.cache.LoadingCache; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -76,8 +76,8 @@ public void onPress() { } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); if (isFocused()) focusedMod = mod; RenderSystem.enableBlend(); SizedLocation logo = modLogosCache.computeIfAbsent(mod, m-> { @@ -92,14 +92,14 @@ protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { if (mod.getId().equals("minecraft")) defaultLogo = PackSelector.loadPackIcon(minecraft.getTextureManager(),minecraft.getResourcePackRepository().getPack("vanilla"),"pack.png",defaultLogo); return new SizedLocation(defaultLogo,1,1); }); - if (logo != null) guiGraphics.blit(logo.location,getX() + 5, getY() + 5, 0,0, logo.getScaledWidth(20),20,logo.getScaledWidth(20),20); + if (logo != null) poseStack.blit(logo.location,getX() + 5, getY() + 5, 0,0, logo.getScaledWidth(20),20,logo.getScaledWidth(20),20); RenderSystem.disableBlend(); } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { SizedLocation logo = modLogosCache.get(mod); - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(),this.getX() + 10 + (logo == null ? 20 : logo.getScaledWidth(20)), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j,true); + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(),this.getX() + 10 + (logo == null ? 20 : logo.getScaledWidth(20)), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j,true); } @Override protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) { @@ -110,22 +110,22 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); if (ScreenUtil.hasTooltipBoxes()) { - tooltipBox.render(guiGraphics,i,j,f); + tooltipBox.render(poseStack,i,j,f); if (focusedMod != null) { MultiLineLabel label = modLabelsCache.getUnchecked(focusedMod); scrollableRenderer.scrolled.max = Math.max(0,label.getLineCount() - (tooltipBox.getHeight() - 50) / 12); SizedLocation logo = modLogosCache.get(focusedMod); int x = panel.x + panel.width + (logo == null ? 5 : logo.getScaledWidth(28) + 10); if (logo != null) - guiGraphics.blit(logo.location, panel.x + panel.width + 5, panel.y + 10, 0.0f, 0.0f, logo.getScaledWidth(28), 28, logo.getScaledWidth(28), 28); + poseStack.blit(logo.location, panel.x + panel.width + 5, panel.y + 10, 0.0f, 0.0f, logo.getScaledWidth(28), 28, logo.getScaledWidth(28), 28); if (logo == null || logo.getScaledWidth(28) < 120) { - ScreenUtil.renderScrollingString(guiGraphics, font, Component.translatable("legacy.menu.mods.id", focusedMod.getId()), x, panel.y + 12, panel.x + panel.width + 185, panel.y + 24, 0xFFFFFF, true); - ScreenUtil.renderScrollingString(guiGraphics, font, Component.translatable("legacy.menu.mods.version",focusedMod.getVersion()), x, panel.y + 24, panel.x + panel.width + 185, panel.y + 36, 0xFFFFFF, true); + ScreenUtil.renderScrollingString(poseStack, font, Component.translatable("legacy.menu.mods.id", focusedMod.getId()), x, panel.y + 12, panel.x + panel.width + 185, panel.y + 24, 0xFFFFFF, true); + ScreenUtil.renderScrollingString(poseStack, font, Component.translatable("legacy.menu.mods.version",focusedMod.getVersion()), x, panel.y + 24, panel.x + panel.width + 185, panel.y + 36, 0xFFFFFF, true); } - scrollableRenderer.render(guiGraphics, panel.x + panel.width + 5, panel.y + 38, tooltipBox.getWidth() - 16, tooltipBox.getHeight() - 50, () -> label.renderLeftAligned(guiGraphics, panel.x + panel.width + 5, panel.y + 41, 12, 0xFFFFFF)); + scrollableRenderer.render(poseStack, panel.x + panel.width + 5, panel.y + 38, tooltipBox.getWidth() - 16, tooltipBox.getHeight() - 50, () -> label.renderLeftAligned(poseStack, panel.x + panel.width + 5, panel.y + 41, 12, 0xFFFFFF)); } } } @@ -138,7 +138,7 @@ public boolean mouseScrolled(double d, double e, double g) { @Override public void renderableVListInit() { - addRenderableOnly(((guiGraphics, i, j, f) -> LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); + addRenderableOnly(((poseStack, i, j, f) -> LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 7, panel.y + 7, panel.width - 14, panel.height - 14))); tooltipBox.init(); getRenderableVList().init(this,panel.x + 11,panel.y + 11,260, panel.height - 5); } diff --git a/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java b/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java index 8de53de3..efa12706 100644 --- a/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java @@ -1,6 +1,6 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -18,18 +18,18 @@ public OverlayPanelScreen(int imageWidth, int imageHeight, Component component) @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - if (transparentBackground) guiGraphics.fillGradient(0,0,guiGraphics.guiWidth(),guiGraphics.guiHeight(), -1073741824, -805306368);; + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + if (transparentBackground) poseStack.fillGradient(0,0,poseStack.guiWidth(),poseStack.guiHeight(), -1073741824, -805306368);; } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { + public void render(PoseStack poseStack, int i, int j, float f) { if (parent != null){ - parent.render(guiGraphics, 0, 0, f); + parent.render(poseStack, 0, 0, f); deferredTooltipRendering = null; } - guiGraphics.pose().translate(0,0, 1200); - super.render(guiGraphics, i, j, f); + poseStack.pose().translate(0,0, 1200); + super.render(poseStack, i, j, f); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/PackSelector.java b/common/src/main/java/wily/legacy/client/screen/PackSelector.java index fc4345d5..0ce66b32 100644 --- a/common/src/main/java/wily/legacy/client/screen/PackSelector.java +++ b/common/src/main/java/wily/legacy/client/screen/PackSelector.java @@ -8,15 +8,15 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.packs.PackSelectionModel; @@ -97,10 +97,10 @@ public List getDisplayPacks(){ public void updateTooltip(){ if (hasTooltip) setTooltip(Tooltip.create(selectedPack.getDescription(), selectedPack.getTitle())); } - public void renderTooltipBox(GuiGraphics guiGraphics, Panel panel){ - renderTooltipBox(guiGraphics,panel.x + panel.width - 2, panel.y + 5, 161, panel.height - 10); + public void renderTooltipBox(PoseStack poseStack, Panel panel){ + renderTooltipBox(poseStack,panel.x + panel.width - 2, panel.y + 5, 161, panel.height - 10); } - public void renderTooltipBox(GuiGraphics graphics, int x, int y, int width, int height){ + public void renderTooltipBox(PoseStack graphics, int x, int y, int width, int height){ if (!ScreenUtil.hasTooltipBoxes()) return; ScreenUtil.renderPointerPanel(graphics,x, y,width,height); if (selectedPack != null){ @@ -232,25 +232,25 @@ protected int getMaxPacks(){ } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { Font font = minecraft.font; - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,getX() -1,getY()+ font.lineHeight -1 , width + 2,height + 2 - minecraft.font.lineHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,getX() -1,getY()+ font.lineHeight -1 , width + 2,height + 2 - minecraft.font.lineHeight); List displayPacks = getDisplayPacks(); int visibleCount = 0; RenderSystem.enableBlend(); for (int index = 0; index < displayPacks.size(); index++) { if (visibleCount>=getMaxPacks()) break; - guiGraphics.blit(getPackIcon(displayPacks.get(scrolledList.get() + index)), getX() + 21 + 30 * index,getY() + font.lineHeight + 4,0.0f, 0.0f, 28, 28, 28, 28); - if (model.selected.contains(displayPacks.get(scrolledList.get() + index))) LegacyGuiGraphics.of(guiGraphics).blitSprite(PACK_SELECTED, getX() + 20 + 30 * index,getY() +font.lineHeight + 3,30,30); + poseStack.blit(getPackIcon(displayPacks.get(scrolledList.get() + index)), getX() + 21 + 30 * index,getY() + font.lineHeight + 4,0.0f, 0.0f, 28, 28, 28, 28); + if (model.selected.contains(displayPacks.get(scrolledList.get() + index))) LegacyGuiGraphics.of(poseStack).blitSprite(PACK_SELECTED, getX() + 20 + 30 * index,getY() +font.lineHeight + 3,30,30); if (scrolledList.get() + index == selectedIndex) - LegacyGuiGraphics.of(guiGraphics).blitSprite(PACK_HIGHLIGHTED, getX() + 20 + 30 * index,getY() +font.lineHeight + 3,30,30); + LegacyGuiGraphics.of(poseStack).blitSprite(PACK_HIGHLIGHTED, getX() + 20 + 30 * index,getY() +font.lineHeight + 3,30,30); visibleCount++; } RenderSystem.disableBlend(); - guiGraphics.drawString(font,getMessage(),getX() + 1,getY(),isHoveredOrFocused() ? ScreenUtil.getDefaultTextColor() : CommonColor.INVENTORY_GRAY_TEXT.get(),isHoveredOrFocused()); + poseStack.drawString(font,getMessage(),getX() + 1,getY(),isHoveredOrFocused() ? ScreenUtil.getDefaultTextColor() : CommonColor.INVENTORY_GRAY_TEXT.get(),isHoveredOrFocused()); if (scrolledList.max > 0){ - if (scrolledList.get() < scrolledList.max) scrollRenderer.renderScroll(guiGraphics, ScreenDirection.RIGHT, getX() + width - 12, getY() + font.lineHeight + (height - font.lineHeight - 11) / 2); - if (scrolledList.get() > 0) scrollRenderer.renderScroll(guiGraphics,ScreenDirection.LEFT,getX() + 8, getY() + font.lineHeight + (height - font.lineHeight - 11) / 2); + if (scrolledList.get() < scrolledList.max) scrollRenderer.renderScroll(poseStack, ScreenDirection.RIGHT, getX() + width - 12, getY() + font.lineHeight + (height - font.lineHeight - 11) / 2); + if (scrolledList.get() > 0) scrollRenderer.renderScroll(poseStack,ScreenDirection.LEFT,getX() + 8, getY() + font.lineHeight + (height - font.lineHeight - 11) / 2); } } public static ResourceLocation loadPackIcon(TextureManager textureManager, Pack pack, String icon, ResourceLocation fallback) { diff --git a/common/src/main/java/wily/legacy/client/screen/Panel.java b/common/src/main/java/wily/legacy/client/screen/Panel.java index 94f2faf1..07460da3 100644 --- a/common/src/main/java/wily/legacy/client/screen/Panel.java +++ b/common/src/main/java/wily/legacy/client/screen/Panel.java @@ -1,6 +1,6 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.resources.ResourceLocation; import wily.legacy.client.LegacyGuiGraphics; @@ -44,8 +44,8 @@ public void init() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderPointerPanel(guiGraphics,getX(),getY(),getWidth(),getHeight()); + public void render(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderPointerPanel(poseStack,getX(),getY(),getWidth(),getHeight()); } }; return p; @@ -54,7 +54,7 @@ public void init(){ setX(updatedX.apply(this)); setY(updatedY.apply(this)); } - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(panelSprite, x, y, width, height); + public void render(PoseStack poseStack, int i, int j, float f) { + LegacyGuiGraphics.of(poseStack).blitSprite(panelSprite, x, y, width, height); } } diff --git a/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java b/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java index 8c8692fa..869c2e5c 100644 --- a/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java @@ -1,9 +1,9 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; @@ -40,7 +40,7 @@ public class PlayGameScreen extends PanelVListScreen implements ControlTooltip.E private static final Component SAFETY_CONTENT = Component.translatable("multiplayerWarning.message"); private static final Component SAFETY_CHECK = Component.translatable("multiplayerWarning.check"); public boolean isLoading = false; - protected final TabList tabList = new TabList().add(30,0,Component.translatable("legacy.menu.load"), b-> repositionElements()).add(30,1,Component.translatable("legacy.menu.create"), b-> repositionElements()).add(30,2,t-> (guiGraphics, i, j, f) -> t.renderString(guiGraphics,font,canNotifyOnlineFriends() ? 0xFFFFFF : CommonColor.INVENTORY_GRAY_TEXT.get(),canNotifyOnlineFriends()),Component.translatable("legacy.menu.join"), b-> { + protected final TabList tabList = new TabList().add(30,0,Component.translatable("legacy.menu.load"), b-> repositionElements()).add(30,1,Component.translatable("legacy.menu.create"), b-> repositionElements()).add(30,2,t-> (poseStack, i, j, f) -> t.renderString(poseStack,font,canNotifyOnlineFriends() ? 0xFFFFFF : CommonColor.INVENTORY_GRAY_TEXT.get(),canNotifyOnlineFriends()),Component.translatable("legacy.menu.join"), b-> { if (this.minecraft.options.skipMultiplayerWarning) repositionElements(); else minecraft.setScreen(new ConfirmationScreen(this,SAFETY_TITLE,Component.translatable("legacy.menu.multiplayer_warning").append("\n").append(SAFETY_CONTENT)){ @@ -88,15 +88,15 @@ protected void init() { } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); - tabList.render(guiGraphics,i,j,f); - panel.render(guiGraphics,i,j,f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 9, panel.y + 9, panel.width - 18, panel.height - 18 - (tabList.selectedTab == 0 ? 21 : 0)); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); + tabList.render(poseStack,i,j,f); + panel.render(poseStack,i,j,f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 9, panel.y + 9, panel.width - 18, panel.height - 18 - (tabList.selectedTab == 0 ? 21 : 0)); if (tabList.selectedTab == 0){ if (saveRenderableList.currentlyDisplayedLevels != null) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(panel.x + 11.25f, panel.y + panel.height - 22.75, 0); + poseStack.pose().pushPose(); + poseStack.pose().translate(panel.x + 11.25f, panel.y + panel.height - 22.75, 0); long storage = new File("/").getTotalSpace(); long fixedStorage = SaveRenderableList.sizeCache.asMap().values().stream().max(Comparator.comparingLong(l->l)).orElse(0L) * (saveRenderableList.currentlyDisplayedLevels.size() + 1); long storageSize = fixedStorage != 0 ? Math.min(storage,fixedStorage) : storage; @@ -104,18 +104,18 @@ public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float Long size; if ((size = SaveRenderableList.sizeCache.getIfPresent(level)) == null) continue; float scaledSize = size * (panel.width - 21f)/ storageSize; - guiGraphics.pose().pushPose(); - guiGraphics.pose().scale(scaledSize,1,1); - guiGraphics.fill(0, 0, 1, 11,getFocused() instanceof AbstractButton b && saveRenderableList.renderables.contains(b) && saveRenderableList.renderables.indexOf(b) == saveRenderableList.currentlyDisplayedLevels.indexOf(level) ? CommonColor.SELECTED_STORAGE_SAVE.get() : CommonColor.STORAGE_SAVE.get()); - guiGraphics.pose().popPose(); - guiGraphics.pose().translate(scaledSize, 0, 0); + poseStack.pose().pushPose(); + poseStack.pose().scale(scaledSize,1,1); + poseStack.fill(0, 0, 1, 11,getFocused() instanceof AbstractButton b && saveRenderableList.renderables.contains(b) && saveRenderableList.renderables.indexOf(b) == saveRenderableList.currentlyDisplayedLevels.indexOf(level) ? CommonColor.SELECTED_STORAGE_SAVE.get() : CommonColor.STORAGE_SAVE.get()); + poseStack.pose().popPose(); + poseStack.pose().translate(scaledSize, 0, 0); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } - ScreenUtil.renderPanelTranslucentRecess(guiGraphics, panel.x + 9, panel.y + panel.height - 25, panel.width - 18 , 16); + ScreenUtil.renderPanelTranslucentRecess(poseStack, panel.x + 9, panel.y + panel.height - 25, panel.width - 18 , 16); } if (isLoading) - ScreenUtil.drawGenericLoading(guiGraphics, panel.x + 112 , + ScreenUtil.drawGenericLoading(poseStack, panel.x + 112 , panel.y + 66); } diff --git a/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java b/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java index f6f579cf..e8b42d91 100644 --- a/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java +++ b/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java @@ -2,9 +2,9 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; @@ -41,14 +41,14 @@ public RecipeIconHolder(int x, int y){ allowItemDecorations = false; } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { isHoveredTop = isFocused() && getFocusedRecipes().size() > 2 && isMouseOver(i,j,-1); isHoveredBottom = isFocused() && getFocusedRecipes().size() >= 2 && isMouseOver(i,j,1); itemIcon = isValidIndex() ? getFocusedRecipes().get(0).getResultItem(minecraft.level.registryAccess()) : ItemStack.EMPTY; super.render(graphics, i, j, f); } @Override - public void renderItem(GuiGraphics graphics, int i, int j, float f) { + public void renderItem(PoseStack graphics, int i, int j, float f) { if (!isValidIndex()) return; ScreenUtil.secureTranslucentRender(graphics, !canCraft(getFocusedRecipes().get(0)),0.5f, (u)->super.renderItem(graphics,i,j,f)); } @@ -73,7 +73,7 @@ public void setFocused(boolean bl) { super.setFocused(bl); } @Override - public void renderTooltip(Minecraft minecraft, GuiGraphics graphics, int i, int j) { + public void renderTooltip(Minecraft minecraft, PoseStack graphics, int i, int j) { super.renderTooltip(minecraft, graphics, i, j); if (!isFocused()) return; if (getFocusedRecipes().size() <= 1) return; @@ -137,7 +137,7 @@ public static ItemStack getActualItem(Ingredient ingredient){ return ingredient.isEmpty() || ingredient.getItems().length == 0 ? ItemStack.EMPTY : ingredient.getItems()[(int) ((Util.getMillis() / 800)% ingredient.getItems().length)]; } @Override - public void renderSelection(GuiGraphics graphics, int i, int j, float f) { + public void renderSelection(PoseStack graphics, int i, int j, float f) { if (isValidIndex()) { graphics.pose().pushPose(); graphics.pose().translate(getXCorner() - 4.5f, getYCorner(), 0f); diff --git a/common/src/main/java/wily/legacy/client/screen/SaveOptionsScreen.java b/common/src/main/java/wily/legacy/client/screen/SaveOptionsScreen.java index 5f0d5f77..ef457514 100644 --- a/common/src/main/java/wily/legacy/client/screen/SaveOptionsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/SaveOptionsScreen.java @@ -4,11 +4,9 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.toasts.SystemToast; -import net.minecraft.client.gui.screens.SymlinkWarningScreen; import net.minecraft.network.chat.Component; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelSummary; -import net.minecraft.world.level.validation.ContentValidationException; import wily.legacy.Legacy4J; import wily.legacy.Legacy4JClient; diff --git a/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java b/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java index 32e1fd69..e19e3fb9 100644 --- a/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java +++ b/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java @@ -7,18 +7,19 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.logging.LogUtils; import net.minecraft.ChatFormatting; import net.minecraft.CrashReport; import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.toasts.SystemToast; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.gui.screens.*; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.worldselection.EditWorldScreen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -27,8 +28,6 @@ import net.minecraft.world.level.storage.LevelStorageException; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelSummary; -import net.minecraft.world.level.validation.ContentValidationException; -import net.minecraft.world.level.validation.ForbiddenSymlinkInfo; import org.apache.commons.io.FileUtils; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -83,17 +82,17 @@ public Long load(LevelSummary key) { return FileUtils.sizeOfDirectory(Minecraft.getInstance().getLevelSource().getLevelPath(key.getLevelId()).toFile()); } }); - public static LoadingCache iconCache = CacheBuilder.newBuilder().build(new CacheLoader<>() { + public static LoadingCache iconCache = CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override - public FaviconTexture load(LevelSummary key) { + public DynamicTexture load(LevelSummary key) { Path iconFile = key.getIcon(); try { BasicFileAttributes basicFileAttributes = Files.readAttributes(iconFile, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); if (basicFileAttributes.isSymbolicLink()) { - List list = new ArrayList<>(); + List list = new ArrayList<>(); Minecraft.getInstance().getLevelSource().getWorldDirValidator().validateSymlink(iconFile, list); if (!list.isEmpty()) { - Legacy4J.LOGGER.warn("{}", ContentValidationException.getMessage(iconFile, list)); + Legacy4J.LOGGER.warn("{}", String.join(", ", list)); iconFile = null; } else { basicFileAttributes = Files.readAttributes(iconFile, BasicFileAttributes.class); @@ -108,16 +107,23 @@ public FaviconTexture load(LevelSummary key) { Legacy4J.LOGGER.error("could not validate symlink", iOException); iconFile = null; } - FaviconTexture icon = FaviconTexture.forWorld(Minecraft.getInstance().getTextureManager(), key.getLevelId()); + + DynamicTexture icon = new DynamicTexture(16, 16, true); + TextureManager textureManager = Minecraft.getInstance().getTextureManager(); + ResourceLocation iconLocation = new ResourceLocation("legacy", "worlds/" + key.getLevelId() + "/icon"); + textureManager.register(iconLocation, icon); + boolean bl = iconFile != null && Files.isRegularFile(iconFile); if (bl) { try (InputStream inputStream = Files.newInputStream(iconFile)) { - icon.upload(NativeImage.read(inputStream)); + NativeImage image = NativeImage.read(inputStream); + icon.setPixels(image); + image.close(); } catch (Throwable throwable) { Legacy4J.LOGGER.error("Invalid icon for world {}", key.getLevelId(), throwable); } } else { - icon.clear(); + icon.setPixels(null); } return icon; } @@ -222,13 +228,13 @@ protected MutableComponent createNarrationMessage() { } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); RenderSystem.enableBlend(); - guiGraphics.blit(iconCache.getUnchecked(summary).textureLocation(), getX() + 5, getY() + 5, 0, 0, 20, 20, 20, 20); + poseStack.blit(iconCache.getUnchecked(summary).textureLocation(), getX() + 5, getY() + 5, 0, 0, 20, 20, 20, 20); RenderSystem.disableBlend(); if (minecraft.options.touchscreen().get().booleanValue() || isHovered) { - guiGraphics.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); boolean hoverIcon = ScreenUtil.isMouseOver(i, j, getX() + 5, getY() + 5, 20, height); ResourceLocation resourceLocation = hoverIcon ? JOIN_HIGHLIGHTED : JOIN; @@ -236,42 +242,42 @@ protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { ResourceLocation resourceLocation3 = hoverIcon ? ERROR_HIGHLIGHTED : ERROR; ResourceLocation resourceLocation4 = hoverIcon ? MARKED_JOIN_HIGHLIGHTED : MARKED_JOIN; if (summary instanceof LevelSummary.SymlinkLevelSummary) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation3, getX(), getY(), 32, 32); - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation4, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation4, getX(), getY(), 32, 32); return; } if (summary.isLocked()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation3, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); if (hoverIcon) { screen.setTooltipForNextRenderPass(minecraft.font.split(WORLD_LOCKED_TOOLTIP, 175)); } } else if (summary.requiresManualConversion()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation3, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); if (hoverIcon) { screen.setTooltipForNextRenderPass(minecraft.font.split(WORLD_REQUIRES_CONVERSION, 175)); } } else if (summary.markVersionInList()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation4, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation4, getX(), getY(), 32, 32); if (summary.askToOpenWorld()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation3, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); if (hoverIcon) { screen.setTooltipForNextRenderPass(ImmutableList.of(FROM_NEWER_TOOLTIP_1.getVisualOrderText(), FROM_NEWER_TOOLTIP_2.getVisualOrderText())); } } else if (!SharedConstants.getCurrentVersion().isStable()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation2, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation2, getX(), getY(), 32, 32); if (hoverIcon) { screen.setTooltipForNextRenderPass(ImmutableList.of(SNAPSHOT_TOOLTIP_1.getVisualOrderText(), SNAPSHOT_TOOLTIP_2.getVisualOrderText())); } } } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation, getX(), getY(), 32, 32); } } } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + 35, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j, true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), this.getX() + 35, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j, true); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java b/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java index d3dab7c5..9107ea44 100644 --- a/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java +++ b/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import org.joml.Math; import wily.legacy.util.Stocker; @@ -17,7 +17,7 @@ public ScrollableRenderer(LegacyScrollRenderer renderer){ scrollRenderer = renderer; } public final LegacyScrollRenderer scrollRenderer; - public void render(GuiGraphics graphics, int x, int y, int width, int height, Runnable scrollable){ + public void render(PoseStack graphics, int x, int y, int width, int height, Runnable scrollable){ graphics.enableScissor(x,y, x + width, y + height); graphics.pose().pushPose(); float s = Math.min(1.0f,(Util.getMillis() - scrollRenderer.lastScroll) / 480f); diff --git a/common/src/main/java/wily/legacy/client/screen/ServerEditScreen.java b/common/src/main/java/wily/legacy/client/screen/ServerEditScreen.java index 02d48ce7..ca981423 100644 --- a/common/src/main/java/wily/legacy/client/screen/ServerEditScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/ServerEditScreen.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.resolver.ServerAddress; @@ -60,9 +60,9 @@ protected void initButtons() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - guiGraphics.drawString(this.font, ipBox.getMessage(), panel.x + 15, panel.y + 73, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + poseStack.drawString(this.font, ipBox.getMessage(), panel.x + 15, panel.y + 73, CommonColor.INVENTORY_GRAY_TEXT.get(),false); } private void updateAddButtonStatus() { diff --git a/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java b/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java index 80cb1256..61715b99 100644 --- a/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java +++ b/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.logging.LogUtils; import com.mojang.realmsclient.RealmsMainScreen; import net.minecraft.ChatFormatting; @@ -13,14 +14,12 @@ import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.ConnectScreen; -import net.minecraft.client.gui.screens.FaviconTexture; import net.minecraft.client.gui.screens.LoadingDotsText; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; @@ -30,6 +29,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.client.server.LanServer; import net.minecraft.client.server.LanServerDetection; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentUtils; @@ -120,9 +120,9 @@ private Component getMultiplayerDisabledReason() { } } } - public static void drawIcon(GuiGraphics guiGraphics, int i, int j, ResourceLocation resourceLocation) { + public static void drawIcon(PoseStack poseStack, int i, int j, ResourceLocation resourceLocation) { RenderSystem.enableBlend(); - guiGraphics.blit(resourceLocation, i + 5, j + 5, 0.0f, 0.0f, 20, 20, 20, 20); + poseStack.blit(resourceLocation, i + 5, j + 5, 0.0f, 0.0f, 20, 20, 20, 20); RenderSystem.disableBlend(); } public void updateServers(){ @@ -138,8 +138,8 @@ public void updateServers(){ addRenderable(new AbstractButton(0,0,270,30,Component.literal(server.name)) { private byte @Nullable [] lastIconBytes; @Override - protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { - super.renderWidget(guiGraphics, mouseX, mouseY, partialTicks); + protected void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) { + super.renderWidget(poseStack, mouseX, mouseY, partialTicks); List list2; Component component2; ResourceLocation resourceLocation; @@ -161,18 +161,18 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo }); } boolean bl2 = !this.isCompatible(); - guiGraphics.drawString(minecraft.font, getMessage(), getX() + 32 + 3, getY() + 3, 0xFFFFFF); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(getX() + 35, getY() + 10,0); - guiGraphics.pose().scale(2/3f,2/3f,2/3f); + poseStack.drawString(minecraft.font, getMessage(), getX() + 32 + 3, getY() + 3, 0xFFFFFF); + poseStack.pose().pushPose(); + poseStack.pose().translate(getX() + 35, getY() + 10,0); + poseStack.pose().scale(2/3f,2/3f,2/3f); List list = minecraft.font.split(server.motd, Math.max(234,minecraft.font.width(server.motd) / 2 + 20)); for (int p = 0; p < Math.min(2,list.size()); ++p) { - ScreenUtil.renderScrollingString(guiGraphics,minecraft.font, list.get(p), 0, minecraft.font.lineHeight * p,234 , 11 + minecraft.font.lineHeight * p, -8355712, false,minecraft.font.width(list.get(p))* 2/3); + ScreenUtil.renderScrollingString(poseStack,minecraft.font, list.get(p), 0, minecraft.font.lineHeight * p,234 , 11 + minecraft.font.lineHeight * p, -8355712, false,minecraft.font.width(list.get(p))* 2/3); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); Component component = bl2 ? server.version.copy().withStyle(ChatFormatting.RED) : server.status; int q = minecraft.font.width(component); - guiGraphics.drawString(minecraft.font, component, getX() + 270 - q - 15 - 2, getY() + 3, -8355712, false); + poseStack.drawString(minecraft.font, component, getX() + 270 - q - 15 - 2, getY() + 3, -8355712, false); if (bl2) { resourceLocation = INCOMPATIBLE; component2 = INCOMPATIBLE_STATUS; @@ -201,7 +201,7 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo component2 = PINGING_STATUS; list2 = Collections.emptyList(); } - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocation, getX() + width - 15, getY() + 3, 10, 8); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation, getX() + width - 15, getY() + 3, 10, 8); byte[] bs = server.getIconBytes(); if (!Arrays.equals(bs, this.lastIconBytes)) { if (this.uploadServerIcon(bs)) { @@ -211,35 +211,35 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo this.updateServerList(); } } - drawIcon(guiGraphics, getX(), getY(), icon.textureLocation()); + drawIcon(poseStack, getX(), getY(), icon.textureLocation()); int s = mouseX - getX(); int t = mouseY - getY(); if (s >= width - 15 && s <= width - 5 && t >= 2 && t <= 10) { - guiGraphics.renderTooltip(minecraft.font,component2, mouseX,mouseY); + poseStack.renderTooltip(minecraft.font,component2, mouseX,mouseY); } else if (s >= width - q - 15 - 2 && s <= width - 15 - 2 && t >= 2 && t <= 10) { - guiGraphics.renderComponentTooltip(minecraft.font,list2, mouseX,mouseY); + poseStack.renderComponentTooltip(minecraft.font,list2, mouseX,mouseY); } if (minecraft.options.touchscreen().get().booleanValue() || isHovered) { - guiGraphics.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); int u = mouseX - getX(); int v = mouseY - getY(); if (u < 32 && u > 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.JOIN_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.JOIN_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.JOIN, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.JOIN, getX(), getY(), 32, 32); } if (index > 0) { if (u < 16 && v < 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.MOVE_UP_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.MOVE_UP_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.MOVE_UP, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.MOVE_UP, getX(), getY(), 32, 32); } } if (index < screen.getServers().size() - 1) { if (u < 16 && v > 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.MOVE_DOWN_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.MOVE_DOWN_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.MOVE_DOWN, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.MOVE_DOWN, getX(), getY(), 32, 32); } } } @@ -269,7 +269,7 @@ private boolean uploadServerIcon(@Nullable byte[] bs) { } return true; } - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { } @Override @@ -358,13 +358,13 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp AbstractButton lanButton; addRenderable(lanButton = new AbstractButton(0,0,270,30,Component.literal(lanServer.getMotd())) { @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - guiGraphics.drawString(minecraft.font, LAN_SERVER_HEADER, getX() + 32 + 3, getY() + 1, 0xFFFFFF, false); - guiGraphics.drawString(minecraft.font, lanServer.getMotd(), getX() + 32 + 3, getY() + 12, -8355712, false); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + poseStack.drawString(minecraft.font, LAN_SERVER_HEADER, getX() + 32 + 3, getY() + 1, 0xFFFFFF, false); + poseStack.drawString(minecraft.font, lanServer.getMotd(), getX() + 32 + 3, getY() + 12, -8355712, false); if (minecraft.options.hideServerAddress) { - guiGraphics.drawString(minecraft.font, HIDDEN_ADDRESS_TEXT, getX() + 32 + 3,getY() + 12 + 11, 0x303030, false); + poseStack.drawString(minecraft.font, HIDDEN_ADDRESS_TEXT, getX() + 32 + 3,getY() + 12 + 11, 0x303030, false); } else { - guiGraphics.drawString(minecraft.font, lanServer.getAddress(), getX() + 32 + 3, getY() + 12 + 11, 0x303030, false); + poseStack.drawString(minecraft.font, lanServer.getAddress(), getX() + 32 + 3, getY() + 12 + 11, 0x303030, false); } } @@ -382,11 +382,11 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp this.minecraft.getNarrator().say(Component.translatable("multiplayer.lan.server_found", Component.empty().append(LAN_SERVER_HEADER).append(CommonComponents.SPACE).append(lanServer.getMotd()))); } }else { - addRenderable(SimpleLayoutRenderable.create(270,30,(r)-> ((guiGraphics, i, j, f) -> { + addRenderable(SimpleLayoutRenderable.create(270,30,(r)-> ((poseStack, i, j, f) -> { int p = r.y + (r.height - minecraft.font.lineHeight) / 2; - guiGraphics.drawString(this.minecraft.font, SCANNING_LABEL, this.minecraft.screen.width / 2 - this.minecraft.font.width(SCANNING_LABEL) / 2, p, 0xFFFFFF, false); + poseStack.drawString(this.minecraft.font, SCANNING_LABEL, this.minecraft.screen.width / 2 - this.minecraft.font.width(SCANNING_LABEL) / 2, p, 0xFFFFFF, false); String string = LoadingDotsText.get(Util.getMillis()); - guiGraphics.drawString(this.minecraft.font, string, this.minecraft.screen.width / 2 - this.minecraft.font.width(string) / 2, p + this.minecraft.font.lineHeight, -8355712, false); + poseStack.drawString(this.minecraft.font, string, this.minecraft.screen.width / 2 - this.minecraft.font.width(string) / 2, p + this.minecraft.font.lineHeight, -8355712, false); }))); } } diff --git a/common/src/main/java/wily/legacy/client/screen/SimpleLayoutRenderable.java b/common/src/main/java/wily/legacy/client/screen/SimpleLayoutRenderable.java index b688e258..825b784a 100644 --- a/common/src/main/java/wily/legacy/client/screen/SimpleLayoutRenderable.java +++ b/common/src/main/java/wily/legacy/client/screen/SimpleLayoutRenderable.java @@ -1,6 +1,6 @@ package wily.legacy.client.screen; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.layouts.LayoutElement; @@ -24,15 +24,15 @@ public SimpleLayoutRenderable(int width, int height){ } public static SimpleLayoutRenderable create(Function simpleRender){ return new SimpleLayoutRenderable() { - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - simpleRender.apply(this).render(guiGraphics,i,j,f); + public void render(PoseStack poseStack, int i, int j, float f) { + simpleRender.apply(this).render(poseStack,i,j,f); } }; } public static SimpleLayoutRenderable create(int width, int height,Function simpleRender){ return new SimpleLayoutRenderable(width,height) { - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - simpleRender.apply(this).render(guiGraphics,i,j,f); + public void render(PoseStack poseStack, int i, int j, float f) { + simpleRender.apply(this).render(poseStack,i,j,f); } }; } diff --git a/common/src/main/java/wily/legacy/client/screen/TabList.java b/common/src/main/java/wily/legacy/client/screen/TabList.java index 1b0983a1..ed185308 100644 --- a/common/src/main/java/wily/legacy/client/screen/TabList.java +++ b/common/src/main/java/wily/legacy/client/screen/TabList.java @@ -1,7 +1,7 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.Tooltip; @@ -81,7 +81,7 @@ public void init(BiConsumer buttonManager, boolean ver } } @Override - public void render(GuiGraphics graphics, int i, int j, float f) { + public void render(PoseStack graphics, int i, int j, float f) { for (int index = 0; index < tabButtons.size(); index++) { LegacyTabButton tabButton = tabButtons.get(index); tabButton.selected = selectedTab == index; diff --git a/common/src/main/java/wily/legacy/client/screen/TickBox.java b/common/src/main/java/wily/legacy/client/screen/TickBox.java index 930b18d7..9ad3c14a 100644 --- a/common/src/main/java/wily/legacy/client/screen/TickBox.java +++ b/common/src/main/java/wily/legacy/client/screen/TickBox.java @@ -1,9 +1,9 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.*; import net.minecraft.client.gui.narration.NarratedElementType; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -48,17 +48,17 @@ public void onPress() { } @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { setAlpha(active ? 1.0F : 0.5F); Minecraft minecraft = Minecraft.getInstance(); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, this.alpha); + poseStack.setColor(1.0f, 1.0f, 1.0f, this.alpha); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(SPRITES[isHoveredOrFocused() ? 1 : 0], this.getX(), this.getY(), 12, 12); - if (selected) LegacyGuiGraphics.of(guiGraphics).blitSprite(TICK, this.getX(), this.getY(), 14, 12); + LegacyGuiGraphics.of(poseStack).blitSprite(SPRITES[isHoveredOrFocused() ? 1 : 0], this.getX(), this.getY(), 12, 12); + if (selected) LegacyGuiGraphics.of(poseStack).blitSprite(TICK, this.getX(), this.getY(), 14, 12); int k = isHoveredOrFocused() ? ScreenUtil.getDefaultTextColor() : CommonColor.INVENTORY_GRAY_TEXT.get(); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, 1.0F); - this.renderString(guiGraphics, minecraft.font, k); + poseStack.setColor(1.0f, 1.0f, 1.0f, 1.0F); + this.renderString(poseStack, minecraft.font, k); } @@ -81,7 +81,7 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp } @Override - public void renderString(GuiGraphics guiGraphics, Font font, int i) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + 14, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), i,isHoveredOrFocused()); + public void renderString(PoseStack poseStack, Font font, int i) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), this.getX() + 14, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), i,isHoveredOrFocused()); } } diff --git a/common/src/main/java/wily/legacy/client/screen/WidgetPanel.java b/common/src/main/java/wily/legacy/client/screen/WidgetPanel.java index 18568f76..3c83ec0b 100644 --- a/common/src/main/java/wily/legacy/client/screen/WidgetPanel.java +++ b/common/src/main/java/wily/legacy/client/screen/WidgetPanel.java @@ -1,8 +1,8 @@ package wily.legacy.client.screen; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; diff --git a/common/src/main/java/wily/legacy/client/screen/WorldMoreOptionsScreen.java b/common/src/main/java/wily/legacy/client/screen/WorldMoreOptionsScreen.java index 2da585b8..323e68b8 100644 --- a/common/src/main/java/wily/legacy/client/screen/WorldMoreOptionsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/WorldMoreOptionsScreen.java @@ -1,10 +1,10 @@ package wily.legacy.client.screen; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.*; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.client.gui.screens.packs.PackSelectionScreen; @@ -50,7 +50,7 @@ public void addControlTooltips(ControlTooltip.Renderer renderer) { public WorldMoreOptionsScreen(CreateWorldScreen parent, Consumer setTrustPlayers) { super(parent,244, 199, Component.translatable("createWorld.tab.more.title")); - renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((guiGraphics, i, j, f) -> guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.enterSeed"),r.x + 1,r.y + 2, CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); + renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((poseStack, i, j, f) -> poseStack.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.enterSeed"),r.x + 1,r.y + 2, CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); EditBox editBox = new EditBox(Minecraft.getInstance().font, 308, 20, 200, 20, Component.translatable("selectWorld.enterSeed")){ protected MutableComponent createNarrationMessage() { return super.createNarrationMessage().append(CommonComponents.NARRATION_SEPARATOR).append(Component.translatable("selectWorld.seedInfo")); @@ -59,7 +59,7 @@ protected MutableComponent createNarrationMessage() { editBox.setValue(parent.getUiState().getSeed()); editBox.setResponder(string -> parent.getUiState().setSeed(editBox.getValue())); renderableVList.addRenderable(editBox); - renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((guiGraphics, i, j, f) -> guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.seedInfo"),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); + renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((poseStack, i, j, f) -> poseStack.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.seedInfo"),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); renderableVList.addRenderable(new TickBox(0,0,parent.getUiState().isGenerateStructures(),b-> Component.translatable("selectWorld.mapFeatures"),b-> Tooltip.create(Component.translatable("selectWorld.mapFeatures.info")),b->parent.getUiState().setGenerateStructures(b.selected))); renderableVList.addRenderable(new TickBox(0,0,parent.getUiState().isBonusChest(),b-> Component.translatable("selectWorld.bonusItems"),b-> null,b->parent.getUiState().setBonusChest(b.selected))); renderableVList.addRenderable(new LegacySliderButton<>(0, 0, 0, 16, s -> s.getDefaultMessage(Component.translatable("selectWorld.mapType"), parent.getUiState().getWorldType().describePreset()), b -> parent.getUiState().getWorldType().isAmplified() ? Tooltip.create(Component.translatable("generator.minecraft.amplified.info")) : null, parent.getUiState().getWorldType(), () -> hasAltDown() ? parent.getUiState().getAltPresetList() : parent.getUiState().getNormalPresetList(), b -> parent.getUiState().setWorldType(b.objectValue))); @@ -70,13 +70,13 @@ protected MutableComponent createNarrationMessage() { }).build(); parent.getUiState().addListener( s->customizeButton.active = !s.isDebug() && s.getPresetEditor() != null); renderableVList.addRenderable(customizeButton); - SimpleLayoutRenderable.create(0,9,r-> ((guiGraphics, i, j, f) -> {})); + SimpleLayoutRenderable.create(0,9,r-> ((poseStack, i, j, f) -> {})); TickBox hostPrivilleges = new TickBox(0,0,parent.getUiState().isAllowCheats(),b->Component.translatable("selectWorld.allowCommands"),b->Tooltip.create(Component.translatable("selectWorld.allowCommands.info")),b->parent.getUiState().setAllowCheats(b.selected)); parent.getUiState().addListener(s-> hostPrivilleges.active = !s.isDebug() && !s.isHardcore()); GameRules gameRules = parent.getUiState().getGameRules(); Pair pair = parent.getDataPackSelectionSettings(parent.getUiState().getSettings().dataConfiguration()); if (pair != null){ - renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((guiGraphics, i, j, f) -> guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.experiments"),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); + renderableVList.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((poseStack, i, j, f) -> poseStack.drawString(Minecraft.getInstance().font, Component.translatable("selectWorld.experiments"),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); PackRepository dataRepository = pair.getSecond(); List selectedExperiments = new ArrayList<>(dataRepository.getSelectedIds()); dataRepository.getAvailablePacks().forEach(p->{ @@ -130,7 +130,7 @@ public void visitInteger(GameRules.Key key, GameRules.Ty integerEdit.setValue(Integer.toString(value.get())); integerEdit.setFilter(value::tryDeserialize); integerEdit.setResponder(string -> value.set(Integer.parseInt(string),null)); - list.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((guiGraphics, i, j, f) -> guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable(key.getDescriptionId()),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); + list.addRenderable(SimpleLayoutRenderable.create(0,9,r-> ((poseStack, i, j, f) -> poseStack.drawString(Minecraft.getInstance().font, Component.translatable(key.getDescriptionId()),r.x + 1,r.y + 2,CommonColor.INVENTORY_GRAY_TEXT.get(),false)))); list.addRenderable(integerEdit); } }); @@ -177,16 +177,16 @@ public WorldMoreOptionsScreen(LoadSaveScreen parent) { } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); if (ScreenUtil.hasTooltipBoxes()) { if (tooltipBoxLabel != null && getChildAt(i,j).map(g-> g instanceof AbstractWidget w ? w.getTooltip() : null).isEmpty() && (!(getFocused() instanceof AbstractWidget w) || w.getTooltip() == null)) { tooltipBoxLabel = null; scrollableRenderer.scrolled.set(0); } - tooltipBox.render(guiGraphics,i,j,f); + tooltipBox.render(poseStack,i,j,f); if (tooltipBoxLabel != null) { - scrollableRenderer.render(guiGraphics,panel.x + panel.width + 3, panel.y + 13,tooltipBox.width - 10, tooltipBox.getHeight() - 44, ()-> tooltipBoxLabel.renderLeftAligned(guiGraphics, panel.x + panel.width + 3, panel.y + 13, 12, 0xFFFFFF)); + scrollableRenderer.render(poseStack,panel.x + panel.width + 3, panel.y + 13,tooltipBox.width - 10, tooltipBox.getHeight() - 44, ()-> tooltipBoxLabel.renderLeftAligned(poseStack, panel.x + panel.width + 3, panel.y + 13, 12, 0xFFFFFF)); } } } diff --git a/common/src/main/java/wily/legacy/client/screen/compat/FriendsServerRenderableList.java b/common/src/main/java/wily/legacy/client/screen/compat/FriendsServerRenderableList.java index 2bb62eb0..4ae2bc98 100644 --- a/common/src/main/java/wily/legacy/client/screen/compat/FriendsServerRenderableList.java +++ b/common/src/main/java/wily/legacy/client/screen/compat/FriendsServerRenderableList.java @@ -2,18 +2,18 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.platform.NativeImage; +import com.mojang.blaze3d.vertex.PoseStack; import io.github.gaming32.worldhost.FriendsListUpdate; import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.mixin.ServerStatusPingerAccessor; import io.github.gaming32.worldhost.versions.Components; import net.minecraft.ChatFormatting; import net.minecraft.Util; +import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.PlayerFaceRenderer; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.gui.screens.FaviconTexture; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.network.chat.Component; @@ -79,25 +79,25 @@ private boolean uploadServerIcon(@Nullable byte[] bs) { } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), this.getX() + 35, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j, true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), this.getX() + 35, this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), j, true); } @Override - protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float f) { - super.renderWidget(guiGraphics, mouseX, mouseY, f); + protected void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float f) { + super.renderWidget(poseStack, mouseX, mouseY, f); updateServerInfo(); byte[] bs = serverData.getIconBytes(); if (!Arrays.equals(bs, this.lastIconBytes)) { if (this.uploadServerIcon(bs)) this.lastIconBytes = bs; else serverData.setIconBytes(null); } - if (serverData.getIconBytes() == null) PlayerFaceRenderer.draw(guiGraphics, minecraft.getSkinManager().getInsecureSkinLocation(profile),getX() + 5, getY() + 5, 20); - else drawIcon(guiGraphics, getX(), getY(),icon.textureLocation()); + if (serverData.getIconBytes() == null) PlayerFaceRenderer.draw(poseStack, minecraft.getSkinManager().getInsecureSkinLocation(profile),getX() + 5, getY() + 5, 20); + else drawIcon(poseStack, getX(), getY(),icon.textureLocation()); if (minecraft.options.touchscreen().get().booleanValue() || isHovered) { - guiGraphics.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); int u = mouseX - getX(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(u < 30 && u > 5 ? LegacySprites.JOIN_HIGHLIGHTED : LegacySprites.JOIN, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(u < 30 && u > 5 ? LegacySprites.JOIN_HIGHLIGHTED : LegacySprites.JOIN, getX(), getY(), 32, 32); } } diff --git a/common/src/main/java/wily/legacy/client/screen/compat/WorldHostFriendsScreen.java b/common/src/main/java/wily/legacy/client/screen/compat/WorldHostFriendsScreen.java index 967dda4e..03c8dc19 100644 --- a/common/src/main/java/wily/legacy/client/screen/compat/WorldHostFriendsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/compat/WorldHostFriendsScreen.java @@ -2,6 +2,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.gui.screen.AddFriendScreen; @@ -10,7 +11,6 @@ import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.PlayerFaceRenderer; @@ -111,14 +111,14 @@ protected void init() { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,panel.getX() + panel.getWidth() - 47, panel.getY() + 9, 32,32); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,panel.getX() + panel.getWidth() - 47, panel.getY() + 9, 32,32); if (friend != null){ - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(1.5f,1.5f,0); - PlayerFaceRenderer.draw(guiGraphics, minecraft.getSkinManager().getInsecureSkinLocation(friend), panel.getX() + panel.getWidth() - 47, panel.getY() + 9, 29); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(1.5f,1.5f,0); + PlayerFaceRenderer.draw(poseStack, minecraft.getSkinManager().getInsecureSkinLocation(friend), panel.getX() + panel.getWidth() - 47, panel.getY() + 9, 29); + poseStack.pose().popPose(); } } @@ -153,14 +153,14 @@ protected void addFriendButtons(Runnable afterButtonsAdd){ skin.get(); renderableVList.addRenderable(new AbstractButton(0, 0, 230, 30, Component.literal(WorldHost.getName(profile))) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) { - super.renderWidget(guiGraphics, i, j, f); - PlayerFaceRenderer.draw(guiGraphics, skin.get(), getX() + 5, getY() + 5, 20); + protected void renderWidget(PoseStack poseStack, int i, int j, float f) { + super.renderWidget(poseStack, i, j, f); + PlayerFaceRenderer.draw(poseStack, skin.get(), getX() + 5, getY() + 5, 20); } @Override - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics, font, this.getMessage(), getX() + 30, this.getY(), getX() + getWidth() - 2, this.getY() + this.getHeight(), j, true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack, font, this.getMessage(), getX() + 30, this.getY(), getX() + getWidth() - 2, this.getY() + this.getHeight(), j, true); } @Override @@ -197,8 +197,8 @@ protected void updateWidgetNarration(NarrationElementOutput narrationElementOutp } @Override - public void renderDefaultBackground(GuiGraphics guiGraphics, int i, int j, float f) { - panel.render(guiGraphics,i,j,f); - guiGraphics.drawString(font,getTitle(),panel.x + 11, panel.y + 8, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) { + panel.render(poseStack,i,j,f); + poseStack.drawString(font,getTitle(),panel.x + 11, panel.y + 8, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } } diff --git a/common/src/main/java/wily/legacy/init/LegacyRegistries.java b/common/src/main/java/wily/legacy/init/LegacyRegistries.java index 5e36a608..5662e3b2 100644 --- a/common/src/main/java/wily/legacy/init/LegacyRegistries.java +++ b/common/src/main/java/wily/legacy/init/LegacyRegistries.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.PushReaction; import wily.legacy.Legacy4J; import wily.legacy.Legacy4JPlatform; diff --git a/common/src/main/java/wily/legacy/mixin/AbstractButtonMixin.java b/common/src/main/java/wily/legacy/mixin/AbstractButtonMixin.java index 523aa9fa..a63cf9a7 100644 --- a/common/src/main/java/wily/legacy/mixin/AbstractButtonMixin.java +++ b/common/src/main/java/wily/legacy/mixin/AbstractButtonMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.network.chat.Component; @@ -36,7 +36,7 @@ protected int renderWidget(int k) { return ScreenUtil.getDefaultTextColor(!isHoveredOrFocused() || Util.getMillis() - lastTimePressed <= 150); } @Inject(method = "renderWidget", at = @At("HEAD")) - protected void renderWidget(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + protected void renderWidget(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { alpha = active ? 1 : 0.8f; } @Inject(method = "getTextureY", at = @At("HEAD"), cancellable = true) diff --git a/common/src/main/java/wily/legacy/mixin/AbstractContainerScreenMixin.java b/common/src/main/java/wily/legacy/mixin/AbstractContainerScreenMixin.java index 91a76f1d..8281cdf3 100644 --- a/common/src/main/java/wily/legacy/mixin/AbstractContainerScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/AbstractContainerScreenMixin.java @@ -1,10 +1,10 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenRectangle; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -65,7 +65,7 @@ protected AbstractContainerScreenMixin(Component component) { @Shadow protected abstract void init(); - @ModifyArg(method = "renderLabels", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawString(Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;IIIZ)I"), index = 4) + @ModifyArg(method = "renderLabels", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;draw(Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/lang/String;FFI)I"), index = 4) private int renderLabels(int i){ return CommonColor.INVENTORY_GRAY_TEXT.get(); } @@ -87,13 +87,13 @@ private void mouseClicked(double d, double e, int i, CallbackInfoReturnable cir) { + public void render(PoseStack poseStack, ToastComponent toastComponent, long l, CallbackInfoReturnable cir) { Component holdToView = Component.translatable("legacy.menu.advancements.toast",(ControlType.getActiveType().isKbm() ? ControlTooltip.getKeyIcon(InputConstants.KEY_I) : ControllerBinding.UP_BUTTON.bindingState.getIcon()).getComponent()); Font font= Minecraft.getInstance().font; DisplayInfo displayInfo = this.advancement.getDisplay(); width = 82 + (displayInfo == null ? 0 : Math.max(font.width(holdToView), Math.max(font.width(displayInfo.getTitle()) * 3/2,font.width(displayInfo.getFrame().getDisplayName())))); - ScreenUtil.renderPointerPanel(guiGraphics,0,0,width(),height()); + ScreenUtil.renderPointerPanel(poseStack,0,0,width(),height()); if (displayInfo != null) { int i = displayInfo.getFrame() == FrameType.CHALLENGE ? 0xFF88FF : 0xFFFF00; - if (l < 1500L) guiGraphics.drawString(font, displayInfo.getFrame().getDisplayName(),(width() - font.width(displayInfo.getFrame().getDisplayName())) / 2, height() - 18, i | Mth.floor(Mth.clamp((float)(1500L - l) / 300.0f, 0.0f, 1.0f) * 255.0f) << 24 | 0x4000000); - else guiGraphics.drawString(font, holdToView,(width() - font.width(holdToView)) / 2, height() - 18, 0xFFFFFF | Mth.floor(Mth.clamp((float)(l - 1500L) / 300.0f, 0.0f, 1.0f) * 252.0f) << 24 | 0x4000000); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate((width() - font.width(displayInfo.getTitle()) * 1.5f) / 2,10,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - guiGraphics.drawString(font, displayInfo.getTitle(), 0, 0, -1); - guiGraphics.pose().popPose(); + if (l < 1500L) poseStack.drawString(font, displayInfo.getFrame().getDisplayName(),(width() - font.width(displayInfo.getFrame().getDisplayName())) / 2, height() - 18, i | Mth.floor(Mth.clamp((float)(1500L - l) / 300.0f, 0.0f, 1.0f) * 255.0f) << 24 | 0x4000000); + else poseStack.drawString(font, holdToView,(width() - font.width(holdToView)) / 2, height() - 18, 0xFFFFFF | Mth.floor(Mth.clamp((float)(l - 1500L) / 300.0f, 0.0f, 1.0f) * 252.0f) << 24 | 0x4000000); + poseStack.pose().pushPose(); + poseStack.pose().translate((width() - font.width(displayInfo.getTitle()) * 1.5f) / 2,10,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.drawString(font, displayInfo.getTitle(), 0, 0, -1); + poseStack.pose().popPose(); if (!this.playedSound && l > 0L) { this.playedSound = true; @@ -59,9 +59,9 @@ public void render(GuiGraphics guiGraphics, ToastComponent toastComponent, long toastComponent.getMinecraft().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, 1.0f, 1.0f)); } } - if (toastComponent.getMinecraft().player != null) PlayerFaceRenderer.draw(guiGraphics, toastComponent.getMinecraft().player.getSkinTextureLocation(), 7, (height() - 32) / 2, 32); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,width() - 38,(height() - 28) / 2,28,28); - guiGraphics.renderItem(displayInfo.getIcon(), width() - 32, (height() - 16) / 2); + if (toastComponent.getMinecraft().player != null) PlayerFaceRenderer.draw(poseStack, toastComponent.getMinecraft().player.getSkinTextureLocation(), 7, (height() - 32) / 2, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,width() - 38,(height() - 28) / 2,28,28); + poseStack.renderItem(displayInfo.getIcon(), width() - 32, (height() - 16) / 2); cir.setReturnValue((double)l >= 5000.0 * toastComponent.getNotificationDisplayTimeMultiplier() ? Toast.Visibility.HIDE : Toast.Visibility.SHOW); return; } diff --git a/common/src/main/java/wily/legacy/mixin/AnvilScreenMixin.java b/common/src/main/java/wily/legacy/mixin/AnvilScreenMixin.java index 787c448a..95cdb84f 100644 --- a/common/src/main/java/wily/legacy/mixin/AnvilScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/AnvilScreenMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.inventory.AnvilScreen; import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen; @@ -53,9 +53,9 @@ public void repositionElements() { } @Inject(method = "renderLabels",at = @At("HEAD"), cancellable = true) - public void renderLabels(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) { + public void renderLabels(PoseStack poseStack, int i, int j, CallbackInfo ci) { ci.cancel(); - super.renderLabels(guiGraphics, i, j); + super.renderLabels(poseStack, i, j); int k = this.menu.getCost(); if (k > 0) { Component component; @@ -73,7 +73,7 @@ public void renderLabels(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) } if (component != null) { int m = this.imageWidth - 8 - this.font.width(component) - 2; - guiGraphics.drawString(this.font, component, m, 90, l); + poseStack.drawString(this.font, component, m, 90, l); } } } @@ -93,29 +93,29 @@ public void subInit(CallbackInfo ci) { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 13.5, topPos + 9.5,0f); - guiGraphics.pose().scale(2.5f,2.5f,2.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ANVIL_HAMMER,0,0,15,15); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 53, topPos + 60,0f); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.COMBINER_PLUS,0,0,13,13); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 122, topPos + 59,0f); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ARROW,0,0,22,15); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 13.5, topPos + 9.5,0f); + poseStack.pose().scale(2.5f,2.5f,2.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ANVIL_HAMMER,0,0,15,15); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 53, topPos + 60,0f); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.COMBINER_PLUS,0,0,13,13); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 122, topPos + 59,0f); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ARROW,0,0,22,15); if ((this.menu.getSlot(0).hasItem() || this.menu.getSlot(1).hasItem()) && !this.menu.getSlot(this.menu.getResultSlot()).hasItem()) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ERROR_CROSS, 4, 0, 15, 15); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ERROR_CROSS, 4, 0, 15, 15); + poseStack.pose().popPose(); } } diff --git a/common/src/main/java/wily/legacy/mixin/BeaconScreenMixin.java b/common/src/main/java/wily/legacy/mixin/BeaconScreenMixin.java index 28f34d9f..60d82247 100644 --- a/common/src/main/java/wily/legacy/mixin/BeaconScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/BeaconScreenMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.BeaconScreen; @@ -49,7 +49,7 @@ private BeaconScreen self(){ } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "init",at = @At("HEAD"), cancellable = true) @@ -61,9 +61,9 @@ public void init(CallbackInfo ci) { this.beaconButtons.clear(); this.addBeaconButton(self().new BeaconConfirmButton(this.leftPos + 202, this.topPos + 127){ @Override - protected void renderIcon(GuiGraphics guiGraphics) { + protected void renderIcon(PoseStack poseStack) { RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BEACON_CONFIRM,this.getX() + 2, this.getY() + 2, 18, 18); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BEACON_CONFIRM,this.getX() + 2, this.getY() + 2, 18, 18); RenderSystem.disableBlend(); } }); @@ -98,29 +98,29 @@ protected void renderIcon(GuiGraphics guiGraphics) { } @Inject(method = "renderLabels",at = @At("HEAD"), cancellable = true) - public void renderLabels(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) { + public void renderLabels(PoseStack poseStack, int i, int j, CallbackInfo ci) { ci.cancel(); - guiGraphics.drawString(this.font, PRIMARY_EFFECT_LABEL, 9 + (121 - font.width(PRIMARY_EFFECT_LABEL)) /2, 13, 0x383838, false); - guiGraphics.drawString(this.font, SECONDARY_EFFECT_LABEL, 133 + (121 - font.width(SECONDARY_EFFECT_LABEL)) /2, 13, 0x383838, false); + poseStack.drawString(this.font, PRIMARY_EFFECT_LABEL, 9 + (121 - font.width(PRIMARY_EFFECT_LABEL)) /2, 13, 0x383838, false); + poseStack.drawString(this.font, SECONDARY_EFFECT_LABEL, 133 + (121 - font.width(SECONDARY_EFFECT_LABEL)) /2, 13, 0x383838, false); } private static final Item[] DISPLAY_ITEMS = new Item[]{Items.NETHERITE_INGOT,Items.EMERALD,Items.DIAMOND,Items.GOLD_INGOT,Items.IRON_INGOT}; @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 8,topPos + 9,120, 115); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 132,topPos + 9,120, 115); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BEACON_1,leftPos + 32, topPos + 39, 20, 19); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BEACON_2,leftPos + 32, topPos + 69, 20, 19); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BEACON_3,leftPos + 32, topPos + 97, 20, 19); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BEACON_4,leftPos + 180, topPos + 42, 20, 19); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 15, topPos + 129, 100.0F); - guiGraphics.pose().scale(7/6f, 7/6f,7/6f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 8,topPos + 9,120, 115); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 132,topPos + 9,120, 115); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BEACON_1,leftPos + 32, topPos + 39, 20, 19); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BEACON_2,leftPos + 32, topPos + 69, 20, 19); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BEACON_3,leftPos + 32, topPos + 97, 20, 19); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BEACON_4,leftPos + 180, topPos + 42, 20, 19); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 15, topPos + 129, 100.0F); + poseStack.pose().scale(7/6f, 7/6f,7/6f); for (Item displayItem : DISPLAY_ITEMS) { - guiGraphics.renderItem(new ItemStack(displayItem), 0, 0); - guiGraphics.pose().translate(18,0,0); + poseStack.renderItem(new ItemStack(displayItem), 0, 0); + poseStack.pose().translate(18,0,0); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } } diff --git a/common/src/main/java/wily/legacy/mixin/BookEditScreenMixin.java b/common/src/main/java/wily/legacy/mixin/BookEditScreenMixin.java index a69c747f..b87f79af 100644 --- a/common/src/main/java/wily/legacy/mixin/BookEditScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/BookEditScreenMixin.java @@ -1,11 +1,11 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.SharedConstants; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.font.TextFieldHelper; -import net.minecraft.client.gui.navigation.CommonInputs; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.BookEditScreen; import net.minecraft.client.gui.screens.inventory.PageButton; @@ -64,9 +64,9 @@ public abstract class BookEditScreenMixin extends Screen implements Controller.E private static final Component EXIT_BOOK_MESSAGE = Component.translatable("legacy.menu.exit_book_message"); @Shadow protected abstract BookEditScreen.DisplayCache getDisplayCache(); - @Shadow protected abstract void renderHighlight(GuiGraphics arg, Rect2i[] args); + @Shadow protected abstract void renderHighlight(PoseStack arg, Rect2i[] args); - @Shadow protected abstract void renderCursor(GuiGraphics arg, BookEditScreen.Pos2i arg2, boolean bl); + @Shadow protected abstract void renderCursor(PoseStack arg, BookEditScreen.Pos2i arg2, boolean bl); @Shadow @Final private static FormattedCharSequence BLACK_CURSOR; @Shadow @Final private static FormattedCharSequence GRAY_CURSOR; @@ -196,7 +196,7 @@ public void init(CallbackInfo ci) { setFocused(panel); this.updateButtonVisibility(); } - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { + public void renderBackground(PoseStack poseStack, int i, int j, float f) { } @Inject(method = "tick", at = @At("RETURN")) @@ -206,31 +206,31 @@ public void tick(CallbackInfo ci) { } @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); - super.render(guiGraphics, i, j, f); + super.render(poseStack, i, j, f); int n; int o; if (this.isSigning) { boolean bl = this.frameTick / 6 % 2 == 0; FormattedCharSequence formattedCharSequence = FormattedCharSequence.composite(FormattedCharSequence.forward(this.title, Style.EMPTY), bl ? BLACK_CURSOR : GRAY_CURSOR); - guiGraphics.drawString(this.font, EDIT_TITLE_LABEL, panel.x + 20, panel.y + 37, 0, false); - guiGraphics.drawString(this.font, formattedCharSequence, panel.x + 20, panel.y + 50, 0, false); - guiGraphics.drawString(this.font, this.ownerText, panel.x + 20, panel.y + 61, 0, false); - guiGraphics.drawWordWrap(this.font, FINALIZE_WARNING_LABEL, panel.x + 20, panel.y + 85, 159, 0); + poseStack.drawString(this.font, EDIT_TITLE_LABEL, panel.x + 20, panel.y + 37, 0, false); + poseStack.drawString(this.font, formattedCharSequence, panel.x + 20, panel.y + 50, 0, false); + poseStack.drawString(this.font, this.ownerText, panel.x + 20, panel.y + 61, 0, false); + poseStack.drawWordWrap(this.font, FINALIZE_WARNING_LABEL, panel.x + 20, panel.y + 85, 159, 0); } else { - guiGraphics.drawString(this.font, this.pageMsg, panel.x + panel.width - 24 - font.width(pageMsg), panel.y + 22, 0, false); + poseStack.drawString(this.font, this.pageMsg, panel.x + panel.width - 24 - font.width(pageMsg), panel.y + 22, 0, false); BookEditScreen.DisplayCache displayCache = this.getDisplayCache(); BookEditScreen.LineInfo[] var15 = displayCache.lines; n = var15.length; for(o = 0; o < n; ++o) { BookEditScreen.LineInfo lineInfo = var15[o]; - guiGraphics.drawString(this.font, lineInfo.asComponent, lineInfo.x, lineInfo.y, -16777216, false); + poseStack.drawString(this.font, lineInfo.asComponent, lineInfo.x, lineInfo.y, -16777216, false); } if (panel.isFocused()) { - this.renderHighlight(guiGraphics, displayCache.selection); - this.renderCursor(guiGraphics, displayCache.cursor, displayCache.cursorAtEnd); + this.renderHighlight(poseStack, displayCache.selection); + this.renderCursor(poseStack, displayCache.cursor, displayCache.cursorAtEnd); } } } diff --git a/common/src/main/java/wily/legacy/mixin/BookViewScreenMixin.java b/common/src/main/java/wily/legacy/mixin/BookViewScreenMixin.java index 908e0c16..65637cc7 100644 --- a/common/src/main/java/wily/legacy/mixin/BookViewScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/BookViewScreenMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.InputConstants; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.BookViewScreen; import net.minecraft.client.gui.screens.inventory.PageButton; @@ -75,12 +75,12 @@ public void init(CallbackInfo ci) { setFocused(panel); this.updateButtonVisibility(); } - public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { + public void renderBackground(PoseStack poseStack, int i, int j, float f) { } @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); - super.render(guiGraphics, i, j, f); + super.render(poseStack, i, j, f); if (this.cachedPage != this.currentPage) { FormattedText formattedText = this.bookAccess.getPage(this.currentPage); @@ -88,15 +88,15 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo this.pageMsg = Component.translatable("book.pageIndicator", this.currentPage + 1, Math.max(this.getNumPages(), 1)); } this.cachedPage = this.currentPage; - guiGraphics.drawString(this.font, this.pageMsg, panel.x + panel.width - 24 - font.width(pageMsg), panel.y + 22, 0, false); + poseStack.drawString(this.font, this.pageMsg, panel.x + panel.width - 24 - font.width(pageMsg), panel.y + 22, 0, false); int n = Math.min(176 / this.font.lineHeight, this.cachedPageComponents.size()); for (int o = 0; o < n; ++o) { FormattedCharSequence formattedCharSequence = this.cachedPageComponents.get(o); - guiGraphics.drawString(this.font, formattedCharSequence, panel.x + 20, panel.y + 37 + o * this.font.lineHeight, 0, false); + poseStack.drawString(this.font, formattedCharSequence, panel.x + 20, panel.y + 37 + o * this.font.lineHeight, 0, false); } Style style = this.getClickedComponentStyleAt(i, j); if (style != null) { - guiGraphics.renderComponentHoverEffect(this.font, style, i, j); + poseStack.renderComponentHoverEffect(this.font, style, i, j); } } @Override diff --git a/common/src/main/java/wily/legacy/mixin/BossHealthOverlayMixin.java b/common/src/main/java/wily/legacy/mixin/BossHealthOverlayMixin.java index 4540a1ab..613b656b 100644 --- a/common/src/main/java/wily/legacy/mixin/BossHealthOverlayMixin.java +++ b/common/src/main/java/wily/legacy/mixin/BossHealthOverlayMixin.java @@ -1,9 +1,9 @@ package wily.legacy.mixin; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.BossHealthOverlay; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -30,7 +30,7 @@ public abstract class BossHealthOverlayMixin { private static final ResourceLocation[] OVERLAY_PROGRESS_SPRITES = new ResourceLocation[]{new ResourceLocation(Legacy4J.MOD_ID,"boss_bar/notched_6_progress"), new ResourceLocation(Legacy4J.MOD_ID,"boss_bar/notched_10_progress"), new ResourceLocation(Legacy4J.MOD_ID,"boss_bar/notched_12_progress"), new ResourceLocation(Legacy4J.MOD_ID,"boss_bar/notched_20_progress")}; @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawString(Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;III)I")) - public int drawString(GuiGraphics graphics, Font font, Component component, int i, int j, int k) { + public int drawString(PoseStack graphics, Font font, Component component, int i, int j, int k) { graphics.pose().pushPose(); graphics.pose().translate((graphics.guiWidth() - font.width(component) * 2/3f) / 2,j,0); graphics.pose().scale(2/3f,2/3f,2/3f); @@ -41,7 +41,7 @@ public int drawString(GuiGraphics graphics, Font font, Component component, int } @Inject(method = "render", at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, CallbackInfo ci) { + public void render(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) { ci.cancel(); return; @@ -51,7 +51,7 @@ public void render(GuiGraphics guiGraphics, CallbackInfo ci) { } @Inject(method = "render", at = @At("RETURN")) - public void renderReturn(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderReturn(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) return; RenderSystem.setShaderColor(1.0f,1.0f,1.0f, 1.0f); RenderSystem.disableBlend(); @@ -60,32 +60,32 @@ public void renderReturn(GuiGraphics guiGraphics, CallbackInfo ci) { public int render(int i) { return 28; } - @Inject(method = "drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;)V", at = @At("HEAD")) - private void drawBar(GuiGraphics guiGraphics, int i, int j, BossEvent bossEvent, CallbackInfo ci) { - guiGraphics.pose().pushPose(); + @Inject(method = "drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;)V", at = @At("HEAD")) + private void drawBar(PoseStack poseStack, int i, int j, BossEvent bossEvent, CallbackInfo ci) { + poseStack.pose().pushPose(); RenderSystem.enableBlend(); - guiGraphics.pose().translate((guiGraphics.guiWidth() - 203) / 2f,j,0); - guiGraphics.pose().scale(0.5f,0.5f,0.5f); + poseStack.pose().translate((poseStack.guiWidth() - 203) / 2f,j,0); + poseStack.pose().scale(0.5f,0.5f,0.5f); } - @Inject(method = "drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;)V", at = @At("RETURN")) - private void drawBarReturn(GuiGraphics guiGraphics, int i, int j, BossEvent bossEvent, CallbackInfo ci) { + @Inject(method = "drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;)V", at = @At("RETURN")) + private void drawBarReturn(PoseStack poseStack, int i, int j, BossEvent bossEvent, CallbackInfo ci) { RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } - @Redirect(method = "drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/BossHealthOverlay;drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;II)V", ordinal = 0)) - private void drawBar(BossHealthOverlay instance, GuiGraphics guiGraphics, int i, int j, BossEvent bossEvent, int k, int l) { - drawBar(guiGraphics,0,0,bossEvent,406,BAR_BACKGROUND_SPRITES,OVERLAY_BACKGROUND_SPRITES); + @Redirect(method = "drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/BossHealthOverlay;drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;II)V", ordinal = 0)) + private void drawBar(BossHealthOverlay instance, PoseStack poseStack, int i, int j, BossEvent bossEvent, int k, int l) { + drawBar(poseStack,0,0,bossEvent,406,BAR_BACKGROUND_SPRITES,OVERLAY_BACKGROUND_SPRITES); } - @Redirect(method = "drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/BossHealthOverlay;drawBar(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/world/BossEvent;II)V",ordinal = 1)) - private void drawBarProgress(BossHealthOverlay instance, GuiGraphics guiGraphics, int i, int j, BossEvent bossEvent, int k, int l) { - guiGraphics.pose().translate(3f,0,0); - drawBar(guiGraphics,0,0,bossEvent, lerpDiscrete(bossEvent.getProgress(), 0, 400),BAR_PROGRESS_SPRITES,OVERLAY_PROGRESS_SPRITES); + @Redirect(method = "drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/BossHealthOverlay;drawBar(Lcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/BossEvent;II)V", ordinal = 1)) + private void drawBarProgress(BossHealthOverlay instance, PoseStack poseStack, int i, int j, BossEvent bossEvent, int k, int l) { + poseStack.pose().translate(3f,0,0); + drawBar(poseStack,0,0,bossEvent, lerpDiscrete(bossEvent.getProgress(), 0, 400),BAR_PROGRESS_SPRITES,OVERLAY_PROGRESS_SPRITES); } - private void drawBar(GuiGraphics guiGraphics, int i, int j, BossEvent bossEvent, int k, ResourceLocation[] resourceLocations, ResourceLocation[] resourceLocations2) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocations[bossEvent.getColor().ordinal()], k <= 400 ? 400 : 406, 15, 0, 0, i, j, k, 15); + private void drawBar(PoseStack poseStack, int i, int j, BossEvent bossEvent, int k, ResourceLocation[] resourceLocations, ResourceLocation[] resourceLocations2) { + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocations[bossEvent.getColor().ordinal()], k <= 400 ? 400 : 406, 15, 0, 0, i, j, k, 15); if (bossEvent.getOverlay() != BossEvent.BossBarOverlay.PROGRESS) { RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(resourceLocations2[bossEvent.getOverlay().ordinal() - 1], k <= 400 ? 400 : 406, 15, 0, 0, i, j, k, 15); + LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocations2[bossEvent.getOverlay().ordinal() - 1], k <= 400 ? 400 : 406, 15, 0, 0, i, j, k, 15); RenderSystem.disableBlend(); } diff --git a/common/src/main/java/wily/legacy/mixin/BrewingStandScreenMixin.java b/common/src/main/java/wily/legacy/mixin/BrewingStandScreenMixin.java index 63887512..3dc06d35 100644 --- a/common/src/main/java/wily/legacy/mixin/BrewingStandScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/BrewingStandScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.BrewingStandScreen; import net.minecraft.network.chat.Component; @@ -43,47 +43,47 @@ public void init(CallbackInfo ci) { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Override - protected void renderLabels(GuiGraphics guiGraphics, int i, int j) { - super.renderLabels(guiGraphics, i, j); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BREWING_COIL_FLAME, 43, 42,51, 33); + protected void renderLabels(PoseStack poseStack, int i, int j) { + super.renderLabels(poseStack, i, j); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BREWING_COIL_FLAME, 43, 42,51, 33); int fuel = this.menu.getFuel(); int n = Mth.clamp((27 * fuel + 20 - 1) / 20, 0, 27); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(65.5f,66, 0f); + poseStack.pose().pushPose(); + poseStack.pose().translate(65.5f,66, 0f); if (n > 0) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(FUEL_LENGTH_SPRITE, 27, 6, 0, 0, 0, 0, n, 6); + LegacyGuiGraphics.of(poseStack).blitSprite(FUEL_LENGTH_SPRITE, 27, 6, 0, 0, 0, 0, n, 6); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 58.5f,topPos + 22.5, 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.BREWING_SLOTS, 0, 0,96, 96); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 58.5f,topPos + 22.5, 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.BREWING_SLOTS, 0, 0,96, 96); + poseStack.pose().popPose(); int o; if ((o = this.menu.getBrewingTicks()) > 0) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 121.5f,topPos + 22.5, 0f); - guiGraphics.pose().scale(0.5f,0.5f,0.5f); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 121.5f,topPos + 22.5, 0f); + poseStack.pose().scale(0.5f,0.5f,0.5f); int p = (int)(84.0f * (1.0f - (float)o / 400.0f)); if (p > 0) - LegacyGuiGraphics.of(guiGraphics).blitSprite(BREW_PROGRESS_SPRITE, 27, 84, 0, 0, 0, 0, 27, p); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 71f,topPos + 21, 0f); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(BREW_PROGRESS_SPRITE, 27, 84, 0, 0, 0, 0, 27, p); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 71f,topPos + 21, 0f); + poseStack.pose().scale(1.5f,1.5f,1.5f); if ((p = BUBBLELENGTHS[o / 2 % 7]) > 0) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(BUBBLES_SPRITE, 12, 29, 0, 29 - p, 0, 29 - p, 12, p); + LegacyGuiGraphics.of(poseStack).blitSprite(BUBBLES_SPRITE, 12, 29, 0, 29 - p, 0, 29 - p, 12, p); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } } } diff --git a/common/src/main/java/wily/legacy/mixin/CartographyTableScreenMixin.java b/common/src/main/java/wily/legacy/mixin/CartographyTableScreenMixin.java index 1963d673..4fae01cb 100644 --- a/common/src/main/java/wily/legacy/mixin/CartographyTableScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/CartographyTableScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.CartographyTableScreen; @@ -100,11 +100,11 @@ public boolean keyPressed(int i, int j, int k) { } - public void renderLabels(GuiGraphics guiGraphics, int i, int j) { - super.renderLabels(guiGraphics, i, j); - guiGraphics.drawString(font,MAP_NAME,10,27,0x383838,false); + public void renderLabels(PoseStack poseStack, int i, int j) { + super.renderLabels(poseStack, i, j); + poseStack.drawString(font,MAP_NAME,10,27,0x383838,false); Component cartographyAction = getCartographyAction(); - if (cartographyAction != null) guiGraphics.drawString(font,cartographyAction,(imageWidth - font.width(cartographyAction)) / 2,130,0x383838,false); + if (cartographyAction != null) poseStack.drawString(font,cartographyAction,(imageWidth - font.width(cartographyAction)) / 2,130,0x383838,false); } @@ -115,25 +115,25 @@ public void repositionElements() { this.name.setValue(string); } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - name.render(guiGraphics, i, j, f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.COMBINER_PLUS,leftPos + 14, topPos + 88,13,13); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + name.render(poseStack, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.COMBINER_PLUS,leftPos + 14, topPos + 88,13,13); ItemStack input2 = menu.getSlot(1).getItem(); boolean bl = input2.is(Items.MAP); boolean bl2 = input2.is(Items.PAPER); boolean bl3 = input2.is(Items.GLASS_PANE); ItemStack input = menu.getSlot(0).getItem(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ARROW,leftPos + 36, topPos + 87,22,15); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ARROW,leftPos + 36, topPos + 87,22,15); if (input.is(Items.FILLED_MAP)) { MapItemSavedData mapItemSavedData = MapItem.getSavedData(MapItem.getMapId(input), this.minecraft.level); if (mapItemSavedData != null && (mapItemSavedData.locked && (bl2 || bl3) || bl2 && mapItemSavedData.scale >= 4)) - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ERROR_CROSS, leftPos + 40, topPos + 87, 15, 15); - LegacyGuiGraphics.of(guiGraphics).blitSprite(bl ? LegacySprites.CARTOGRAPHY_TABLE_COPY : bl2 ? LegacySprites.CARTOGRAPHY_TABLE_ZOOM : bl3 ? LegacySprites.CARTOGRAPHY_TABLE_LOCKED : LegacySprites.CARTOGRAPHY_TABLE_MAP,leftPos + 70, topPos + 61,66,66); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ERROR_CROSS, leftPos + 40, topPos + 87, 15, 15); + LegacyGuiGraphics.of(poseStack).blitSprite(bl ? LegacySprites.CARTOGRAPHY_TABLE_COPY : bl2 ? LegacySprites.CARTOGRAPHY_TABLE_ZOOM : bl3 ? LegacySprites.CARTOGRAPHY_TABLE_LOCKED : LegacySprites.CARTOGRAPHY_TABLE_MAP,leftPos + 70, topPos + 61,66,66); }else{ - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.CARTOGRAPHY_TABLE,leftPos + 70, topPos + 61,66,66); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.CARTOGRAPHY_TABLE,leftPos + 70, topPos + 61,66,66); } - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.ARROW,leftPos + 139, topPos + 87,22,15); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ARROW,leftPos + 139, topPos + 87,22,15); } } diff --git a/common/src/main/java/wily/legacy/mixin/ChatComponentMixin.java b/common/src/main/java/wily/legacy/mixin/ChatComponentMixin.java index a13bef62..257f9f70 100644 --- a/common/src/main/java/wily/legacy/mixin/ChatComponentMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ChatComponentMixin.java @@ -1,8 +1,8 @@ package wily.legacy.mixin; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.client.gui.screens.ChatScreen; import net.minecraft.util.Mth; @@ -34,13 +34,13 @@ private int changeChatBackground(int i) { return CommonColor.CHAT_BACKGROUND.get() + i; } @Inject(method = "render",at = @At(value = "HEAD"), cancellable = true) - private void stopRender(GuiGraphics guiGraphics, int i, int j, int k, CallbackInfo ci) { + private void stopRender(PoseStack poseStack, int i, int j, int k, CallbackInfo ci) { if (minecraft.screen != null && !isChatFocused()) ci.cancel(); } @Inject(method = "render",at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", shift = At.Shift.AFTER, ordinal = 0)) - private void changeRenderY(GuiGraphics guiGraphics, int i, int j, int k, CallbackInfo ci) { + private void changeRenderY(PoseStack poseStack, int i, int j, int k, CallbackInfo ci) { RenderSystem.setShaderColor(1.0f,1.0f,1.0f,1.0f); - guiGraphics.pose().translate(0.0F, ScreenUtil.getHUDDistance() - 42,0.0F); + poseStack.pose().translate(0.0F, ScreenUtil.getHUDDistance() - 42,0.0F); } @Inject(method = "screenToChatY",at = @At("HEAD"), cancellable = true) private void screenToChatY(double d, CallbackInfoReturnable cir) { diff --git a/common/src/main/java/wily/legacy/mixin/ChatScreenMixin.java b/common/src/main/java/wily/legacy/mixin/ChatScreenMixin.java index 91bd57aa..a59c555e 100644 --- a/common/src/main/java/wily/legacy/mixin/ChatScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ChatScreenMixin.java @@ -1,9 +1,9 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.CommandSuggestions; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.ChatScreen; @@ -69,14 +69,14 @@ private boolean keyPressed(ChatScreen instance, String string, boolean bl, int i return true; } @Redirect(method = "render",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/CommandSuggestions;render(Lnet/minecraft/client/gui/GuiGraphics;II)V")) - private void render(CommandSuggestions instance, GuiGraphics guiGraphics, int i, int j){ - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(0,(int)(ScreenUtil.getHUDDistance() - 56),200); - instance.render(guiGraphics,i,j); - guiGraphics.pose().popPose(); + private void render(CommandSuggestions instance, PoseStack poseStack, int i, int j){ + poseStack.pose().pushPose(); + poseStack.pose().translate(0,(int)(ScreenUtil.getHUDDistance() - 56),200); + instance.render(poseStack,i,j); + poseStack.pose().popPose(); } @Redirect(method = "render",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;fill(IIIII)V")) - private void render(GuiGraphics instance, int i, int j, int k, int l, int m){ + private void render(PoseStack instance, int i, int j, int k, int l, int m){ } diff --git a/common/src/main/java/wily/legacy/mixin/ClientPacketListenerMixin.java b/common/src/main/java/wily/legacy/mixin/ClientPacketListenerMixin.java index 8f8b2ce0..ba00f715 100644 --- a/common/src/main/java/wily/legacy/mixin/ClientPacketListenerMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ClientPacketListenerMixin.java @@ -1,9 +1,9 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.ReceivingLevelScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.*; @@ -43,9 +43,9 @@ public void handleRespawn(ClientboundRespawnPacket clientboundRespawnPacket, Cal Component respawn = Component.translatable("menu.respawning"); minecraft.setScreen(new ReceivingLevelScreen(){ @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - Legacy4JClient.legacyLoadingScreen.prepareRender(minecraft,guiGraphics.guiWidth(),guiGraphics.guiHeight(),respawn,null,0,true); - Legacy4JClient.legacyLoadingScreen.render(guiGraphics, i, j, f); + public void render(PoseStack poseStack, int i, int j, float f) { + Legacy4JClient.legacyLoadingScreen.prepareRender(minecraft,poseStack.guiWidth(),poseStack.guiHeight(),respawn,null,0,true); + Legacy4JClient.legacyLoadingScreen.render(poseStack, i, j, f); } }); } diff --git a/common/src/main/java/wily/legacy/mixin/ContainerScreenMixin.java b/common/src/main/java/wily/legacy/mixin/ContainerScreenMixin.java index 367b5a90..59a48c83 100644 --- a/common/src/main/java/wily/legacy/mixin/ContainerScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ContainerScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.inventory.*; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; @@ -23,7 +23,7 @@ public ContainerScreenMixin(AbstractContainerMenu abstractContainerMenu, Invento super(abstractContainerMenu, inventory, component); } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } public void init() { int k = ((menu instanceof ChestMenu m ? m.getRowCount() : menu instanceof HopperMenu ? 1 : 3) - 3) * 21; @@ -38,8 +38,8 @@ public void init() { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); } } diff --git a/common/src/main/java/wily/legacy/mixin/CraftingScreenMixin.java b/common/src/main/java/wily/legacy/mixin/CraftingScreenMixin.java index e487557d..7e4b4892 100644 --- a/common/src/main/java/wily/legacy/mixin/CraftingScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/CraftingScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.inventory.*; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; @@ -36,7 +36,7 @@ public CraftingScreenMixin(CraftingMenu abstractContainerMenu, Inventory invento super(abstractContainerMenu, inventory, component); } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "init",at = @At("HEAD"), cancellable = true) public void init(CallbackInfo ci) { @@ -65,14 +65,14 @@ public void init(CallbackInfo ci) { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 105,topPos + 43,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(ARROW,0,0,22,15); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 105,topPos + 43,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(ARROW,0,0,22,15); + poseStack.pose().popPose(); if (!recipeBookComponent.isVisible() && recipeButton != null && !recipeButton.isHovered()) recipeButton.setFocused(false); } diff --git a/common/src/main/java/wily/legacy/mixin/CreateWorldScreenMixin.java b/common/src/main/java/wily/legacy/mixin/CreateWorldScreenMixin.java index 521b251d..dd64e2ca 100644 --- a/common/src/main/java/wily/legacy/mixin/CreateWorldScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/CreateWorldScreenMixin.java @@ -1,10 +1,10 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.Lifecycle; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.Renderable; @@ -146,12 +146,12 @@ public boolean mouseScrolled(double d, double e, double f) { if (resourcePackSelector.scrollableRenderer.mouseScrolled(f)) return true; return super.mouseScrolled(d, e, f); } - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); - resourcePackSelector.renderTooltipBox(guiGraphics,panel); + public void render(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack,false); + resourcePackSelector.renderTooltipBox(poseStack,panel); for (Renderable renderable : this.renderables) - renderable.render(guiGraphics, i, j, f); - guiGraphics.drawString(font,NAME_LABEL, panel.x + 14, panel.y + 15, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + renderable.render(poseStack, i, j, f); + poseStack.drawString(font,NAME_LABEL, panel.x + 14, panel.y + 15, CommonColor.INVENTORY_GRAY_TEXT.get(),false); } @Override diff --git a/common/src/main/java/wily/legacy/mixin/CyclingSlotBackgroundMixin.java b/common/src/main/java/wily/legacy/mixin/CyclingSlotBackgroundMixin.java index e7522553..6833cb7d 100644 --- a/common/src/main/java/wily/legacy/mixin/CyclingSlotBackgroundMixin.java +++ b/common/src/main/java/wily/legacy/mixin/CyclingSlotBackgroundMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.CyclingSlotBackground; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -18,15 +18,15 @@ @Mixin(CyclingSlotBackground.class) public class CyclingSlotBackgroundMixin { @Inject(method = "renderIcon", at = @At("HEAD"), cancellable = true) - private void renderIcon(Slot slot, ResourceLocation resourceLocation, float f, GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) { + private void renderIcon(Slot slot, ResourceLocation resourceLocation, float f, PoseStack poseStack, int i, int j, CallbackInfo ci) { if (slot instanceof LegacySlotDisplay) ci.cancel(); else return; LegacyIconHolder holder = ScreenUtil.iconHolderRenderer.slotBounds(slot); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(i + slot.x,j + slot.y,0); - guiGraphics.pose().scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); + poseStack.pose().pushPose(); + poseStack.pose().translate(i + slot.x,j + slot.y,0); + poseStack.pose().scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); TextureAtlasSprite textureAtlasSprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(resourceLocation); - guiGraphics.blit(0, 0, 0, 16, 16, textureAtlasSprite, 1.0f, 1.0f, 1.0f, f); - guiGraphics.pose().popPose(); + poseStack.blit(0, 0, 0, 16, 16, textureAtlasSprite, 1.0f, 1.0f, 1.0f, f); + poseStack.pose().popPose(); } } diff --git a/common/src/main/java/wily/legacy/mixin/DeathScreenMixin.java b/common/src/main/java/wily/legacy/mixin/DeathScreenMixin.java index 7ac01125..2d8961c9 100644 --- a/common/src/main/java/wily/legacy/mixin/DeathScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/DeathScreenMixin.java @@ -1,8 +1,8 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Renderable; @@ -78,25 +78,25 @@ private void handleExitToTitleScreen(CallbackInfo ci) { } } @Inject(method = "render", at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); float alpha = Math.min((Util.getMillis() - screenInit) / 1200f,1.0f); - guiGraphics.fill(0, 0, guiGraphics.guiWidth(),guiGraphics.guiHeight(), 3672076 | Mth.ceil(alpha * 160.0F) << 24); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate((this.width - font.width(title) * 2) / 2f, height / 4f + 20,0); - guiGraphics.pose().scale(2.0F, 2.0F, 2.0F); - ScreenUtil.drawOutlinedString(guiGraphics,this.font, this.title, 0,0, 16777215,0,0.5f); - guiGraphics.pose().popPose(); + poseStack.fill(0, 0, poseStack.guiWidth(),poseStack.guiHeight(), 3672076 | Mth.ceil(alpha * 160.0F) << 24); + poseStack.pose().pushPose(); + poseStack.pose().translate((this.width - font.width(title) * 2) / 2f, height / 4f + 20,0); + poseStack.pose().scale(2.0F, 2.0F, 2.0F); + ScreenUtil.drawOutlinedString(poseStack,this.font, this.title, 0,0, 16777215,0,0.5f); + poseStack.pose().popPose(); if (this.causeOfDeath != null) { - guiGraphics.drawCenteredString(this.font, this.causeOfDeath, this.width / 2, height / 2 - 24, 16777215); - if (j > height / 2 - 24 && j < height / 2 - 15) guiGraphics.renderComponentHoverEffect(this.font, this.getClickedComponentStyleAt(i), i, j); + poseStack.drawCenteredString(this.font, this.causeOfDeath, this.width / 2, height / 2 - 24, 16777215); + if (j > height / 2 - 24 && j < height / 2 - 15) poseStack.renderComponentHoverEffect(this.font, this.getClickedComponentStyleAt(i), i, j); } if (this.exitToTitleButton != null && this.minecraft.getReportingContext().hasDraftReport()) { - guiGraphics.blit(AbstractWidget.WIDGETS_LOCATION, this.exitToTitleButton.getX() + this.exitToTitleButton.getWidth() - 17, this.exitToTitleButton.getY() + 3, 182, 24, 15, 15); + poseStack.blit(AbstractWidget.WIDGETS_LOCATION, this.exitToTitleButton.getX() + this.exitToTitleButton.getWidth() - 17, this.exitToTitleButton.getY() + 3, 182, 24, 15, 15); } for (Renderable renderable : this.renderables) - renderable.render(guiGraphics, i, j, f); + renderable.render(poseStack, i, j, f); } } diff --git a/common/src/main/java/wily/legacy/mixin/EditBoxMixin.java b/common/src/main/java/wily/legacy/mixin/EditBoxMixin.java index 01284aa5..10d16502 100644 --- a/common/src/main/java/wily/legacy/mixin/EditBoxMixin.java +++ b/common/src/main/java/wily/legacy/mixin/EditBoxMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.Screen; @@ -43,13 +43,13 @@ private void onClick(double d, double e, CallbackInfo ci){ } @Redirect(method = "renderWidget", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;fill(IIIII)V")) - private void renderWidget(GuiGraphics instance, int i, int j, int k, int l, int m){ + private void renderWidget(PoseStack instance, int i, int j, int k, int l, int m){ } @Inject(method = "renderWidget", at = @At("HEAD")) - private void renderWidget(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci){ + private void renderWidget(PoseStack poseStack, int i, int j, float f, CallbackInfo ci){ if (isBordered()) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TEXT_FIELD, getX(), getY(), getWidth(), getHeight()); - if (isHoveredOrFocused()) LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.HIGHLIGHTED_TEXT_FIELD, getX() - 1, getY() - 1, getWidth() + 2, getHeight() + 2); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.TEXT_FIELD, getX(), getY(), getWidth(), getHeight()); + if (isHoveredOrFocused()) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.HIGHLIGHTED_TEXT_FIELD, getX() - 1, getY() - 1, getWidth() + 2, getHeight() + 2); } } } diff --git a/common/src/main/java/wily/legacy/mixin/EffectRenderingInventoryScreenMixin.java b/common/src/main/java/wily/legacy/mixin/EffectRenderingInventoryScreenMixin.java index 29928b06..32b44328 100644 --- a/common/src/main/java/wily/legacy/mixin/EffectRenderingInventoryScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/EffectRenderingInventoryScreenMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; import com.google.common.collect.Ordering; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; @@ -32,9 +32,9 @@ public EffectRenderingInventoryScreenMixin(AbstractContainerMenu abstractContain } @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); - super.render(guiGraphics, i, j, f); + super.render(poseStack, i, j, f); int x = this.leftPos + this.imageWidth + 3; int l = this.width - x; Collection collection = this.minecraft.player.getActiveEffects(); @@ -49,12 +49,12 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo List iterable = Ordering.natural().sortedCopy(collection); int y = topPos + imageHeight - 28; for (MobEffectInstance mobEffectInstance : iterable) { - ScreenUtil.renderPointerPanel(guiGraphics,x,y,bl ? 129 : 28, 28); + ScreenUtil.renderPointerPanel(poseStack,x,y,bl ? 129 : 28, 28); if (bl) { - guiGraphics.drawString(this.font, this.getEffectName(mobEffectInstance), x + 25, y + 7, 0xFFFFFF); - guiGraphics.drawString(this.font, MobEffectUtil.formatDuration(mobEffectInstance, 1.0f), x + 25, y + 17, 0x7F7F7F); + poseStack.drawString(this.font, this.getEffectName(mobEffectInstance), x + 25, y + 7, 0xFFFFFF); + poseStack.drawString(this.font, MobEffectUtil.formatDuration(mobEffectInstance, 1.0f), x + 25, y + 17, 0x7F7F7F); } - guiGraphics.blit(x + (bl ? 3 : 5), y + 5, 0, 18, 18, minecraft.getMobEffectTextures().get(mobEffectInstance.getEffect())); + poseStack.blit(x + (bl ? 3 : 5), y + 5, 0, 18, 18, minecraft.getMobEffectTextures().get(mobEffectInstance.getEffect())); y -= m; } if (!bl && i >= x && i <= x + 28) { @@ -68,7 +68,7 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo } if (mobEffectInstance != null) { List list = List.of(this.getEffectName(mobEffectInstance), MobEffectUtil.formatDuration(mobEffectInstance, 1.0f)); - guiGraphics.renderTooltip(this.font, list, Optional.empty(), i, j); + poseStack.renderTooltip(this.font, list, Optional.empty(), i, j); } } diff --git a/common/src/main/java/wily/legacy/mixin/EnchantmentScreenMixin.java b/common/src/main/java/wily/legacy/mixin/EnchantmentScreenMixin.java index 11e97b75..373214c5 100644 --- a/common/src/main/java/wily/legacy/mixin/EnchantmentScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/EnchantmentScreenMixin.java @@ -1,8 +1,8 @@ package wily.legacy.mixin; import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.EnchantmentNames; import net.minecraft.client.gui.screens.inventory.EnchantmentScreen; @@ -37,7 +37,7 @@ public abstract class EnchantmentScreenMixin extends AbstractContainerScreen cir) { @@ -76,24 +76,24 @@ public void mouseClicked(double d, double e, int i, CallbackInfoReturnable= n + 1 && this.minecraft.player.experienceLevel >= enchantCost || this.minecraft.player.getAbilities().instabuild)) { - guiGraphics.drawWordWrap(this.font, formattedText, 24, 3, r, (s & 0xFEFEFE) >> 1); + poseStack.drawWordWrap(this.font, formattedText, 24, 3, r, (s & 0xFEFEFE) >> 1); s = 4226832; } else { double t = i - (leftPos + 80.5); double u = j - (topPos + 23.5 + 21 * n); if (t >= 0 && u >= 0 && t < 120 && u < 21) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(ENCHANTMENT_BUTTON_SELECTED, 0, 0, 120, 21); + LegacyGuiGraphics.of(poseStack).blitSprite(ENCHANTMENT_BUTTON_SELECTED, 0, 0, 120, 21); s = 0xFFFF80; } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(ENCHANTMENT_BUTTON_ACTIVE, 0, 0, 120, 21); + LegacyGuiGraphics.of(poseStack).blitSprite(ENCHANTMENT_BUTTON_ACTIVE, 0, 0, 120, 21); } - LegacyGuiGraphics.of(guiGraphics).blitSprite(ENABLED_LEVEL_SPRITES[n], -1, -1, 24, 24); - guiGraphics.drawWordWrap(this.font, formattedText, 24, 3, r, s); + LegacyGuiGraphics.of(poseStack).blitSprite(ENABLED_LEVEL_SPRITES[n], -1, -1, 24, 24); + poseStack.drawWordWrap(this.font, formattedText, 24, 3, r, s); s = 8453920; } - guiGraphics.drawString(this.font, string, 120 - this.font.width(string), 12, s); + poseStack.drawString(this.font, string, 120 - this.font.width(string), 12, s); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); f = this.minecraft.getFrameTime(); - super.render(guiGraphics, i, j, f); - this.renderTooltip(guiGraphics, i, j); + super.render(poseStack, i, j, f); + this.renderTooltip(poseStack, i, j); boolean bl = this.minecraft.player.getAbilities().instabuild; int k = this.menu.getGoldCount(); for (int l = 0; l < 3; ++l) { @@ -149,7 +149,7 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo list.add(mutableComponent2.withStyle(ChatFormatting.GRAY)); } } - guiGraphics.renderComponentTooltip(this.font, list, i, j); + poseStack.renderComponentTooltip(this.font, list, i, j); break; } } diff --git a/common/src/main/java/wily/legacy/mixin/GameRendererMixin.java b/common/src/main/java/wily/legacy/mixin/GameRendererMixin.java index 6daeca81..48a00816 100644 --- a/common/src/main/java/wily/legacy/mixin/GameRendererMixin.java +++ b/common/src/main/java/wily/legacy/mixin/GameRendererMixin.java @@ -6,7 +6,6 @@ import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastComponent; import net.minecraft.client.renderer.GameRenderer; @@ -53,7 +52,7 @@ public abstract class GameRendererMixin { @Shadow private boolean renderHand; @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;flush()V")) - private void render(GuiGraphics graphics, float f){ + private void render(PoseStack graphics, float f){ if (!Legacy4JClient.isGameLoadFinished) return; LegacyTip tip = LegacyTipManager.getActualTip(); if (!LegacyTipManager.tips.isEmpty() || tip != null) { @@ -87,8 +86,8 @@ private void render(GuiGraphics graphics, float f){ graphics.flush(); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;render(Lnet/minecraft/client/gui/GuiGraphics;F)V")) - private void render(Gui instance, GuiGraphics guiGraphics, float f){ - if (((LegacyOptions)minecraft.options).displayHUD().get()) instance.render(guiGraphics,f); + private void render(Gui instance, PoseStack poseStack, float f){ + if (((LegacyOptions)minecraft.options).displayHUD().get()) instance.render(poseStack,f); } @Inject(method = "bobView", at = @At("RETURN")) private void bobView(PoseStack poseStack, float f, CallbackInfo ci){ diff --git a/common/src/main/java/wily/legacy/mixin/GrindstoneScreenMixin.java b/common/src/main/java/wily/legacy/mixin/GrindstoneScreenMixin.java index 56547d5c..c784a410 100644 --- a/common/src/main/java/wily/legacy/mixin/GrindstoneScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/GrindstoneScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.GrindstoneScreen; import net.minecraft.network.chat.Component; @@ -35,19 +35,19 @@ protected void init() { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos, imageWidth,imageHeight); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 85,topPos + 50,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(ARROW,0,0,22,15); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos, imageWidth,imageHeight); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 85,topPos + 50,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + LegacyGuiGraphics.of(poseStack).blitSprite(ARROW,0,0,22,15); if ((this.menu.getSlot(0).hasItem() || this.menu.getSlot(1).hasItem()) && !this.menu.getSlot(2).hasItem()) - LegacyGuiGraphics.of(guiGraphics).blitSprite(ERROR_CROSS, 2, 0, 15, 15); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(ERROR_CROSS, 2, 0, 15, 15); + poseStack.pose().popPose(); } } diff --git a/common/src/main/java/wily/legacy/mixin/GuiGraphicsMixin.java b/common/src/main/java/wily/legacy/mixin/GuiGraphicsMixin.java index 51dc9467..e3876291 100644 --- a/common/src/main/java/wily/legacy/mixin/GuiGraphicsMixin.java +++ b/common/src/main/java/wily/legacy/mixin/GuiGraphicsMixin.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; @@ -28,11 +27,11 @@ import java.util.List; -@Mixin(GuiGraphics.class) +@Mixin(GuiComponent.class) public abstract class GuiGraphicsMixin implements LegacyGuiGraphics { @Override - public GuiGraphics self() { - return (GuiGraphics) (Object) this; + public PoseStack self() { + return (PoseStack) (Object) this; } @Shadow @Final private PoseStack pose; @@ -84,7 +83,7 @@ private Vector2ic renderTooltipInternal(ClientTooltipPositioner instance, int gu return instance.positionTooltip(guiWidth(),guiHeight,x,y, (int) (width * ScreenUtil.getTextScale()), (int) (height * ScreenUtil.getTextScale())); } @Redirect(method = "renderTooltipInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent;renderImage(Lnet/minecraft/client/gui/Font;IILnet/minecraft/client/gui/GuiGraphics;)V")) - private void renderTooltipInternal(ClientTooltipComponent instance, Font font, int i, int j, GuiGraphics guiGraphics){ + private void renderTooltipInternal(ClientTooltipComponent instance, Font font, int i, int j, PoseStack guiGraphics){ instance.renderImage(font, (int)(i / ScreenUtil.getTextScale()),(int)(j / ScreenUtil.getTextScale()),guiGraphics); } @Redirect(method = "renderTooltipInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent;renderText(Lnet/minecraft/client/gui/Font;IILorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;)V")) diff --git a/common/src/main/java/wily/legacy/mixin/GuiMixin.java b/common/src/main/java/wily/legacy/mixin/GuiMixin.java index 190f5a65..36f8c766 100644 --- a/common/src/main/java/wily/legacy/mixin/GuiMixin.java +++ b/common/src/main/java/wily/legacy/mixin/GuiMixin.java @@ -3,11 +3,11 @@ import com.google.common.collect.Ordering; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.MobEffectTextureManager; @@ -59,45 +59,45 @@ public abstract class GuiMixin implements ControlTooltip.Event { @Shadow protected abstract Player getCameraPlayer(); - @Shadow public abstract void render(GuiGraphics guiGraphics, float f); + @Shadow public abstract void render(PoseStack poseStack, float f); @Redirect(method = "renderSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getPopTime()I")) public int renderSlot(ItemStack instance) { return 0; } @Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true) - public void renderVignette(GuiGraphics guiGraphics, Entity entity, CallbackInfo ci) { + public void renderVignette(PoseStack poseStack, Entity entity, CallbackInfo ci) { if (minecraft.screen != null || !((LegacyOptions)minecraft.options).vignette().get()) ci.cancel(); } @Inject(method = "renderCrosshair", at = @At("HEAD"), cancellable = true) - public void renderCrosshair(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderCrosshair(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) { ci.cancel(); return; } - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(guiGraphics.guiWidth()/2f,guiGraphics.guiHeight()/2f,0); - ScreenUtil.applyHUDScale(guiGraphics); - guiGraphics.pose().translate(-guiGraphics.guiWidth()/2,-guiGraphics.guiHeight()/2,0); + poseStack.pose().pushPose(); + poseStack.pose().translate(poseStack.guiWidth()/2f,poseStack.guiHeight()/2f,0); + ScreenUtil.applyHUDScale(poseStack); + poseStack.pose().translate(-poseStack.guiWidth()/2,-poseStack.guiHeight()/2,0); } @Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFuncSeparate(Lcom/mojang/blaze3d/platform/GlStateManager$SourceFactor;Lcom/mojang/blaze3d/platform/GlStateManager$DestFactor;Lcom/mojang/blaze3d/platform/GlStateManager$SourceFactor;Lcom/mojang/blaze3d/platform/GlStateManager$DestFactor;)V")) - public void renderCrosshairBlendFunc(GlStateManager.SourceFactor sourceFactor, GlStateManager.DestFactor destFactor, GlStateManager.SourceFactor sourceFactor2, GlStateManager.DestFactor destFactor2, GuiGraphics guiGraphics) { + public void renderCrosshairBlendFunc(GlStateManager.SourceFactor sourceFactor, GlStateManager.DestFactor destFactor, GlStateManager.SourceFactor sourceFactor2, GlStateManager.DestFactor destFactor2, PoseStack poseStack) { if (((LegacyOptions)minecraft.options).hudOpacity().get() < 1.0) { - guiGraphics.setColor(1.0f, 1.0f, 1.0f, ScreenUtil.getHUDOpacity()); + poseStack.setColor(1.0f, 1.0f, 1.0f, ScreenUtil.getHUDOpacity()); RenderSystem.enableBlend(); } else RenderSystem.blendFuncSeparate(sourceFactor,destFactor,sourceFactor2,destFactor2); } @Inject(method = "renderCrosshair", at = @At("RETURN")) - public void renderCrosshairReturn(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderCrosshairReturn(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) return; - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); - guiGraphics.pose().popPose(); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); + poseStack.pose().popPose(); } @Inject(method = "renderEffects", at = @At("HEAD"), cancellable = true) - public void renderEffects(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderEffects(PoseStack poseStack, CallbackInfo ci) { ci.cancel(); Collection collection = this.minecraft.player.getActiveEffects(); if (minecraft.screen != null || collection.isEmpty()) { @@ -110,7 +110,7 @@ public void renderEffects(GuiGraphics guiGraphics, CallbackInfo ci) { for (MobEffectInstance mobEffectInstance : Ordering.natural().reverse().sortedCopy(collection)) { MobEffect mobEffect = mobEffectInstance.getEffect(); if (!mobEffectInstance.showIcon()) continue; - int k = guiGraphics.guiWidth() - 55; + int k = poseStack.guiWidth() - 55; int l = 18; if (this.minecraft.isDemo()) { l += 15; @@ -122,26 +122,26 @@ public void renderEffects(GuiGraphics guiGraphics, CallbackInfo ci) { l += 24; } float f = 1.0f; - guiGraphics.setColor(1.0f, 1.0f, 1.0f, backAlpha); - ScreenUtil.renderPointerPanel(guiGraphics, k, l, 24, 24); + poseStack.setColor(1.0f, 1.0f, 1.0f, backAlpha); + ScreenUtil.renderPointerPanel(poseStack, k, l, 24, 24); if (mobEffectInstance.endsWithin(200)){ int m = mobEffectInstance.getDuration(); f = Mth.clamp((float)m / 10.0f / 5.0f * 0.5f, 0.0f, 0.5f) + Mth.cos((float)m * (float)Math.PI / 5.0f) * Mth.clamp((10 - m / 20) / 10.0f * 0.25f, 0.0f, 0.25f); } RenderSystem.enableBlend(); TextureAtlasSprite textureAtlasSprite = mobEffectTextureManager.get(mobEffect); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, f * backAlpha); - guiGraphics.blit(k + 3, l + 3, 0, 18, 18, textureAtlasSprite); + poseStack.setColor(1.0f, 1.0f, 1.0f, f * backAlpha); + poseStack.blit(k + 3, l + 3, 0, 18, 18, textureAtlasSprite); RenderSystem.disableBlend(); } - guiGraphics.setColor(1.0f, 1.0f, 1.0f, 1.0f); + poseStack.setColor(1.0f, 1.0f, 1.0f, 1.0f); } @Redirect(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lnet/minecraft/resources/ResourceLocation;IIIIII)V", ordinal = 1)) - private void renderHotbarSelection(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l, int m, int n) { + private void renderHotbarSelection(PoseStack instance, ResourceLocation resourceLocation, int i, int j, int k, int l, int m, int n) { instance.blit(resourceLocation, i, j, k, l, m, 24); } @Inject(method = "renderHotbar", at = @At("HEAD"), cancellable = true) - public void renderHotbar(float f, GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderHotbar(float f, PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) { ci.cancel(); return; @@ -156,11 +156,11 @@ public void renderHotbar(float f, GuiGraphics guiGraphics, CallbackInfo ci) { float xRot = character.getXRot(); float xRotO = character.xRotO; if (!character.isFallFlying()) character.setXRot(character.xRotO = 0); - guiGraphics.pose().pushPose(); - ScreenUtil.applyHUDScale(guiGraphics); + poseStack.pose().pushPose(); + ScreenUtil.applyHUDScale(poseStack); f = ScreenUtil.getLegacyOptions().smoothAnimatedCharacter().get() ? f : 0; - ScreenUtil.renderEntity(guiGraphics, 28f, 50f, 13, f,new Vector3f(), new Quaternionf().rotationXYZ(0, -(Mth.lerp(f, character.yBodyRotO, character.yBodyRot) * (float)(Math.PI/180f)) + (float) (Math.PI * 7/8f), (float) Math.PI), null, character); - guiGraphics.pose().popPose(); + ScreenUtil.renderEntity(poseStack, 28f, 50f, 13, f,new Vector3f(), new Quaternionf().rotationXYZ(0, -(Mth.lerp(f, character.yBodyRotO, character.yBodyRot) * (float)(Math.PI/180f)) + (float) (Math.PI * 7/8f), (float) Math.PI), null, character); + poseStack.pose().popPose(); character.setXRot(xRot); character.xRotO = xRotO; } @@ -168,20 +168,20 @@ public void renderHotbar(float f, GuiGraphics guiGraphics, CallbackInfo ci) { int newSelection = minecraft.player != null ? minecraft.player.getInventory().selected : -1; if (lastHotbarSelection >= 0 && lastHotbarSelection != newSelection) ScreenUtil.lastHotbarSelectionChange = Util.getMillis(); lastHotbarSelection = newSelection; - ScreenUtil.prepareHUDRender(guiGraphics); - guiGraphics.pose().translate(guiGraphics.guiWidth()/2f, guiGraphics.guiHeight(),0.0F); - ScreenUtil.applyHUDScale(guiGraphics); - guiGraphics.pose().translate(-guiGraphics.guiWidth()/2,-guiGraphics.guiHeight(),0); + ScreenUtil.prepareHUDRender(poseStack); + poseStack.pose().translate(poseStack.guiWidth()/2f, poseStack.guiHeight(),0.0F); + ScreenUtil.applyHUDScale(poseStack); + poseStack.pose().translate(-poseStack.guiWidth()/2,-poseStack.guiHeight(),0); Player player = this.getCameraPlayer(); if (player == null) { return; } if (ScreenUtil.getHUDOpacity() < 1.0) { - Legacy4JClient.guiBufferSourceOverride = BufferSourceWrapper.translucent(guiGraphics.bufferSource()); + Legacy4JClient.guiBufferSourceOverride = BufferSourceWrapper.translucent(poseStack.bufferSource()); } } @Inject(method = "displayScoreboardSidebar", at = @At("HEAD"), cancellable = true) - private void displayScoreboardSidebar(GuiGraphics guiGraphics, Objective objective, CallbackInfo ci) { + private void displayScoreboardSidebar(PoseStack poseStack, Objective objective, CallbackInfo ci) { ci.cancel(); Scoreboard scoreboard = objective.getScoreboard(); Collection collection = scoreboard.getPlayerScores(objective); @@ -196,105 +196,105 @@ private void displayScoreboardSidebar(GuiGraphics guiGraphics, Objective objecti Objects.requireNonNull(this.getFont()); int l = scores.size() * 9; - int m = guiGraphics.guiHeight() / 2 + l / 3; - int o = guiGraphics.guiWidth() - j - 3; - int p = guiGraphics.guiWidth() - 3 + 2; + int m = poseStack.guiHeight() / 2 + l / 3; + int o = poseStack.guiWidth() - j - 3; + int p = poseStack.guiWidth() - 3 + 2; Objects.requireNonNull(this.getFont()); int s = m - scores.size() * 9; int x = o - 2; Objects.requireNonNull(this.getFont()); - ScreenUtil.renderPointerPanel(guiGraphics,x,s - 12,j + 4, scores.size() * 9 + 14); + ScreenUtil.renderPointerPanel(poseStack,x,s - 12,j + 4, scores.size() * 9 + 14); Font var18 = this.getFont(); int var10003 = o + j / 2 - i / 2; Objects.requireNonNull(this.getFont()); - guiGraphics.drawString(var18, component, var10003, s - 9, -1, false); + poseStack.drawString(var18, component, var10003, s - 9, -1, false); for(int t = 0; t < scores.size(); ++t) { Score lv = scores.get(t); x = scores.size() - t; Objects.requireNonNull(this.getFont()); int u = m - x * 9; - guiGraphics.drawString(this.getFont(), PlayerTeam.formatNameForTeam(scoreboard.getPlayersTeam(lv.getOwner()), Component.literal(lv.getOwner())), o, u, -1, false); + poseStack.drawString(this.getFont(), PlayerTeam.formatNameForTeam(scoreboard.getPlayersTeam(lv.getOwner()), Component.literal(lv.getOwner())), o, u, -1, false); Component score = lv.getObjective().getFormattedDisplayName(); - guiGraphics.drawString(this.getFont(), score, p - getFont().width(score), u, -1, false); + poseStack.drawString(this.getFont(), score, p - getFont().width(score), u, -1, false); } } @Inject(method = "renderHotbar", at = @At("RETURN")) - public void renderHotbarTail(float f, GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderHotbarTail(float f, PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) return; Legacy4JClient.guiBufferSourceOverride = null; - ScreenUtil.finishHUDRender(guiGraphics); - if (minecraft.player != null) ControlTooltip.Renderer.of(this).render(guiGraphics,0,0,f); + ScreenUtil.finishHUDRender(poseStack); + if (minecraft.player != null) ControlTooltip.Renderer.of(this).render(poseStack,0,0,f); } @Redirect(method = "renderExperienceBar", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;experienceLevel:I", ordinal = 0)) - public int renderExperienceBar(LocalPlayer instance, GuiGraphics guiGraphics) { + public int renderExperienceBar(LocalPlayer instance, PoseStack poseStack) { if (instance.experienceLevel > 0) { this.minecraft.getProfiler().push("expLevel"); String exp = "" + instance.experienceLevel; int hudScale = ScreenUtil.getLegacyOptions().hudScale().get(); boolean is720p = minecraft.getWindow().getHeight() % 720 == 0; - guiGraphics.pose().translate(guiGraphics.guiWidth() / 2,guiGraphics.guiHeight() - 36f,0); - if (!is720p && hudScale != 1) guiGraphics.pose().scale(7/8f,7/8f,7/8f); - ScreenUtil.drawOutlinedString(guiGraphics,getFont(), Component.literal(exp),-this.getFont().width(exp) / 2,-2,8453920,0,is720p && hudScale == 3 || !is720p && hudScale == 2 || hudScale == 1 ? 1/2f : 2/3f); + poseStack.pose().translate(poseStack.guiWidth() / 2,poseStack.guiHeight() - 36f,0); + if (!is720p && hudScale != 1) poseStack.pose().scale(7/8f,7/8f,7/8f); + ScreenUtil.drawOutlinedString(poseStack,getFont(), Component.literal(exp),-this.getFont().width(exp) / 2,-2,8453920,0,is720p && hudScale == 3 || !is720p && hudScale == 2 || hudScale == 1 ? 1/2f : 2/3f); this.minecraft.getProfiler().pop(); } return 0; } @Inject(method = {"renderVehicleHealth","renderPlayerHealth"}, at = @At("HEAD"), cancellable = true) - public void renderHealth(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderHealth(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null){ ci.cancel(); return; } - ScreenUtil.prepareHUDRender(guiGraphics); - guiGraphics.pose().translate(guiGraphics.guiWidth() / 2f, guiGraphics.guiHeight(),0); - ScreenUtil.applyHUDScale(guiGraphics); - guiGraphics.pose().translate(-guiGraphics.guiWidth() / 2, -guiGraphics.guiHeight(),0); + ScreenUtil.prepareHUDRender(poseStack); + poseStack.pose().translate(poseStack.guiWidth() / 2f, poseStack.guiHeight(),0); + ScreenUtil.applyHUDScale(poseStack); + poseStack.pose().translate(-poseStack.guiWidth() / 2, -poseStack.guiHeight(),0); } @Inject(method = {"renderVehicleHealth","renderPlayerHealth"}, at = @At("RETURN")) - public void renderHealthReturn(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderHealthReturn(PoseStack poseStack, CallbackInfo ci) { if (minecraft.screen != null) return; - ScreenUtil.finishHUDRender(guiGraphics); + ScreenUtil.finishHUDRender(poseStack); } @Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true) - public void renderExperienceBar(GuiGraphics guiGraphics, int i, CallbackInfo ci) { + public void renderExperienceBar(PoseStack poseStack, int i, CallbackInfo ci) { if (minecraft.screen != null){ ci.cancel(); return; } - ScreenUtil.prepareHUDRender(guiGraphics); - guiGraphics.pose().translate(guiGraphics.guiWidth() / 2f, guiGraphics.guiHeight(),0); - ScreenUtil.applyHUDScale(guiGraphics); - guiGraphics.pose().translate(-guiGraphics.guiWidth() / 2, -guiGraphics.guiHeight(),0); + ScreenUtil.prepareHUDRender(poseStack); + poseStack.pose().translate(poseStack.guiWidth() / 2f, poseStack.guiHeight(),0); + ScreenUtil.applyHUDScale(poseStack); + poseStack.pose().translate(-poseStack.guiWidth() / 2, -poseStack.guiHeight(),0); } @Inject(method = "renderExperienceBar", at = @At("RETURN")) - public void renderExperienceBarReturn(GuiGraphics guiGraphics, int i, CallbackInfo ci) { + public void renderExperienceBarReturn(PoseStack poseStack, int i, CallbackInfo ci) { if (minecraft.screen != null) return; - ScreenUtil.finishHUDRender(guiGraphics); + ScreenUtil.finishHUDRender(poseStack); } @Inject(method = "renderJumpMeter", at = @At("HEAD"), cancellable = true) - public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int i, CallbackInfo ci) { + public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, PoseStack poseStack, int i, CallbackInfo ci) { if (minecraft.screen != null){ ci.cancel(); return; } - ScreenUtil.prepareHUDRender(guiGraphics); - guiGraphics.pose().translate(guiGraphics.guiWidth() / 2f, guiGraphics.guiHeight(),0); - ScreenUtil.applyHUDScale(guiGraphics); - guiGraphics.pose().translate(-guiGraphics.guiWidth() / 2, -guiGraphics.guiHeight(),0); + ScreenUtil.prepareHUDRender(poseStack); + poseStack.pose().translate(poseStack.guiWidth() / 2f, poseStack.guiHeight(),0); + ScreenUtil.applyHUDScale(poseStack); + poseStack.pose().translate(-poseStack.guiWidth() / 2, -poseStack.guiHeight(),0); } @Inject(method = "renderJumpMeter", at = @At("RETURN")) - public void renderJumpMeterReturn(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int i, CallbackInfo ci) { + public void renderJumpMeterReturn(PlayerRideableJumping playerRideableJumping, PoseStack poseStack, int i, CallbackInfo ci) { if (minecraft.screen != null) return; - ScreenUtil.finishHUDRender(guiGraphics); + ScreenUtil.finishHUDRender(poseStack); } @Inject(method = "renderSavingIndicator", at = @At("HEAD"), cancellable = true) - public void renderAutoSaveIndicator(GuiGraphics guiGraphics, CallbackInfo ci) { + public void renderAutoSaveIndicator(PoseStack poseStack, CallbackInfo ci) { ci.cancel(); } diff --git a/common/src/main/java/wily/legacy/mixin/HorseInventoryScreenMixin.java b/common/src/main/java/wily/legacy/mixin/HorseInventoryScreenMixin.java index edfd45f5..7a7e74a3 100644 --- a/common/src/main/java/wily/legacy/mixin/HorseInventoryScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/HorseInventoryScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.HorseInventoryScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; @@ -38,7 +38,7 @@ public void init() { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics graphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack graphics, float f, int i, int j, CallbackInfo ci) { ci.cancel(); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,leftPos + 34,topPos + 20,63,63); @@ -47,6 +47,6 @@ public void renderBg(GuiGraphics graphics, float f, int i, int j, CallbackInfo c } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } } diff --git a/common/src/main/java/wily/legacy/mixin/InventoryScreenMixin.java b/common/src/main/java/wily/legacy/mixin/InventoryScreenMixin.java index 61d5ee9a..fb91ccf7 100644 --- a/common/src/main/java/wily/legacy/mixin/InventoryScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/InventoryScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -51,7 +51,7 @@ public void containerTick(CallbackInfo ci) { } } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "init",at = @At("HEAD"), cancellable = true) public void init(CallbackInfo ci) { @@ -79,7 +79,7 @@ public void init(CallbackInfo ci) { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics graphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack graphics, float f, int i, int j, CallbackInfo ci) { ci.cancel(); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.ENTITY_PANEL,leftPos + 40 + (ScreenUtil.hasClassicCrafting() ? 0 : 50),topPos + 13,63,84); @@ -94,9 +94,9 @@ public void renderBg(GuiGraphics graphics, float f, int i, int j, CallbackInfo c if (!recipeBookComponent.isVisible() && recipeButton != null && !recipeButton.isHovered()) recipeButton.setFocused(false); } @Inject(method = "renderLabels",at = @At("HEAD"), cancellable = true) - public void renderLabels(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) { + public void renderLabels(PoseStack poseStack, int i, int j, CallbackInfo ci) { ci.cancel(); - guiGraphics.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } public boolean canReplace() { diff --git a/common/src/main/java/wily/legacy/mixin/LegacyLoadingScreenMixin.java b/common/src/main/java/wily/legacy/mixin/LegacyLoadingScreenMixin.java index 9de7358e..64ff4e86 100644 --- a/common/src/main/java/wily/legacy/mixin/LegacyLoadingScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/LegacyLoadingScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.*; import net.minecraft.network.chat.Component; import net.minecraft.world.level.Level; @@ -29,7 +29,7 @@ public void onClose() { @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); Component lastLoadingHeader = null; Component lastLoadingStage = null; @@ -54,6 +54,6 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo lastLoadingHeader = p.status; } legacyLoadingScreen.prepareRender(minecraft,width, height,lastLoadingHeader,lastLoadingStage,progress,genericLoading); - legacyLoadingScreen.render(guiGraphics,i,j,f); + legacyLoadingScreen.render(poseStack,i,j,f); } } diff --git a/common/src/main/java/wily/legacy/mixin/LoadingOverlayMixin.java b/common/src/main/java/wily/legacy/mixin/LoadingOverlayMixin.java index 9f5d2f29..ef0e4491 100644 --- a/common/src/main/java/wily/legacy/mixin/LoadingOverlayMixin.java +++ b/common/src/main/java/wily/legacy/mixin/LoadingOverlayMixin.java @@ -3,9 +3,9 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; import net.minecraft.client.gui.screens.Overlay; import net.minecraft.client.renderer.RenderType; @@ -41,7 +41,7 @@ public class LoadingOverlayMixin extends Overlay { @Shadow private long fadeInStart; private long initTime = Util.getMillis(); @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { + public void render(PoseStack poseStack, int i, int j, float f) { if (!loadIntroLocation){ loadIntroLocation = true; LegacyResourceManager.registerIntroLocations(minecraft.getResourceManager()); @@ -52,12 +52,12 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f) { if ((InputConstants.isKeyDown(minecraft.getWindow().getWindow(), InputConstants.KEY_RETURN) || ControllerBinding.DOWN_BUTTON.bindingState.pressed) && reload.isDone()) finishedIntro = true; if (timer % INTROS.size() >= INTROS.size() - 0.01f) finishedIntro = true; - guiGraphics.fill(RenderType.guiOverlay(), 0, 0, guiGraphics.guiWidth(), guiGraphics.guiHeight(), 0xFFFFFFFF); + poseStack.fill(RenderType.guiOverlay(), 0, 0, poseStack.guiWidth(), poseStack.guiHeight(), 0xFFFFFFFF); RenderSystem.enableBlend(); float last = (float) Math.ceil(timer) - timer; - guiGraphics.setColor(1.0f, 1.0f, 1.0f, last <= 0.4f ? last * 2.5f : last > 0.6f ? (1 - last) * 2.5f : 1.0f); - guiGraphics.blit(INTROS.get((int) (timer % INTROS.size())), (guiGraphics.guiWidth() - guiGraphics.guiHeight() * 320 / 180) / 2, 0, 0, 0, guiGraphics.guiHeight() * 320 / 180, guiGraphics.guiHeight(), guiGraphics.guiHeight() * 320 / 180, guiGraphics.guiHeight()); - guiGraphics.setColor(1.0f, 1.0f, 1.0f, 1.0f); + poseStack.setColor(1.0f, 1.0f, 1.0f, last <= 0.4f ? last * 2.5f : last > 0.6f ? (1 - last) * 2.5f : 1.0f); + poseStack.blit(INTROS.get((int) (timer % INTROS.size())), (poseStack.guiWidth() - poseStack.guiHeight() * 320 / 180) / 2, 0, 0, 0, poseStack.guiHeight() * 320 / 180, poseStack.guiHeight(), poseStack.guiHeight() * 320 / 180, poseStack.guiHeight()); + poseStack.setColor(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.disableBlend(); } @@ -69,14 +69,14 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f) { } float g = this.fadeOutStart > -1L ? (float)(m - this.fadeOutStart) / 1000.0f : -1.0f; h = this.fadeInStart > -1L ? (float)(m - this.fadeInStart) / 500.0f : -1.0f; - if ((Legacy4JClient.isGameLoadFinished && reload.isDone()) && minecraft.screen != null) this.minecraft.screen.renderWithTooltip(guiGraphics, 0, 0, f); + if ((Legacy4JClient.isGameLoadFinished && reload.isDone()) && minecraft.screen != null) this.minecraft.screen.renderWithTooltip(poseStack, 0, 0, f); else { GlStateManager._clearColor(0, 0, 0, 1.0f); GlStateManager._clear(16384, Minecraft.ON_OSX); - guiGraphics.fill(RenderType.guiOverlay(),0,0,guiGraphics.guiWidth(),guiGraphics.guiHeight(),0); + poseStack.fill(RenderType.guiOverlay(),0,0,poseStack.guiWidth(),poseStack.guiHeight(),0); } if (g < 1.0f && !reload.isDone() && Legacy4JClient.isGameLoadFinished) - ScreenUtil.drawGenericLoading(guiGraphics, (guiGraphics.guiWidth() - 75) / 2, (guiGraphics.guiHeight() - 75) / 2); + ScreenUtil.drawGenericLoading(poseStack, (poseStack.guiWidth() - 75) / 2, (poseStack.guiHeight() - 75) / 2); if (g >= 2.0f) this.minecraft.setOverlay(null); @@ -90,7 +90,7 @@ public void render(GuiGraphics guiGraphics, int i, int j, float f) { } this.fadeOutStart = Util.getMillis(); if (this.minecraft.screen != null) { - this.minecraft.screen.init(this.minecraft, guiGraphics.guiWidth(), guiGraphics.guiHeight()); + this.minecraft.screen.init(this.minecraft, poseStack.guiWidth(), poseStack.guiHeight()); } } } diff --git a/common/src/main/java/wily/legacy/mixin/LoomScreenMixin.java b/common/src/main/java/wily/legacy/mixin/LoomScreenMixin.java index ffbdd172..11aa3dd0 100644 --- a/common/src/main/java/wily/legacy/mixin/LoomScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/LoomScreenMixin.java @@ -5,7 +5,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.LoomScreen; @@ -54,7 +53,7 @@ public abstract class LoomScreenMixin extends AbstractContainerScreen @Shadow private int startRow; - @Shadow protected abstract void renderPattern(GuiGraphics guiGraphics, Holder holder, int i, int j); + @Shadow protected abstract void renderPattern(PoseStack poseStack, Holder holder, int i, int j); @Shadow private ModelPart flag; @@ -85,52 +84,52 @@ private void renderPattern(PoseStack instance, float posestack$pose, float f, fl instance.scale(1,-1,-1); } @Redirect(method = "renderPattern", at = @At(value = "NEW", target = "()Lcom/mojang/blaze3d/vertex/PoseStack;")) - private PoseStack renderPattern(GuiGraphics graphics) { + private PoseStack renderPattern(PoseStack graphics) { return graphics.pose(); } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "renderBg",at = @At("HEAD"), cancellable = true) - public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { + public void renderBg(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { ci.cancel(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos, imageWidth,imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 72, topPos+ 18, 75, 75); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 164.5f, topPos + 7, 0.0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0, 32, 64); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 149.5, topPos + 18, 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos, imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 72, topPos+ 18, 75, 75); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 164.5f, topPos + 7, 0.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0, 32, 64); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 149.5, topPos + 18, 0f); if (displayPatterns && menu.getSelectablePatterns().size() > 4) { if (startRow != totalRowCount() - 4) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.DOWN, 0, 79); + scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN, 0, 79); if (startRow > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.UP,0,-11); - }else guiGraphics.setColor(1.0f,1.0f,1.0f,0.5f); + scrollRenderer.renderScroll(poseStack, ScreenDirection.UP,0,-11); + }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,75); - guiGraphics.pose().translate(-2f, -1f + (menu.getSelectablePatterns().size() > 4 && displayPatterns ? 61.5f * startRow / (totalRowCount() - 4) : 0), 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL,0,0, 16,16); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,75); + poseStack.pose().translate(-2f, -1f + (menu.getSelectablePatterns().size() > 4 && displayPatterns ? 61.5f * startRow / (totalRowCount() - 4) : 0), 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); Lighting.setupForFlatItems(); if (this.resultBannerPatterns != null && !this.hasMaxPatterns) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 168.5f, topPos + 69, 0.0f); - guiGraphics.pose().scale(24.0f, -24.0f, 1.0f); - guiGraphics.pose().translate(0.5f, 0.5f, 0.5f); - guiGraphics.pose().scale(1f, -1f, -1f); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 168.5f, topPos + 69, 0.0f); + poseStack.pose().scale(24.0f, -24.0f, 1.0f); + poseStack.pose().translate(0.5f, 0.5f, 0.5f); + poseStack.pose().scale(1f, -1f, -1f); this.flag.xRot = 0.0f; this.flag.y = -32.0f; - BannerRenderer.renderPatterns(guiGraphics.pose(), guiGraphics.bufferSource(), 0xF000F0, OverlayTexture.NO_OVERLAY, this.flag, ModelBakery.BANNER_BASE, true, this.resultBannerPatterns); - guiGraphics.pose().popPose(); - guiGraphics.flush(); + BannerRenderer.renderPatterns(poseStack.pose(), poseStack.bufferSource(), 0xF000F0, OverlayTexture.NO_OVERLAY, this.flag, ModelBakery.BANNER_BASE, true, this.resultBannerPatterns); + poseStack.pose().popPose(); + poseStack.flush(); } - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 73.5f,topPos + 19.5f,0); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 73.5f,topPos + 19.5f,0); if (this.displayPatterns) { List> list = this.menu.getSelectablePatterns(); block0: for (int p = 0; p < 4; ++p) { @@ -140,14 +139,14 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf if (s >= list.size()) break block0; int t = q * 18; int u = p * 18; - LegacyGuiGraphics.of(guiGraphics).blitSprite(s == menu.getSelectedBannerPatternIndex() ? BUTTON_SLOT_SELECTED : (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + t,topPos + 19.5f + u,18,18)? BUTTON_SLOT_HIGHLIGHTED : BUTTON_SLOT), t, u, 18, 18); - guiGraphics.pose().pushPose(); - this.renderPattern(guiGraphics, list.get(s), t + 3, u + 3); - guiGraphics.pose().popPose(); + LegacyGuiGraphics.of(poseStack).blitSprite(s == menu.getSelectedBannerPatternIndex() ? BUTTON_SLOT_SELECTED : (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + t,topPos + 19.5f + u,18,18)? BUTTON_SLOT_HIGHLIGHTED : BUTTON_SLOT), t, u, 18, 18); + poseStack.pose().pushPose(); + this.renderPattern(poseStack, list.get(s), t + 3, u + 3); + poseStack.pose().popPose(); } } } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); Lighting.setupFor3DItems(); } @Inject(method = "mouseClicked",at = @At("HEAD"), cancellable = true) diff --git a/common/src/main/java/wily/legacy/mixin/MerchantScreenMixin.java b/common/src/main/java/wily/legacy/mixin/MerchantScreenMixin.java index c2b71222..7b0a861d 100644 --- a/common/src/main/java/wily/legacy/mixin/MerchantScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/MerchantScreenMixin.java @@ -1,8 +1,8 @@ package wily.legacy.mixin; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.navigation.CommonInputs; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.navigation.ScreenDirection; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.MerchantScreen; @@ -40,9 +40,9 @@ public abstract class MerchantScreenMixin extends AbstractContainerScreen= merchantOffers.size()) break; - LegacyGuiGraphics.of(guiGraphics).blitSprite(index + scrollOff == shopItem ? LegacySprites.BUTTON_SLOT_SELECTED : ScreenUtil.isMouseOver(i,j,leftPos + 8.5f,topPos + 22.5f + index * 18,102,18) ? LegacySprites.BUTTON_SLOT_HIGHLIGHTED : LegacySprites.BUTTON_SLOT, 0, 0, 102, 18); + LegacyGuiGraphics.of(poseStack).blitSprite(index + scrollOff == shopItem ? LegacySprites.BUTTON_SLOT_SELECTED : ScreenUtil.isMouseOver(i,j,leftPos + 8.5f,topPos + 22.5f + index * 18,102,18) ? LegacySprites.BUTTON_SLOT_HIGHLIGHTED : LegacySprites.BUTTON_SLOT, 0, 0, 102, 18); MerchantOffer merchantOffer = merchantOffers.get(index + scrollOff); ItemStack itemStack = merchantOffer.getBaseCostA(); ItemStack itemStack2 = merchantOffer.getCostA(); ItemStack itemStack3 = merchantOffer.getCostB(); ItemStack itemStack4 = merchantOffer.getResult(); - this.renderAndDecorateCostA(guiGraphics, itemStack2, itemStack, 10, 1); + this.renderAndDecorateCostA(poseStack, itemStack2, itemStack, 10, 1); if (!itemStack3.isEmpty()) { - guiGraphics.renderFakeItem(itemStack3, 35, 1); - guiGraphics.renderItemDecorations(this.font, itemStack3, 35, 1); + poseStack.renderFakeItem(itemStack3, 35, 1); + poseStack.renderItemDecorations(this.font, itemStack3, 35, 1); } - this.renderButtonArrows(guiGraphics, merchantOffer, -4, 1); - if (((LegacyMerchantOffer)merchantOffer).getRequiredLevel() > menu.getTraderLevel()) LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PADLOCK, 52, 1, 16, 16); - guiGraphics.renderFakeItem(itemStack4, 68, 1); - guiGraphics.renderItemDecorations(this.font, itemStack4, 68, 1); - guiGraphics.pose().translate(0, 18, 0F); + this.renderButtonArrows(poseStack, merchantOffer, -4, 1); + if (((LegacyMerchantOffer)merchantOffer).getRequiredLevel() > menu.getTraderLevel()) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PADLOCK, 52, 1, 16, 16); + poseStack.renderFakeItem(itemStack4, 68, 1); + poseStack.renderItemDecorations(this.font, itemStack4, 68, 1); + poseStack.pose().translate(0, 18, 0F); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); for (int index = 0; index < 9; index++) { if (index + scrollOff >= merchantOffers.size()) break; MerchantOffer merchantOffer = merchantOffers.get(index + scrollOff); int diffY = index * 18; - if (ScreenUtil.isMouseOver(i,j,leftPos + 18.5F, topPos + diffY + 23.5F,16,16)) guiGraphics.renderTooltip(font,merchantOffer.getCostA(),i,j); - else if (!merchantOffer.getCostB().isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + 43.5F, topPos + diffY + 23.5F,16,16)) guiGraphics.renderTooltip(font,merchantOffer.getCostB(),i,j); - else if (ScreenUtil.isMouseOver(i,j,leftPos + 76.5F, topPos + diffY + 23.5F,16,16)) guiGraphics.renderTooltip(font,merchantOffer.getResult(),i,j); + if (ScreenUtil.isMouseOver(i,j,leftPos + 18.5F, topPos + diffY + 23.5F,16,16)) poseStack.renderTooltip(font,merchantOffer.getCostA(),i,j); + else if (!merchantOffer.getCostB().isEmpty() && ScreenUtil.isMouseOver(i,j,leftPos + 43.5F, topPos + diffY + 23.5F,16,16)) poseStack.renderTooltip(font,merchantOffer.getCostB(),i,j); + else if (ScreenUtil.isMouseOver(i,j,leftPos + 76.5F, topPos + diffY + 23.5F,16,16)) poseStack.renderTooltip(font,merchantOffer.getResult(),i,j); } MerchantOffer merchantOffer = merchantOffers.get(this.shopItem); if (shopItem - scrollOff < 9 && shopItem - scrollOff >= 0 && merchantOffer.isOutOfStock() && this.isHovering( 7,21 + 18 * (shopItem - scrollOff),105,18, i, j) && this.menu.canRestock()) { - guiGraphics.renderTooltip(this.font, DEPRECATED_TOOLTIP, i, j); + poseStack.renderTooltip(this.font, DEPRECATED_TOOLTIP, i, j); } } - this.renderTooltip(guiGraphics, i, j); + this.renderTooltip(poseStack, i, j); } @Inject(method = "renderLabels",at = @At("HEAD"), cancellable = true) - public void renderLabels(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci) { + public void renderLabels(PoseStack poseStack, int i, int j, CallbackInfo ci) { ci.cancel(); int k = this.menu.getTraderLevel(); if (k > 0 && k <= 5 && this.menu.showProgressBar()) { Component component = Component.translatable("merchant.title", this.title, Component.translatable("merchant.level." + k)); - guiGraphics.drawString(this.font, component, 131 + (189 - this.font.width(component)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, component, 131 + (189 - this.font.width(component)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } else { - guiGraphics.drawString(this.font, this.title, 131 + (189 - this.font.width(title)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.title, 131 + (189 - this.font.width(title)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } - guiGraphics.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - guiGraphics.drawString(this.font, TRADES_LABEL, 7 + (105 - this.font.width(TRADES_LABEL)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, this.playerInventoryTitle, this.inventoryLabelX, this.inventoryLabelY, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + poseStack.drawString(this.font, TRADES_LABEL, 7 + (105 - this.font.width(TRADES_LABEL)) / 2, 10, CommonColor.INVENTORY_GRAY_TEXT.get(), false); } @Inject(method = "mouseClicked",at = @At("HEAD"), cancellable = true) public void mouseClicked(double d, double e, int i, CallbackInfoReturnable cir) { @@ -182,56 +182,56 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void renderBackground(GuiGraphics guiGraphics) { + public void renderBackground(PoseStack poseStack) { } @Inject(method = "renderBg",at = @At("HEAD")) - public void renderBackground(GuiGraphics guiGraphics, float f, int i, int j, CallbackInfo ci) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 7,topPos + 21,105,165); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 219.5,topPos + 42.5,0); - guiGraphics.pose().scale(1.5f,1.5f,1.0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(ARROW,0,0,22,15); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 115, topPos + 21, 0f); + public void renderBackground(PoseStack poseStack, float f, int i, int j, CallbackInfo ci) { + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 7,topPos + 21,105,165); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 219.5,topPos + 42.5,0); + poseStack.pose().scale(1.5f,1.5f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(ARROW,0,0,22,15); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 115, topPos + 21, 0f); if (menu.getOffers().size() > 9) { if (scrollOff != menu.getOffers().size() - 9) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.DOWN, 0, 169); + scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN, 0, 169); if (scrollOff > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.UP,0,-11); - }else guiGraphics.setColor(1.0f,1.0f,1.0f,0.5f); + scrollRenderer.renderScroll(poseStack, ScreenDirection.UP,0,-11); + }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,165); - guiGraphics.pose().translate(-2f, -1f + (menu.getOffers().size() > 9 ? 151.5f * scrollOff / (menu.getOffers().size() - 9) : 0), 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL,0,0, 16,16); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,165); + poseStack.pose().translate(-2f, -1f + (menu.getOffers().size() > 9 ? 151.5f * scrollOff / (menu.getOffers().size() - 9) : 0), 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); if (this.menu.showProgressBar()) { int k = this.menu.getTraderLevel(); int l = this.menu.getTraderXp(); if (k >= 5) { return; } - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 144.5,topPos + 21,0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_BACKGROUND, 0, 0, 0, 161, 4); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 144.5,topPos + 21,0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_BACKGROUND, 0, 0, 0, 161, 4); int m = VillagerData.getMinXpPerLevel(k); if (l < m || !VillagerData.canLevelUp(k)) { - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); return; } float v = 161.0f / (float)(VillagerData.getMaxXpPerLevel(k) - m); int o = Math.min(Mth.floor(v * (float)(l - m)), 161); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_CURRENT, 161, 4, 0, 0, 0, 0, 0, o, 4); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_CURRENT, 161, 4, 0, 0, 0, 0, 0, o, 4); int p = menu.getFutureTraderXp(); if (p > 0) { int q = Math.min(Mth.floor((float)p * v), 161 - o); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.EXPERIENCE_BAR_RESULT, 161, 4, o, 0, o, 0, 0, q, 4); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_RESULT, 161, 4, o, 0, o, 0, 0, q, 4); } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } } } diff --git a/common/src/main/java/wily/legacy/mixin/MinecraftMixin.java b/common/src/main/java/wily/legacy/mixin/MinecraftMixin.java index bcdad600..36af065d 100644 --- a/common/src/main/java/wily/legacy/mixin/MinecraftMixin.java +++ b/common/src/main/java/wily/legacy/mixin/MinecraftMixin.java @@ -1,13 +1,13 @@ package wily.legacy.mixin; import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.realmsclient.client.RealmsClient; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.Options; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.toasts.AdvancementToast; import net.minecraft.client.gui.components.toasts.Toast; @@ -233,7 +233,7 @@ public double getTweakedHeightScale(int height) { return (1.125 - ScreenUtil.getLegacyOptions().interfaceResolution().get() / 4); } @Inject(method = "setInitialScreen", at = @At("HEAD"), cancellable = true) - private void addInitialScreens(RealmsClient realmsClient, ReloadInstance reloadInstance, GameConfig.QuickPlayData quickPlayData, CallbackInfo ci) { + private void addInitialScreens(RealmsClient realmsClient, ReloadInstance reloadInstance, CallbackInfo ci) { ci.cancel(); Legacy4JClient.SECURE_EXECUTOR.executeWhen(()-> { if (!Legacy4JClient.isGameLoadFinished) return false; @@ -252,9 +252,9 @@ public boolean shouldCloseOnEsc() { return false; } - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - super.render(guiGraphics, i, j, f); - ScreenUtil.drawAutoSavingIcon(guiGraphics, panel.x + 127, panel.y + 36); + public void render(PoseStack poseStack, int i, int j, float f) { + super.render(poseStack, i, j, f); + ScreenUtil.drawAutoSavingIcon(poseStack, panel.x + 127, panel.y + 36); } }); return true; }); diff --git a/common/src/main/java/wily/legacy/mixin/PackSelectionScreenMixin.java b/common/src/main/java/wily/legacy/mixin/PackSelectionScreenMixin.java index 503d15bb..2128d9ff 100644 --- a/common/src/main/java/wily/legacy/mixin/PackSelectionScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/PackSelectionScreenMixin.java @@ -1,9 +1,9 @@ package wily.legacy.mixin; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -92,48 +92,48 @@ private void addPacks(RenderableVList list,Stream stre if (!e.getExtendedDescription().getString().isEmpty()) description.add(e.getExtendedDescription()); AbstractButton button = new AbstractButton(0,0,180,30,e.getTitle()) { @Override - protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { - super.renderWidget(guiGraphics, mouseX, mouseY, partialTicks); + protected void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) { + super.renderWidget(poseStack, mouseX, mouseY, partialTicks); RenderSystem.enableBlend(); - guiGraphics.blit(e.getIconTexture(), getX() + 5, getY() + 5, 0.0f, 0.0f, 20, 20, 20, 20); + poseStack.blit(e.getIconTexture(), getX() + 5, getY() + 5, 0.0f, 0.0f, 20, 20, 20, 20); RenderSystem.disableBlend(); if ((minecraft.options.touchscreen().get().booleanValue() || isHovered) && showHoverOverlay()) { - guiGraphics.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); int p = mouseX - getX(); int q = mouseY - getY(); if (e.canSelect()) { if (p < 32) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.JOIN_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.JOIN_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.JOIN, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.JOIN, getX(), getY(), 32, 32); } } else { if (e.canUnselect()) { if (p < 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(UNSELECT_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(UNSELECT_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(UNSELECT, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(UNSELECT, getX(), getY(), 32, 32); } } if (e.canMoveUp()) { if (p < 32 && p > 16 && q < 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TRANSFER_MOVE_UP_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.TRANSFER_MOVE_UP_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TRANSFER_MOVE_UP, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.TRANSFER_MOVE_UP, getX(), getY(), 32, 32); } } if (e.canMoveDown()) { if (p < 32 && p > 16 && q > 16) { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TRANSFER_MOVE_DOWN_HIGHLIGHTED, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.TRANSFER_MOVE_DOWN_HIGHLIGHTED, getX(), getY(), 32, 32); } else { - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.TRANSFER_MOVE_DOWN, getX(), getY(), 32, 32); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.TRANSFER_MOVE_DOWN, getX(), getY(), 32, 32); } } } } } - protected void renderScrollingString(GuiGraphics guiGraphics, Font font, int i, int j) { - ScreenUtil.renderScrollingString(guiGraphics,font,getMessage(),getX() + 30,getY(),getX() + width - 2,getY() + height,e.getCompatibility().isCompatible() ? ScreenUtil.getDefaultTextColor(!isHoveredOrFocused()): 0xFF0000,true); + protected void renderScrollingString(PoseStack poseStack, Font font, int i, int j) { + ScreenUtil.renderScrollingString(poseStack,font,getMessage(),getX() + 30,getY(),getX() + width - 2,getY() + height,e.getCompatibility().isCompatible() ? ScreenUtil.getDefaultTextColor(!isHoveredOrFocused()): 0xFF0000,true); } @Override @@ -220,17 +220,17 @@ public boolean keyPressed(int i, int j, int k) { } @Override - public void render(GuiGraphics guiGraphics, int i, int j, float f) { - ScreenUtil.renderDefaultBackground(guiGraphics); - panel.render(guiGraphics, 0,0,0); + public void render(PoseStack poseStack, int i, int j, float f) { + ScreenUtil.renderDefaultBackground(poseStack); + panel.render(poseStack, 0,0,0); RenderSystem.enableBlend(); - guiGraphics.setColor(1.0f,1.0f,1.0f,0.6f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 10, panel.y + 10, 190, 220); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + poseStack.setColor(1.0f,1.0f,1.0f,0.6f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 10, panel.y + 10, 190, 220); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 210, panel.y + 10, 190, 220); - guiGraphics.drawString(this.font, SELECTED_PACK, panel.x + 10 + (190 - font.width(SELECTED_PACK)) / 2, panel.y + 18, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - guiGraphics.drawString(this.font, AVAILABLE_PACK, panel.x + 210 + (190 - font.width(AVAILABLE_PACK)) / 2, panel.y + 18, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - super.render(guiGraphics, i, j, f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,panel.x + 210, panel.y + 10, 190, 220); + poseStack.drawString(this.font, SELECTED_PACK, panel.x + 10 + (190 - font.width(SELECTED_PACK)) / 2, panel.y + 18, CommonColor.INVENTORY_GRAY_TEXT.get(),false); + poseStack.drawString(this.font, AVAILABLE_PACK, panel.x + 210 + (190 - font.width(AVAILABLE_PACK)) / 2, panel.y + 18, CommonColor.INVENTORY_GRAY_TEXT.get(), false); + super.render(poseStack, i, j, f); } } diff --git a/common/src/main/java/wily/legacy/mixin/PauseScreenMixin.java b/common/src/main/java/wily/legacy/mixin/PauseScreenMixin.java index b92bc653..bff6cbd1 100644 --- a/common/src/main/java/wily/legacy/mixin/PauseScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/PauseScreenMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.PauseScreen; import net.minecraft.client.gui.screens.Screen; @@ -66,10 +66,10 @@ private void initScreen(CallbackInfo ci){ renderableVList.addRenderable(Button.builder(Component.translatable("menu.quit"), button -> minecraft.setScreen(new ExitConfirmationScreen(this))).build()); } @Inject(method = "render",at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); - ScreenUtil.renderDefaultBackground(guiGraphics); - super.render(guiGraphics, i, j, f); + ScreenUtil.renderDefaultBackground(poseStack); + super.render(poseStack, i, j, f); } @Inject(method = "init",at = @At("HEAD"), cancellable = true) diff --git a/common/src/main/java/wily/legacy/mixin/RecipeBookComponentMixin.java b/common/src/main/java/wily/legacy/mixin/RecipeBookComponentMixin.java index d7a74288..c31a03d1 100644 --- a/common/src/main/java/wily/legacy/mixin/RecipeBookComponentMixin.java +++ b/common/src/main/java/wily/legacy/mixin/RecipeBookComponentMixin.java @@ -1,7 +1,7 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.recipebook.GhostRecipe; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; @@ -46,7 +46,7 @@ public void addItemToSlot(GhostRecipe instance, Ingredient ingredient, int i, in ((DisplayRecipe)ghostRecipe).addIngredient(ingredient, menu.slots.get(index)); } @Inject(method = "renderGhostRecipeTooltip", at = @At("HEAD"), cancellable = true) - private void renderGhostRecipeTooltip(GuiGraphics guiGraphics, int leftPos, int topPos, int k, int l, CallbackInfo info) { + private void renderGhostRecipeTooltip(PoseStack poseStack, int leftPos, int topPos, int k, int l, CallbackInfo info) { info.cancel(); ItemStack itemStack = null; for (int m = 0; m < this.ghostRecipe.size(); ++m) { @@ -57,7 +57,7 @@ private void renderGhostRecipeTooltip(GuiGraphics guiGraphics, int leftPos, int itemStack = ghostRecipe.get(m).getItem(); } if (itemStack != null && minecraft.screen != null) { - guiGraphics.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemStack), k, l); + poseStack.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemStack), k, l); } } } diff --git a/common/src/main/java/wily/legacy/mixin/RecipeToastMixin.java b/common/src/main/java/wily/legacy/mixin/RecipeToastMixin.java index 230089c4..673c99fd 100644 --- a/common/src/main/java/wily/legacy/mixin/RecipeToastMixin.java +++ b/common/src/main/java/wily/legacy/mixin/RecipeToastMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.toasts.RecipeToast; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastComponent; @@ -40,7 +40,7 @@ private static void addOrUpdate(ToastComponent toastComponent, Recipe recipeH if (!ScreenUtil.hasClassicCrafting()) ci.cancel(); } @Inject(method = "render", at = @At(value = "HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, ToastComponent toastComponent, long l, CallbackInfoReturnable cir) { + public void render(PoseStack poseStack, ToastComponent toastComponent, long l, CallbackInfoReturnable cir) { if (this.changed) { this.lastChanged = l; this.changed = false; @@ -50,17 +50,17 @@ public void render(GuiGraphics guiGraphics, ToastComponent toastComponent, long return; } - ScreenUtil.renderPointerPanel(guiGraphics,0,0,width(),height()); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate((width() - 1.5 * toastComponent.getMinecraft().font.width(TITLE_TEXT)) / 2, 5,0); - guiGraphics.pose().scale(1.5f,1.5f,1.5f); - guiGraphics.drawString(toastComponent.getMinecraft().font, TITLE_TEXT, 0,0, 0xFFFFFF); - guiGraphics.pose().popPose(); - guiGraphics.drawString(toastComponent.getMinecraft().font, DESCRIPTION_TEXT, (width() - toastComponent.getMinecraft().font.width(DESCRIPTION_TEXT)) / 2 , 18, 0xFFFFFF); + ScreenUtil.renderPointerPanel(poseStack,0,0,width(),height()); + poseStack.pose().pushPose(); + poseStack.pose().translate((width() - 1.5 * toastComponent.getMinecraft().font.width(TITLE_TEXT)) / 2, 5,0); + poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.drawString(toastComponent.getMinecraft().font, TITLE_TEXT, 0,0, 0xFFFFFF); + poseStack.pose().popPose(); + poseStack.drawString(toastComponent.getMinecraft().font, DESCRIPTION_TEXT, (width() - toastComponent.getMinecraft().font.width(DESCRIPTION_TEXT)) / 2 , 18, 0xFFFFFF); Recipe recipeHolder = this.recipes.get((int)((double)l / Math.max(1.0, 5000.0 * toastComponent.getNotificationDisplayTimeMultiplier() / (double)this.recipes.size()) % (double)this.recipes.size())); - ScreenUtil.iconHolderRenderer.itemHolder(8,(height() - 27) / 2,27,27,recipeHolder.getToastSymbol(),false, Offset.ZERO).renderItem(guiGraphics,0,0,0); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SMALL_PANEL,width() - 36,(height() - 28) / 2,28,28); - guiGraphics.renderItem(recipeHolder.getResultItem(toastComponent.getMinecraft().level.registryAccess()) ,width() - 30, (height() - 16) / 2); + ScreenUtil.iconHolderRenderer.itemHolder(8,(height() - 27) / 2,27,27,recipeHolder.getToastSymbol(),false, Offset.ZERO).renderItem(poseStack,0,0,0); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,width() - 36,(height() - 28) / 2,28,28); + poseStack.renderItem(recipeHolder.getResultItem(toastComponent.getMinecraft().level.registryAccess()) ,width() - 30, (height() - 16) / 2); cir.setReturnValue((double)(l - this.lastChanged) >= 5000.0 * toastComponent.getNotificationDisplayTimeMultiplier() ? Toast.Visibility.HIDE : Toast.Visibility.SHOW); } } diff --git a/common/src/main/java/wily/legacy/mixin/ScreenMixin.java b/common/src/main/java/wily/legacy/mixin/ScreenMixin.java index 714c892e..ab8dec68 100644 --- a/common/src/main/java/wily/legacy/mixin/ScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ScreenMixin.java @@ -1,8 +1,8 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; @@ -33,17 +33,17 @@ public Screen self(){ } @Inject(method = "renderWithTooltip",at = @At("HEAD")) - private void renderWithTooltip(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci){ + private void renderWithTooltip(PoseStack poseStack, int i, int j, float f, CallbackInfo ci){ LegacyTipManager.tipDiffPercentage = Math.max(-0.5f,Math.min(LegacyTipManager.tipDiffPercentage + (LegacyTipManager.getActualTip() == null ? -0.1f : 0.08f) * minecraft.getDeltaFrameTime(),1.5f)); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(LegacyTipManager.getTipXDiff(),0,0); + poseStack.pose().pushPose(); + poseStack.pose().translate(LegacyTipManager.getTipXDiff(),0,0); } @Inject(method = "renderWithTooltip",at = @At("RETURN")) - private void renderWithTooltipReturn(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci){ - guiGraphics.pose().translate(-LegacyTipManager.getTipXDiff(),0,0); - guiGraphics.flush(); - ControlTooltip.Renderer.of(this).render(guiGraphics,i,j,f); - guiGraphics.pose().popPose(); + private void renderWithTooltipReturn(PoseStack poseStack, int i, int j, float f, CallbackInfo ci){ + poseStack.pose().translate(-LegacyTipManager.getTipXDiff(),0,0); + poseStack.flush(); + ControlTooltip.Renderer.of(this).render(poseStack,i,j,f); + poseStack.pose().popPose(); } @@ -56,8 +56,8 @@ private void onClose(CallbackInfo ci){ ScreenUtil.playSimpleUISound(LegacyRegistries.BACK.get(),1.0f); } @Inject(method = "renderBackground",at = @At("HEAD"), cancellable = true) - public void renderBackground(GuiGraphics guiGraphics, CallbackInfo ci) { - ScreenUtil.renderDefaultBackground(guiGraphics,false); + public void renderBackground(PoseStack poseStack, CallbackInfo ci) { + ScreenUtil.renderDefaultBackground(poseStack,false); ci.cancel(); } @Inject(method = "hasShiftDown",at = @At("HEAD"), cancellable = true) diff --git a/common/src/main/java/wily/legacy/mixin/SmithingScreenMixin.java b/common/src/main/java/wily/legacy/mixin/SmithingScreenMixin.java index 7559c707..2ccc0f9c 100644 --- a/common/src/main/java/wily/legacy/mixin/SmithingScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/SmithingScreenMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.screens.inventory.CyclingSlotBackground; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen; @@ -33,7 +33,7 @@ public abstract class SmithingScreenMixin extends ItemCombinerScreen 0) { if (getOffscreenRows() != startIndex) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.DOWN, 0, 79); + scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN, 0, 79); if (startIndex > 0) - scrollRenderer.renderScroll(guiGraphics, ScreenDirection.UP,0,-11); - }else guiGraphics.setColor(1.0f,1.0f,1.0f,0.5f); + scrollRenderer.renderScroll(poseStack, ScreenDirection.UP,0,-11); + }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,75); - guiGraphics.pose().translate(-2f, -1f + (this.isScrollBarActive() ? 61.5f * startIndex / getOffscreenRows() : 0), 0f); - LegacyGuiGraphics.of(guiGraphics).blitSprite(LegacySprites.PANEL,0,0, 16,16); - guiGraphics.setColor(1.0f,1.0f,1.0f,1.0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0, 0,13,75); + poseStack.pose().translate(-2f, -1f + (this.isScrollBarActive() ? 61.5f * startIndex / getOffscreenRows() : 0), 0f); + LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); + poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - guiGraphics.pose().popPose(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(leftPos + 71.5f,topPos + 19.5f,0); + poseStack.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate(leftPos + 71.5f,topPos + 19.5f,0); if (this.displayRecipes) { List list = this.menu.getRecipes(); block0: for (int p = 0; p < 4; ++p) { @@ -101,12 +101,12 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf if (s >= list.size()) break block0; int t = q * 18; int u = p * 18; - LegacyGuiGraphics.of(guiGraphics).blitSprite(s == menu.getSelectedRecipeIndex() ? BUTTON_SLOT_SELECTED : (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + t,topPos + 19.5f + u,18,18)? BUTTON_SLOT_HIGHLIGHTED : BUTTON_SLOT), t, u, 18, 18); - guiGraphics.renderItem(list.get(s).getResultItem(this.minecraft.level.registryAccess()), 1 + t, 1 + u); + LegacyGuiGraphics.of(poseStack).blitSprite(s == menu.getSelectedRecipeIndex() ? BUTTON_SLOT_SELECTED : (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + t,topPos + 19.5f + u,18,18)? BUTTON_SLOT_HIGHLIGHTED : BUTTON_SLOT), t, u, 18, 18); + poseStack.renderItem(list.get(s).getResultItem(this.minecraft.level.registryAccess()), 1 + t, 1 + u); } } } - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); } @Inject(method = "mouseClicked",at = @At("HEAD"), cancellable = true) public void mouseClicked(double d, double e, int i, CallbackInfoReturnable cir) { @@ -129,9 +129,9 @@ public void mouseClicked(double d, double e, int i, CallbackInfoReturnable list = this.menu.getRecipes(); block0: for (int p = 0; p < 4; ++p) { @@ -139,7 +139,7 @@ public void renderTooltip(GuiGraphics guiGraphics, int i, int j, CallbackInfo ci int r = p + this.startIndex; int s = r * 4 + q; if (s >= list.size()) break block0; - if (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + q * 18,topPos + 19.5f + p * 18,18,18)) guiGraphics.renderTooltip(this.font, list.get(s).getResultItem(this.minecraft.level.registryAccess()), i, j); + if (ScreenUtil.isMouseOver(i,j,leftPos + 73.5f + q * 18,topPos + 19.5f + p * 18,18,18)) poseStack.renderTooltip(this.font, list.get(s).getResultItem(this.minecraft.level.registryAccess()), i, j); } } } diff --git a/common/src/main/java/wily/legacy/mixin/TitleScreenMixin.java b/common/src/main/java/wily/legacy/mixin/TitleScreenMixin.java index 730e3f36..c3c1b8fd 100644 --- a/common/src/main/java/wily/legacy/mixin/TitleScreenMixin.java +++ b/common/src/main/java/wily/legacy/mixin/TitleScreenMixin.java @@ -1,12 +1,12 @@ package wily.legacy.mixin; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.LogoRenderer; -import net.minecraft.client.gui.components.SplashRenderer; import net.minecraft.client.gui.components.toasts.SystemToast; import net.minecraft.client.gui.screens.ConfirmScreen; +import net.minecraft.client.gui.screens.LoadingOverlay; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.network.chat.CommonComponents; @@ -32,15 +32,14 @@ import java.io.IOException; @Mixin(TitleScreen.class) -public abstract class TitleScreenMixin extends Screen implements ControlTooltip.Event{ +public abstract class TitleScreenMixin extends Screen implements ControlTooltip.Event { @Shadow @Final private static Logger LOGGER; @Shadow protected abstract boolean checkDemoWorldPresence(); @Shadow protected abstract void confirmDemo(boolean bl); - @Shadow @Nullable private SplashRenderer splash; - private RenderableVList renderableVList = new RenderableVList().layoutSpacing(l->5); + private RenderableVList renderableVList = new RenderableVList().layoutSpacing(l -> 5); protected TitleScreenMixin(Component component) { super(component); @@ -57,7 +56,6 @@ public void init(boolean bl, LogoRenderer logoRenderer, CallbackInfo ci) { renderableVList.addRenderable(Button.builder(Component.translatable("menu.quit"), (button) -> minecraft.setScreen(new ExitConfirmationScreen(this))).build()); } - @Inject(method = "init", at = @At("HEAD"), cancellable = true) protected void init(CallbackInfo ci) { ci.cancel(); @@ -125,14 +123,14 @@ public boolean keyPressed(int i, int j, int k) { } @Inject(method = "render", at = @At("HEAD"), cancellable = true) - public void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) { + public void render(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) { ci.cancel(); - ScreenUtil.renderDefaultBackground(guiGraphics,true,true); - super.render(guiGraphics, i, j, f); + ScreenUtil.renderDefaultBackground(poseStack,true,true); + super.render(poseStack, i, j, f); if (this.splash != null) { Legacy4JClient.legacyFont = false; - this.splash.render(guiGraphics, this.width, this.font, 255 << 24); + this.splash.render(poseStack, this.width, this.font, 255 << 24); Legacy4JClient.legacyFont = true; } } diff --git a/common/src/main/java/wily/legacy/mixin/ToastComponentMixin.java b/common/src/main/java/wily/legacy/mixin/ToastComponentMixin.java index 8a440607..6c41892e 100644 --- a/common/src/main/java/wily/legacy/mixin/ToastComponentMixin.java +++ b/common/src/main/java/wily/legacy/mixin/ToastComponentMixin.java @@ -2,7 +2,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.toasts.Toast; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -23,7 +22,7 @@ public abstract class ToastComponentMixin { @Shadow @Final private int index; @Inject(method = "render", at = @At("HEAD"), cancellable = true) - private void render(int i, GuiGraphics guiGraphics, CallbackInfoReturnable cir){ + private void render(int i, PoseStack poseStack, CallbackInfoReturnable cir){ if (!Legacy4JClient.isGameLoadFinished) cir.setReturnValue(false); } diff --git a/common/src/main/java/wily/legacy/mixin/TutorialToastMixin.java b/common/src/main/java/wily/legacy/mixin/TutorialToastMixin.java index 37338d55..ff748e64 100644 --- a/common/src/main/java/wily/legacy/mixin/TutorialToastMixin.java +++ b/common/src/main/java/wily/legacy/mixin/TutorialToastMixin.java @@ -1,6 +1,6 @@ package wily.legacy.mixin; -import net.minecraft.client.gui.GuiGraphics; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.components.toasts.RecipeToast; import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.TutorialToast; @@ -13,7 +13,7 @@ @Mixin(TutorialToast.class) public abstract class TutorialToastMixin implements Toast { @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lnet/minecraft/resources/ResourceLocation;IIIIII)V")) - public void render(GuiGraphics instance, ResourceLocation resourceLocation, int i, int j, int k, int l, int m, int n) { + public void render(PoseStack instance, ResourceLocation resourceLocation, int i, int j, int k, int l, int m, int n) { ScreenUtil.renderPointerPanel(instance,i,j,m,n); } } diff --git a/common/src/main/java/wily/legacy/util/ScreenUtil.java b/common/src/main/java/wily/legacy/util/ScreenUtil.java index 36ba7051..ab323a34 100644 --- a/common/src/main/java/wily/legacy/util/ScreenUtil.java +++ b/common/src/main/java/wily/legacy/util/ScreenUtil.java @@ -3,10 +3,10 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.LogoRenderer; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; @@ -49,19 +49,19 @@ public class ScreenUtil { public static final ResourceLocation PANORAMA_DAY = new ResourceLocation(Legacy4J.MOD_ID, "textures/gui/title/panorama_day.png"); public static final ResourceLocation PANORAMA_NIGHT = new ResourceLocation(Legacy4J.MOD_ID, "textures/gui/title/panorama_night.png"); - public static void renderPointerPanel(GuiGraphics graphics, int x, int y, int width, int height){ + public static void renderPointerPanel(PoseStack graphics, int x, int y, int width, int height){ RenderSystem.enableBlend(); RenderSystem.disableDepthTest(); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.POINTER_PANEL,x,y,width,height); RenderSystem.enableDepthTest(); RenderSystem.disableBlend(); } - public static void renderPanelTranslucentRecess(GuiGraphics graphics, int x, int y, int width, int height){ + public static void renderPanelTranslucentRecess(PoseStack graphics, int x, int y, int width, int height){ RenderSystem.enableBlend(); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.PANEL_TRANSLUCENT_RECESS,x,y,width,height); RenderSystem.disableBlend(); } - public static void renderTiles(ResourceLocation location,GuiGraphics graphics, int x, int y, int width, int height, float dp){ + public static void renderTiles(ResourceLocation location,PoseStack graphics, int x, int y, int width, int height, float dp){ mc.getTextureManager().getTexture(GUI_ATLAS).bind(); GlStateManager._texParameter(3553, 10241, 9729); //GlStateManager._texParameter(3553, 10240, 9729); @@ -73,7 +73,7 @@ public static void renderTiles(ResourceLocation location,GuiGraphics graphics, i graphics.pose().popPose(); GlStateManager._texParameter(3553, 10241, 9728); } - public static void drawAutoSavingIcon(GuiGraphics graphics,int x, int y) { + public static void drawAutoSavingIcon(PoseStack graphics,int x, int y) { graphics.pose().pushPose(); graphics.pose().scale(0.5F,0.5F,1); LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.SAVE_CHEST,x * 2,y * 2,48,48); @@ -84,46 +84,46 @@ public static void drawAutoSavingIcon(GuiGraphics graphics,int x, int y) { LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.SAVE_ARROW,0,0,13,16); graphics.pose().popPose(); } - public static void renderDefaultBackground(GuiGraphics guiGraphics){ - renderDefaultBackground(guiGraphics,false,true); + public static void renderDefaultBackground(PoseStack poseStack){ + renderDefaultBackground(poseStack,false,true); } - public static void renderDefaultBackground(GuiGraphics guiGraphics, boolean title){ - renderDefaultBackground(guiGraphics,false,title); + public static void renderDefaultBackground(PoseStack poseStack, boolean title){ + renderDefaultBackground(poseStack,false,title); } public static boolean getActualLevelNight(){ return (mc.getSingleplayerServer() != null&& mc.getSingleplayerServer().overworld() != null && mc.getSingleplayerServer().overworld().isNight()) || (mc.level!= null && mc.level.isNight()); } - public static void renderDefaultBackground(GuiGraphics guiGraphics, boolean forcePanorama, boolean title){ + public static void renderDefaultBackground(PoseStack poseStack, boolean forcePanorama, boolean title){ if (mc.level == null || forcePanorama) - renderPanoramaBackground(guiGraphics, forcePanorama && getActualLevelNight()); - else renderTransparentBackground(guiGraphics); + renderPanoramaBackground(poseStack, forcePanorama && getActualLevelNight()); + else renderTransparentBackground(poseStack); if (title) { if (Minecraft.getInstance().getResourceManager().getResource(MINECRAFT).isEmpty()) - logoRenderer.renderLogo(guiGraphics, mc.screen == null ? 0 : mc.screen.width, 1.0F); + logoRenderer.renderLogo(poseStack, mc.screen == null ? 0 : mc.screen.width, 1.0F); else { RenderSystem.enableBlend(); - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate((guiGraphics.guiWidth() - 285.5f) / 2, 30,0); - guiGraphics.pose().scale(0.5f,0.5f,0.5f); - guiGraphics.blit(MINECRAFT,0, 0,0,0, 571,138,571,138); - guiGraphics.pose().popPose(); + poseStack.pose().pushPose(); + poseStack.pose().translate((poseStack.guiWidth() - 285.5f) / 2, 30,0); + poseStack.pose().scale(0.5f,0.5f,0.5f); + poseStack.blit(MINECRAFT,0, 0,0,0, 571,138,571,138); + poseStack.pose().popPose(); RenderSystem.disableBlend(); } } } - public static void renderPanoramaBackground(GuiGraphics guiGraphics, boolean isNight){ + public static void renderPanoramaBackground(PoseStack poseStack, boolean isNight){ RenderSystem.depthMask(false); Minecraft.getInstance().getTextureManager().getTexture(isNight ? PANORAMA_NIGHT : PANORAMA_DAY).setFilter(true, false); - guiGraphics.blit(isNight ? PANORAMA_NIGHT : PANORAMA_DAY, 0, 0, mc.options.panoramaSpeed().get().floatValue() * Util.getMillis() / 66.32f, 1, guiGraphics.guiWidth(), guiGraphics.guiHeight() + 2, guiGraphics.guiHeight() * 820/144, guiGraphics.guiHeight() + 2); + poseStack.blit(isNight ? PANORAMA_NIGHT : PANORAMA_DAY, 0, 0, mc.options.panoramaSpeed().get().floatValue() * Util.getMillis() / 66.32f, 1, poseStack.guiWidth(), poseStack.guiHeight() + 2, poseStack.guiHeight() * 820/144, poseStack.guiHeight() + 2); RenderSystem.depthMask(true); } - public static void drawOutlinedString(GuiGraphics graphics, Font font, Component component, int x, int y, int color, int outlineColor, float outline) { + public static void drawOutlinedString(PoseStack graphics, Font font, Component component, int x, int y, int color, int outlineColor, float outline) { drawStringOutline(graphics,font,component,x,y,outlineColor,outline); graphics.drawString(font,component, x, y, color,false); } - public static void drawStringOutline(GuiGraphics graphics, Font font, Component component, int x, int y, int outlineColor, float outline) { + public static void drawStringOutline(PoseStack graphics, Font font, Component component, int x, int y, int outlineColor, float outline) { float[] translations = new float[]{0,outline,-outline}; for (float t : translations) { for (float t1 : translations) { @@ -139,16 +139,16 @@ public static void drawStringOutline(GuiGraphics graphics, Font font, Component public static boolean isMouseOver(double mouseX, double mouseY, double x, double y, int width, int height){ return mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height; } - public static void applyHUDScale(GuiGraphics graphics){ + public static void applyHUDScale(PoseStack graphics){ graphics.pose().scale(3f / getHUDScale(), 3f / getHUDScale() ,3f / getHUDScale()); } - public static void prepareHUDRender(GuiGraphics graphics){ + public static void prepareHUDRender(PoseStack graphics){ graphics.pose().pushPose(); graphics.setColor(1.0f,1.0f,1.0f,getHUDOpacity()); graphics.pose().translate(0,getHUDDistance(),0); RenderSystem.enableBlend(); } - public static void finishHUDRender(GuiGraphics graphics){ + public static void finishHUDRender(PoseStack graphics){ graphics.pose().popPose(); graphics.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); @@ -245,7 +245,7 @@ public static LegacyOptions getLegacyOptions(){ return (LegacyOptions) mc.options; } - public static void drawGenericLoading(GuiGraphics graphics,int x, int y) { + public static void drawGenericLoading(PoseStack graphics,int x, int y) { RenderSystem.enableBlend(); for (int i = 0; i < 8; i++) { int v = (i + 1) * 100; @@ -260,13 +260,13 @@ public static void drawGenericLoading(GuiGraphics graphics,int x, int y) { RenderSystem.disableBlend(); RenderSystem.setShaderColor(1.0f,1.0f,1.0f,1.0f); } - public static void renderScrollingString(GuiGraphics guiGraphics, Font font, Component component, int j, int k, int l, int m, int n, boolean shadow) { - renderScrollingString(guiGraphics,font,component.getVisualOrderText(),j,k,l,m,n,shadow); + public static void renderScrollingString(PoseStack poseStack, Font font, Component component, int j, int k, int l, int m, int n, boolean shadow) { + renderScrollingString(poseStack,font,component.getVisualOrderText(),j,k,l,m,n,shadow); } - public static void renderScrollingString(GuiGraphics guiGraphics, Font font, FormattedCharSequence charSequence, int j, int k, int l, int m, int n, boolean shadow) { - renderScrollingString(guiGraphics,font,charSequence,j,k,l,m,n,shadow,font.width(charSequence)); + public static void renderScrollingString(PoseStack poseStack, Font font, FormattedCharSequence charSequence, int j, int k, int l, int m, int n, boolean shadow) { + renderScrollingString(poseStack,font,charSequence,j,k,l,m,n,shadow,font.width(charSequence)); } - public static void renderScrollingString(GuiGraphics guiGraphics, Font font, FormattedCharSequence charSequence, int j, int k, int l, int m, int n, boolean shadow, int stringWidth) { + public static void renderScrollingString(PoseStack poseStack, Font font, FormattedCharSequence charSequence, int j, int k, int l, int m, int n, boolean shadow, int stringWidth) { int p = (k + m - font.lineHeight) / 2 + 1; int q = l - j; if (stringWidth > q) { @@ -275,14 +275,14 @@ public static void renderScrollingString(GuiGraphics guiGraphics, Font font, For double e = Math.max((double)r * 0.5, 3.0); double f = Math.sin(1.5707963267948966 * Math.cos(Math.PI * 2 * d / e)) / 2.0 + 0.5; double g = Mth.lerp(f, 0.0, r); - guiGraphics.enableScissor(j, k, l, m); - guiGraphics.drawString(font, charSequence, j - (int)g, p, n,shadow); - guiGraphics.disableScissor(); + poseStack.enableScissor(j, k, l, m); + poseStack.drawString(font, charSequence, j - (int)g, p, n,shadow); + poseStack.disableScissor(); } else { - guiGraphics.drawString(font, charSequence, j, p, n,shadow); + poseStack.drawString(font, charSequence, j, p, n,shadow); } } - public static void secureTranslucentRender(GuiGraphics graphics, boolean translucent, float alpha, Consumer render){ + public static void secureTranslucentRender(PoseStack graphics, boolean translucent, float alpha, Consumer render){ if (!translucent){ render.accept(false); return; @@ -303,16 +303,16 @@ public static boolean isHovering(Slot slot,int leftPos, int topPos, double d, d double yCorner = holder.getYCorner() + holder.offset.y(); return (d -= leftPos) >= xCorner && d < (xCorner + width) && (e -= topPos) >= yCorner && e < (yCorner + height); } - public static void renderEntity(GuiGraphics guiGraphics, float x, float y, int size, float partialTicks, Vector3f vector3f, Quaternionf quaternionf, @Nullable Quaternionf quaternionf2, Entity entity) { - renderEntity(guiGraphics,x,y,size,partialTicks,vector3f,quaternionf,quaternionf2,entity,false); + public static void renderEntity(PoseStack poseStack, float x, float y, int size, float partialTicks, Vector3f vector3f, Quaternionf quaternionf, @Nullable Quaternionf quaternionf2, Entity entity) { + renderEntity(poseStack,x,y,size,partialTicks,vector3f,quaternionf,quaternionf2,entity,false); } - public static void renderEntity(GuiGraphics guiGraphics, float x, float y, int size, float partialTicks, Vector3f vector3f, Quaternionf quaternionf, @Nullable Quaternionf quaternionf2, Entity entity, boolean forceSize) { - guiGraphics.pose().pushPose(); - guiGraphics.pose().translate(x, y, 50.0); + public static void renderEntity(PoseStack poseStack, float x, float y, int size, float partialTicks, Vector3f vector3f, Quaternionf quaternionf, @Nullable Quaternionf quaternionf2, Entity entity, boolean forceSize) { + poseStack.pose().pushPose(); + poseStack.pose().translate(x, y, 50.0); float h = forceSize ? Math.max(1f,Math.max(entity.getBbWidth(), entity.getBbHeight())) : 1; - guiGraphics.pose().mulPoseMatrix(new Matrix4f().scaling(size / h, size / h, -size / h)); - guiGraphics.pose().translate(vector3f.x, vector3f.y, vector3f.z); - guiGraphics.pose().mulPose(quaternionf); + poseStack.pose().mulPoseMatrix(new Matrix4f().scaling(size / h, size / h, -size / h)); + poseStack.pose().translate(vector3f.x, vector3f.y, vector3f.z); + poseStack.pose().mulPose(quaternionf); Lighting.setupForEntityInInventory(); EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher(); if (quaternionf2 != null) { @@ -320,16 +320,16 @@ public static void renderEntity(GuiGraphics guiGraphics, float x, float y, int s entityRenderDispatcher.overrideCameraOrientation(quaternionf2); } entityRenderDispatcher.setRenderShadow(false); - RenderSystem.runAsFancy(() -> entityRenderDispatcher.render(entity, 0.0, 0.0, 0.0, 0.0f, partialTicks, guiGraphics.pose(), guiGraphics.bufferSource(), 0xF000F0)); - guiGraphics.flush(); + RenderSystem.runAsFancy(() -> entityRenderDispatcher.render(entity, 0.0, 0.0, 0.0, 0.0f, partialTicks, poseStack.pose(), poseStack.bufferSource(), 0xF000F0)); + poseStack.flush(); entityRenderDispatcher.setRenderShadow(true); - guiGraphics.pose().popPose(); + poseStack.pose().popPose(); Lighting.setupFor3DItems(); } - public static void renderEntityInInventoryFollowsMouse(GuiGraphics guiGraphics, int i, int j, int k, int l, int m, float f, float g, float h, LivingEntity livingEntity) { + public static void renderEntityInInventoryFollowsMouse(PoseStack poseStack, int i, int j, int k, int l, int m, float f, float g, float h, LivingEntity livingEntity) { float n = (float)(i + k) / 2.0f; float o = (float)(j + l) / 2.0f; - guiGraphics.enableScissor(i, j, k, l); + poseStack.enableScissor(i, j, k, l); float p = (float)Math.atan((n - g) / 40.0f); float q = (float)Math.atan((o - h) / 40.0f); Quaternionf quaternionf = new Quaternionf().rotateZ((float)Math.PI); @@ -346,13 +346,13 @@ public static void renderEntityInInventoryFollowsMouse(GuiGraphics guiGraphics, livingEntity.yHeadRot = livingEntity.getYRot(); livingEntity.yHeadRotO = livingEntity.getYRot(); Vector3f vector3f = new Vector3f(0.0f, livingEntity.getBbHeight() / 2.0f + f, 0.0f); - renderEntity(guiGraphics, n, o, m,1, vector3f, quaternionf, quaternionf2, livingEntity); + renderEntity(poseStack, n, o, m,1, vector3f, quaternionf, quaternionf2, livingEntity); livingEntity.yBodyRot = r; livingEntity.setYRot(s); livingEntity.setXRot(t); livingEntity.yHeadRotO = u; livingEntity.yHeadRot = v; - guiGraphics.disableScissor(); + poseStack.disableScissor(); } public static int getStandardHeight(){ return Math.round(mc.getWindow().getHeight() / 180f) * 180; @@ -366,7 +366,7 @@ public static Component getDimensionName(ResourceKey dimension){ String s = dimension.location().toLanguageKey("dimension"); return Component.translatable(hasTip(s) ? s : "dimension.minecraft"); } - public static void renderTransparentBackground(GuiGraphics graphics){ + public static void renderTransparentBackground(PoseStack graphics){ graphics.fillGradient(0,0,graphics.guiWidth(),graphics.guiHeight(), -1073741824, -805306368);; } } diff --git a/gradle.properties b/gradle.properties index 5d35d9c4..3e6578c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx2048M -minecraft_version=1.20.1 +minecraft_version=1.19.4 enabled_platforms=fabric,forge archives_base_name=Legacy4J @@ -15,13 +15,13 @@ mod_authors=Wilyicaro mod_credits=4J Studios and Mojang maven_group=wily.legacy -architectury_version=9.2.14 +architectury_version=8.2.91 -fabric_loader_version=0.15.6 -fabric_api_version=0.92.2+1.20.1 -forge_version=1.20.1-47.3.0 +fabric_loader_version=0.16.3 +fabric_api_version=0.87.2+1.19.4 +forge_version=1.19.4-45.3.0 -sdl_dependency=dev.isxander:libsdl4j:3.693c75e-36 +sdl_dependency=dev.isxander:libsdl4j:3.6896c4c-38 curseforge_id=955526 modrinth_id=gHvKJofA From d430655d109523d22c4747d7f311f3fa5cdbf7a9 Mon Sep 17 00:00:00 2001 From: aric3435 <157071384+arichornloverALT@users.noreply.github.com> Date: Fri, 30 Aug 2024 20:17:35 -0500 Subject: [PATCH 2/6] fix KeyboardScreen.java (1.19.4 Port) --- .../java/wily/legacy/client/screen/KeyboardScreen.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java index 466a09ab..a7be2c06 100644 --- a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java @@ -127,8 +127,12 @@ public void addControlTooltips(ControlTooltip.Renderer renderer) { renderer.add(()-> ControlType.getActiveType().isKbm() ? null : ControllerBinding.RIGHT_STICK.bindingState.getIcon(), ()-> ControlTooltip.getAction("legacy.action.move_keyboard")); } + private static boolean isSpaceOrEnterPressed(int keyCode) { + return keyCode == InputConstants.KEY_SPACE || keyCode == InputConstants.KEY_RETURN; + } + public static boolean isOpenKey(int i){ - return CommonInputs.selected(i) && i != InputConstants.KEY_SPACE; + return isSpaceOrEnterPressed(i) && i != InputConstants.KEY_SPACE; } public static KeyboardScreen fromEditBox(int ordinal, Screen parent){ return new KeyboardScreen(()->getScreenActualEditBox(ordinal,parent),parent); @@ -368,7 +372,7 @@ public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) { @Override public boolean keyReleased(int i, int j, int k) { - if (this.active && this.visible && CommonInputs.selected(i) && pressTime > 0) { + if (this.active && this.visible && isSpaceOrEnterPressed(i) && pressTime > 0) { this.onRelease(); return true; } else { From 7cd5b2af2ad46bdfc1d2de9f1cdc47712982e064 Mon Sep 17 00:00:00 2001 From: aric3435 <157071384+arichornloverALT@users.noreply.github.com> Date: Sat, 31 Aug 2024 01:49:33 -0500 Subject: [PATCH 3/6] Improvements to PoseStack --- .../wily/legacy/client/screen/BookPanel.java | 20 ++++---- .../legacy/client/screen/ControlTooltip.java | 17 +++---- .../client/screen/CreativeModeScreen.java | 8 ++-- .../client/screen/CustomRecipeIconHolder.java | 4 +- .../legacy/client/screen/DisplayRecipe.java | 8 ++-- .../client/screen/FlatWorldLayerSelector.java | 14 +++--- .../legacy/client/screen/KeyboardScreen.java | 18 ++++---- .../client/screen/LeaderboardsScreen.java | 46 +++++++++---------- .../screen/LegacyAdvancementsScreen.java | 14 +++--- .../screen/LegacyBuffetWorldScreen.java | 8 ++-- .../client/screen/LegacyCraftingScreen.java | 12 ++--- .../screen/LegacyFlatPresetsScreen.java | 8 ++-- .../client/screen/LegacyFlatWorldScreen.java | 16 +++---- .../client/screen/LegacyIconHolder.java | 34 +++++++------- .../client/screen/LegacyLoadingScreen.java | 4 +- .../client/screen/LegacyLoomScreen.java | 12 ++--- .../client/screen/LegacyMerchantScreen.java | 22 ++++----- .../legacy/client/screen/LegacyTabButton.java | 12 ++--- .../legacy/client/screen/LoadSaveScreen.java | 12 ++--- .../client/screen/OverlayPanelScreen.java | 2 +- .../legacy/client/screen/PlayGameScreen.java | 14 +++--- .../client/screen/RecipeIconHolder.java | 12 ++--- .../client/screen/ScrollableRenderer.java | 6 +-- .../client/screen/ServerRenderableList.java | 8 ++-- 24 files changed, 166 insertions(+), 165 deletions(-) diff --git a/common/src/main/java/wily/legacy/client/screen/BookPanel.java b/common/src/main/java/wily/legacy/client/screen/BookPanel.java index 1db27e87..77cebc2c 100644 --- a/common/src/main/java/wily/legacy/client/screen/BookPanel.java +++ b/common/src/main/java/wily/legacy/client/screen/BookPanel.java @@ -22,11 +22,11 @@ public BookPanel(Screen screen) { } @Override public void render(PoseStack poseStack, int i, int j, float f) { - poseStack.pose().pushPose(); - poseStack.pose().translate(getX(),getY(),0); - poseStack.pose().scale(getWidth() / 146f,getHeight() / 180f,1f); + poseStack.pushPose(); + poseStack.translate(getX(),getY(),0); + poseStack.scale(getWidth() / 146f,getHeight() / 180f,1f); poseStack.blit(BookViewScreen.BOOK_LOCATION,0,0,20,1,146,180); - poseStack.pose().popPose(); + poseStack.popPose(); } public PageButton createLegacyPageButton(int i, int j, boolean bl, Button.OnPress onPress, boolean bl2){ return new PageButton(i,j,bl,onPress,bl2){ @@ -34,12 +34,12 @@ public PageButton createLegacyPageButton(int i, int j, boolean bl, Button.OnPres @Override public void renderWidget(PoseStack poseStack, int i, int j, float f) { isHovered = Util.getMillis() - lastPressTime <= 300 || clicked(i,j); - poseStack.pose().pushPose(); - poseStack.pose().translate(getX(),getY(),1.5f); - poseStack.pose().scale(1.5f,1.5f,1.5f); - poseStack.pose().translate(-getX(),-getY(),1.5f); + poseStack.pushPose(); + poseStack.translate(getX(),getY(),1.5f); + poseStack.scale(1.5f,1.5f,1.5f); + poseStack.translate(-getX(),-getY(),1.5f); super.renderWidget(poseStack, i, j, f); - poseStack.pose().popPose(); + poseStack.popPose(); } @Override @@ -65,4 +65,4 @@ protected boolean clicked(double d, double e) { } }; } -} +} \ No newline at end of file diff --git a/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java b/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java index 718bf205..79cbcd83 100644 --- a/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java +++ b/common/src/main/java/wily/legacy/client/screen/ControlTooltip.java @@ -64,6 +64,7 @@ import wily.legacy.Legacy4JClient; import wily.legacy.client.CommonColor; import wily.legacy.client.ControlType; +import wily.legacy.client.LegacyGuiGraphics; import wily.legacy.client.controller.ControllerBinding; import wily.legacy.client.controller.LegacyKeyMapping; import wily.legacy.util.JsonUtil; @@ -181,20 +182,20 @@ public int render(PoseStack graphics, int x, int y, boolean allowPressed, boolea lastPressed = pressed(); if (!simulate && c != null) { - graphics.drawString(font,c,x + (co == null || cw > cow ? 0 : (cow - cw) / 2),y,0xFFFFFF,false); + guiGraphics.self().drawString(font, c, x + (co == null || cw > cow ? 0 : (cow - cw) / 2), y, 0xFFFFFF, false); } if (!simulate && co != null){ float rel = startPressTime == 0 ? 0 : canLoop() ? getPressInterval() % 1 : Math.min(getPressInterval(),1); float d = 1 - Math.max(0,(rel >= 0.5f ? 1 - rel: rel) * 2/5); - graphics.pose().pushPose(); - graphics.pose().translate(x + (c == null || cow > cw ? (cow - cow * d) / 2 : (cw - cow * d) / 2f),y + (9 - 9 * d) / 2 ,0); - graphics.pose().scale(d,d,d); + graphics.pushPose(); + graphics.translate(x + (c == null || cow > cw ? (cow - cow * d) / 2 : (cw - cow * d) / 2f), y + (9 - 9 * d) / 2, 0); + graphics.scale(d, d, d); float alpha = RenderSystem.getShaderColor()[3]; - graphics.setColor(1.0f,1.0f,1.0f,alpha * (0.8f + (rel >= 0.5f ? 0.2f : 0))); - graphics.drawString(font,co,0,0,0xFFFFFF,false); - graphics.setColor(1.0f,1.0f,1.0f,alpha); - graphics.pose().popPose(); + guiGraphics.setColor(1.0f, 1.0f, 1.0f, alpha * (0.8f + (rel >= 0.5f ? 0.2f : 0))); + guiGraphics.self().drawString(font, co, 0, 0, 0xFFFFFF, false); + guiGraphics.setColor(1.0f, 1.0f, 1.0f, alpha); + graphics.popPose(); } return Math.max(cw,cow); } diff --git a/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java b/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java index c2c03765..42b8e3e3 100644 --- a/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/CreativeModeScreen.java @@ -142,8 +142,8 @@ public void renderBackground(PoseStack poseStack) { @Override public void render(PoseStack poseStack, int i, int j, float f) { super.render(poseStack, i, j, f); - poseStack.pose().pushPose(); - poseStack.pose().translate(leftPos + 296.5f, topPos + 27.5f, 0f); + poseStack.pushPose(); + poseStack.translate(leftPos + 296.5f, topPos + 27.5f, 0f); Stocker.Sizeable scroll = tabsScrolledList.get(page.get() * 8 + tabList.selectedTab); if (scroll.max > 0) { if (scroll.get() != scroll.max) @@ -153,11 +153,11 @@ public void render(PoseStack poseStack, int i, int j, float f) { }else poseStack.setColor(1.0f,1.0f,1.0f,0.5f); RenderSystem.enableBlend(); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, 0, 0,13,135); - poseStack.pose().translate(-2f, -1f + (scroll.max > 0 ? scroll.get() * 121.5f / scroll.max : 0), 0f); + poseStack.translate(-2f, -1f + (scroll.max > 0 ? scroll.get() * 121.5f / scroll.max : 0), 0f); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - poseStack.pose().popPose(); + poseStack.popPose(); this.renderTooltip(poseStack, i, j); } diff --git a/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java b/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java index e1f88b81..9dad674e 100644 --- a/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java +++ b/common/src/main/java/wily/legacy/client/screen/CustomRecipeIconHolder.java @@ -177,12 +177,12 @@ public void renderSelection(PoseStack graphics, int i, int j, float f) { Slot s = a.getMenu().getSlot(findInventoryMatchSlot()); ScreenUtil.iconHolderRenderer.slotBounds(a.getMenuRectangle().left(),a.getMenuRectangle().top(),s).renderHighlight(graphics); } - graphics.pose().pushPose(); + graphics.pushPose(); applyOffset(graphics); if (!previousItem.isEmpty() && previousItem!=itemIcon || !nextItem.isEmpty() && nextItem!=itemIcon){ getScrollRenderer().renderScroll(graphics, ScreenDirection.UP,getX() + 5,getY() - 14); getScrollRenderer().renderScroll(graphics, ScreenDirection.DOWN,getX() + 5,getY() + 31); } - graphics.pose().popPose(); + graphics.popPose(); } } \ No newline at end of file diff --git a/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java b/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java index 49a7852b..4cdedf87 100644 --- a/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java +++ b/common/src/main/java/wily/legacy/client/screen/DisplayRecipe.java @@ -32,10 +32,10 @@ public void render(PoseStack poseStack, Minecraft minecraft, int leftPos, int to for (int k = 0; k < this.ingredients.size(); ++k) { GhostIngredient ghostIngredient = this.ingredients.get(k); LegacyIconHolder holder = ScreenUtil.iconHolderRenderer.slotBounds(ingredientSlots.get(k)); - poseStack.pose().pushPose(); - poseStack.pose().translate(ghostIngredient.getX() + leftPos, ghostIngredient.getY() + topPos, 0); + poseStack.pushPose(); + poseStack.translate(ghostIngredient.getX() + leftPos, ghostIngredient.getY() + topPos, 0); holder.applyOffset(poseStack); - poseStack.pose().scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); + poseStack.scale(holder.getSelectableWidth() / 16f,holder.getSelectableHeight() / 16f,holder.getSelectableHeight() / 16f); poseStack.fill(0, 0, 16, 16, 0x30FF0000); ItemStack itemStack = ghostIngredient.getItem(); @@ -43,7 +43,7 @@ public void render(PoseStack poseStack, Minecraft minecraft, int leftPos, int to poseStack.fill(RenderType.guiGhostRecipeOverlay(), 0, 0, 16,16, 0x30FFFFFF); if (k == 0) poseStack.renderItemDecorations(minecraft.font, itemStack, 0, 0); - poseStack.pose().popPose(); + poseStack.popPose(); } } } diff --git a/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java b/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java index 0bc4be20..984960f7 100644 --- a/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java +++ b/common/src/main/java/wily/legacy/client/screen/FlatWorldLayerSelector.java @@ -183,14 +183,14 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) poseStack.drawString(this.font, layerCount,panel.x + 49 - font.width(layerCount),panel. y + 197, 0xFFFFFF, true); poseStack.drawString(this.font, selectedLayer.getItem().getDescription(),panel.x + 70,panel. y + 197, 0xFFFFFF, true); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + 50, panel.y + 190,0); - poseStack.pose().scale(1.25f,1.25f,1.25f); + poseStack.pushPose(); + poseStack.translate(panel.x + 50, panel.y + 190,0); + poseStack.scale(1.25f,1.25f,1.25f); poseStack.renderItem(selectedLayer,0, 0); - poseStack.pose().popPose(); + poseStack.popPose(); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + 299.5, panel.y + 23, 0f); + poseStack.pushPose(); + poseStack.translate(panel.x + 299.5, panel.y + 23, 0f); if (scrolledList.max > 0) { if (scrolledList.get() != scrolledList.max) scrollRenderer.renderScroll(poseStack, ScreenDirection.DOWN, 0, 139); @@ -203,7 +203,7 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL,0,0, 16,16); poseStack.setColor(1.0f,1.0f,1.0f,1.0f); RenderSystem.disableBlend(); - poseStack.pose().popPose(); + poseStack.popPose(); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java index a7be2c06..8a2c13d6 100644 --- a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java @@ -185,20 +185,20 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) RenderSystem.enableBlend(); poseStack.setColor(1f,1f,1f,0.8f); panel.render(poseStack,i,j,f); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.getX() + 4.5f,panel.getY() + 25.5,0); + poseStack.pushPose(); + poseStack.translate(panel.getX() + 4.5f,panel.getY() + 25.5,0); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,0,0,53, 123); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,panel.getWidth() - 62,0,53, 123); - poseStack.pose().translate(-4.5f,0,0); + poseStack.translate(-4.5f,0,0); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS,(panel.getWidth() - 267) / 2,-1,267, 125); - poseStack.pose().popPose(); + poseStack.popPose(); RenderSystem.disableBlend(); poseStack.setColor(1f,1f,1f,1f); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.getX() + (panel.getWidth() - font.width(KEYBOARD) * 1.5f) / 2,panel.getY() + 8,0); - poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.pushPose(); + poseStack.translate(panel.getX() + (panel.getWidth() - font.width(KEYBOARD) * 1.5f) / 2,panel.getY() + 8,0); + poseStack.scale(1.5f,1.5f,1.5f); poseStack.drawString(font,KEYBOARD,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - poseStack.pose().popPose(); + poseStack.popPose(); } public record CharButtonBuilder(int width, String chars, String shiftChars, ControllerBinding binding, ResourceLocation iconSprite, SoundEvent downSound){ @@ -423,4 +423,4 @@ public void bindingStateTick(BindingState state) { public boolean onceClickBindings() { return false; } -} +} \ No newline at end of file diff --git a/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java b/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java index adc3635e..edf57da0 100644 --- a/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LeaderboardsScreen.java @@ -186,27 +186,27 @@ protected void init() { ScreenUtil.renderPointerPanel(poseStack,panel.x + panel.width - 174 ,panel.y - 18,166,18); if (!statsBoards.isEmpty() && selectedStatBoard < statsBoards.size()){ StatsBoard board = statsBoards.get(selectedStatBoard); - poseStack.pose().pushPose(); + poseStack.pushPose(); Component filter = Component.translatable("legacy.menu.leaderboard.filter", myScore ? MY_SCORE : LegacyKeyBindsScreen.NONE); - poseStack.pose().translate(panel.x + 91 - font.width(filter) / 4f, panel.y - 12,0); - poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.translate(panel.x + 91 - font.width(filter) / 4f, panel.y - 12,0); + poseStack.scale(2/3f,2/3f,2/3f); poseStack.drawString(font,filter,0, 0,0xFFFFFF); - poseStack.pose().popPose(); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + (panel.width - font.width(board.displayName) / 2f) / 2, panel.y - 12,0); - poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.popPose(); + poseStack.pushPose(); + poseStack.translate(panel.x + (panel.width - font.width(board.displayName) / 2f) / 2, panel.y - 12,0); + poseStack.scale(2/3f,2/3f,2/3f); poseStack.drawString(font,board.displayName,0, 0,0xFFFFFF); - poseStack.pose().popPose(); - poseStack.pose().pushPose(); + poseStack.popPose(); + poseStack.pushPose(); Component entries = Component.translatable("legacy.menu.leaderboard.entries",actualRankBoard.size()); - poseStack.pose().translate(panel.x + 477 - font.width(entries) / 4f, panel.y - 12,0); - poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.translate(panel.x + 477 - font.width(entries) / 4f, panel.y - 12,0); + poseStack.scale(2/3f,2/3f,2/3f); poseStack.drawString(font,entries,0, 0,0xFFFFFF); - poseStack.pose().popPose(); + poseStack.popPose(); RenderSystem.enableBlend(); - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + (panel.width - 211) / 2f, panel.y - 12,0); - poseStack.pose().scale(0.5f,0.5f,0.5f); + poseStack.pushPose(); + poseStack.translate(panel.x + (panel.width - 211) / 2f, panel.y - 12,0); + poseStack.scale(0.5f,0.5f,0.5f); (ControlType.getActiveType().isKbm() ? ControlTooltip.COMPOUND_ICON_FUNCTION.apply(new ControlTooltip.Icon[]{ControlTooltip.getKeyIcon(InputConstants.KEY_LEFT),ControlTooltip.SPACE_ICON, ControlTooltip.getKeyIcon(InputConstants.KEY_RIGHT)}) : ControllerBinding.LEFT_STICK.bindingState.getIcon()).render(poseStack,4,0,false, false); if (statsInScreen < statsBoards.get(selectedStatBoard).renderables.size()) { ControlTooltip.Icon pageControl = ControlTooltip.COMPOUND_ICON_FUNCTION.apply(new ControlTooltip.Icon[]{ControlType.getActiveType().isKbm() ? ControlTooltip.getKeyIcon(InputConstants.KEY_LBRACKET) : ControllerBinding.LEFT_BUMPER.bindingState.getIcon(), ControlTooltip.SPACE_ICON, ControlType.getActiveType().isKbm() ? ControlTooltip.getKeyIcon(InputConstants.KEY_RBRACKET) : ControllerBinding.RIGHT_BUMPER.bindingState.getIcon()}); @@ -215,11 +215,11 @@ protected void init() { poseStack.pose().popPose(); RenderSystem.disableBlend(); if (board.statsList.isEmpty()) { - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + (panel.width - font.width(NO_RESULTS) * 1.5f)/2f, panel.y + (panel.height - 13.5f) / 2f,0); - poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.pushPose(); + poseStack.translate(panel.x + (panel.width - font.width(NO_RESULTS) * 1.5f)/2f, panel.y + (panel.height - 13.5f) / 2f,0); + poseStack.scale(1.5f,1.5f,1.5f); poseStack.drawString(font,NO_RESULTS,0,0, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - poseStack.pose().popPose(); + poseStack.popPose(); return; } poseStack.drawString(font,RANK,panel.x + 40, panel.y + 20,CommonColor.INVENTORY_GRAY_TEXT.get(),false); @@ -283,11 +283,11 @@ public SimpleLayoutRenderable getRenderable(Stat stat){ } Component name = Component.translatable("stat." + stat.getValue().toString().replace(':', '.')); return SimpleLayoutRenderable.create(Minecraft.getInstance().font.width(name) * 2/3 + 2,7, (l)->((poseStack, i, j, f) -> { - poseStack.pose().pushPose(); - poseStack.pose().translate(l.getX() + 1,l.getY(),0); - poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.pushPose(); + poseStack.translate(l.getX() + 1,l.getY(),0); + poseStack.scale(2/3f,2/3f,2/3f); poseStack.drawString(Minecraft.getInstance().font,name,0,0,CommonColor.INVENTORY_GRAY_TEXT.get(),false); - poseStack.pose().popPose(); + poseStack.popPose(); })); } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java index ae82e683..446d8057 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyAdvancementsScreen.java @@ -89,10 +89,10 @@ protected void addAdvancementButton(Advancement root, Advancement node){ protected void renderWidget(PoseStack poseStack, int i, int j, float f) { if (isFocused()) { selectedAdvancement = node; - poseStack.pose().pushPose(); - poseStack.pose().translate(-1.5f, -1.5f, 0); + poseStack.pushPose(); + poseStack.translate(-1.5f, -1.5f, 0); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_HIGHLIGHT, getX(), getY(), 41, 41); - poseStack.pose().popPose(); + poseStack.popPose(); } RenderSystem.enableBlend(); if (!unlocked) poseStack.setColor(1.0f, 1.0f, 1.0f, 0.5f); @@ -104,11 +104,11 @@ protected void renderWidget(PoseStack poseStack, int i, int j, float f) { RenderSystem.disableBlend(); poseStack.setColor(1.0f, 1.0f, 1.0f, 1.0f); if (!unlocked) return; - poseStack.pose().pushPose(); - poseStack.pose().translate(getX() + (getWidth() - 32) / 2f, getY() + (getHeight() - 32) / 2f, 0); - poseStack.pose().scale(2f, 2f, 2f); + poseStack.pushPose(); + poseStack.translate(getX() + (getWidth() - 32) / 2f, getY() + (getHeight() - 32) / 2f, 0); + poseStack.scale(2f, 2f, 2f); poseStack.renderFakeItem(info.getIcon(), 0, 0); - poseStack.pose().popPose(); + poseStack.popPose(); } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java index fa5412a1..6dd5c19c 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyBuffetWorldScreen.java @@ -45,11 +45,11 @@ protected void renderWidget(PoseStack poseStack, int i, int j, float f) { super.renderWidget(poseStack, i, j, f); ItemStack s = LegacyBiomeOverride.getOrDefault(biome.unwrapKey()).icon(); if (!s.isEmpty()){ - poseStack.pose().pushPose(); - poseStack.pose().translate(getX() + 26, getY() + 5,0); - poseStack.pose().scale(1.25f,1.25f,1.25f); + poseStack.pushPose(); + poseStack.translate(getX() + 26, getY() + 5,0); + poseStack.scale(1.25f,1.25f,1.25f); poseStack.renderItem(s,0, 0); - poseStack.pose().popPose(); + poseStack.popPose(); } RenderSystem.enableBlend(); LegacyGuiGraphics.of(poseStack).blitSprite(TickBox.SPRITES[isHoveredOrFocused() ? 1 : 0], this.getX() + 6, this.getY() + (height - 12) / 2, 12, 12); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java index 11855a24..26b69ff8 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyCraftingScreen.java @@ -382,20 +382,20 @@ protected void renderLabels(PoseStack poseStack, int i, int j) { if (i1 > 4) break; ItemStack ing = compactItemStackList.get(i1); ScreenUtil.iconHolderRenderer.itemHolder(180, 124 + 15 * i1, 14, 14, ing, false, Offset.ZERO).render(poseStack, i, j, 0); - poseStack.pose().pushPose(); - poseStack.pose().translate(198, 128 + 15 * i1, 0); - poseStack.pose().scale(2 / 3f, 2 / 3f, 2 / 3f); + poseStack.pushPose(); + poseStack.translate(198, 128 + 15 * i1, 0); + poseStack.scale(2 / 3f, 2 / 3f, 2 / 3f); poseStack.drawString(font, ing.getHoverName(), 0, 0, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - poseStack.pose().popPose(); + poseStack.popPose(); } } } } } - poseStack.pose().translate(-leftPos,-topPos,0); + poseStack.translate(-leftPos,-topPos,0); getCraftingButtons().forEach(b-> b.render(poseStack,i,j,0)); if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(poseStack, i, j, 0); - poseStack.pose().translate(leftPos,topPos,0); + poseStack.translate(leftPos,topPos,0); } @Override diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java index 44c542cf..a62ac2e6 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyFlatPresetsScreen.java @@ -35,11 +35,11 @@ public LegacyFlatPresetsScreen(Screen parent, HolderLookup.RegistryLookupgraphics.fillGradient(RenderType.gui(), 0, 0, 16,16, color, color, h)); } public void renderScaled(PoseStack graphics, float x, float y, Runnable render){ - graphics.pose().pushPose(); - graphics.pose().translate(x,y,0); + graphics.pushPose(); + graphics.translate(x,y,0); applyOffset(graphics); - graphics.pose().scale(getSelectableWidth() / 16f,getSelectableHeight() / 16f,getSelectableHeight() / 16f); + graphics.scale(getSelectableWidth() / 16f,getSelectableHeight() / 16f,getSelectableHeight() / 16f); render.run(); - graphics.pose().popPose(); + graphics.popPose(); } public void renderHighlight(PoseStack graphics, int h){ renderHighlight(graphics,-2130706433,h); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java index 564624e9..4de5e797 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyLoadingScreen.java @@ -90,10 +90,10 @@ public void render(PoseStack poseStack, int i, int j, float f) { } }else ScreenUtil.drawGenericLoading(poseStack,(width - 75 )/ 2, height / 2); - poseStack.pose().scale(2.0F,2.0F,1.0F); + poseStack.scale(2.0F,2.0F,1.0F); if (lastLoadingHeader != null) ScreenUtil.drawOutlinedString(poseStack, minecraft.font, lastLoadingHeader, (width - minecraft.font.width(lastLoadingHeader) * 2) / 4, (height / 4 - 13), 0xFFFFFF, 0, 0.5f); - poseStack.pose().scale(0.5F,0.5F,1.0F); + poseStack.scale(0.5F,0.5F,1.0F); RenderSystem.enableDepthTest(); } } diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java index 0d107eac..0afd07ab 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyLoomScreen.java @@ -236,10 +236,10 @@ protected void renderLabels(PoseStack poseStack, int i, int j) { poseStack.drawString(this.font, title,((craftingTabList.selectedTab != 0 ? imageWidth : imageWidth / 2) - font.width(title)) / 2,17, CommonColor.INVENTORY_GRAY_TEXT.get(), false); if (menu.inventoryActive) poseStack.drawString(this.font, this.playerInventoryTitle, (355 + 160 - font.width(playerInventoryTitle))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); else poseStack.drawString(this.font, PREVIEW, (355 + 160 - font.width(PREVIEW))/ 2, 114, CommonColor.INVENTORY_GRAY_TEXT.get(), false); - poseStack.pose().translate(-leftPos,-topPos,0); + poseStack.translate(-leftPos,-topPos,0); getCraftingButtons().forEach(b-> b.render(poseStack,i,j,0)); if (selectedCraftingButton < getCraftingButtons().size()) getCraftingButtons().get(selectedCraftingButton).renderSelection(poseStack, i, j, 0); - poseStack.pose().translate(leftPos,topPos,0); + poseStack.translate(leftPos,topPos,0); } @Override public void bindingStateTick(BindingState state) { @@ -429,11 +429,11 @@ protected void renderBg(PoseStack poseStack, float f, int i, int j) { LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 9, topPos + 103, 163, 105); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 103, 163, 105); if (!menu.inventoryActive && !previewStack.isEmpty()){ - poseStack.pose().pushPose(); - poseStack.pose().translate(leftPos + 220.5, topPos + 130.5,0); - poseStack.pose().scale(4.25f,4.25f,4.25f); + poseStack.pushPose(); + poseStack.translate(leftPos + 220.5, topPos + 130.5,0); + poseStack.scale(4.25f,4.25f,4.25f); poseStack.renderItem(previewStack,0,0); - poseStack.pose().popPose(); + poseStack.popPose(); } if (craftingTabList.selectedTab == 0) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL, leftPos + 176, topPos + 8, 163, 93); LegacyGuiGraphics.of(poseStack).blitSprite(SMALL_ARROW, leftPos + 97, topPos + 161, 16, 13); diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java b/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java index 00cc8396..c195bdb1 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyMerchantScreen.java @@ -148,10 +148,10 @@ public void renderSelection(PoseStack graphics, int i, int j, float f) { } else { graphics.renderItemDecorations(font, baseCostA, -12, 0, baseCostA.getCount() == 1 ? "1" : null); graphics.renderItemDecorations(font, costA, 0, 0, costA.getCount() == 1 ? "1" : null); - graphics.pose().pushPose(); - graphics.pose().translate(0.0f, 0.0f, 300.0f); + graphics.pushPose(); + graphics.translate(0.0f, 0.0f, 300.0f); LegacyGuiGraphics.of(graphics).blitSprite(DISCOUNT_STRIKETHRUOGH_SPRITE, -5, +12, 0, 9, 2); - graphics.pose().popPose(); + graphics.popPose(); } }, iconHolder.getX(),iconHolder.getY(),iconHolder.isWarning()); } @@ -286,9 +286,9 @@ private void renderProgressBar(PoseStack poseStack) { if (k >= 5) { return; } - poseStack.pose().pushPose(); - poseStack.pose().translate(leftPos + (imageWidth - 1.5f* 161) / 2,topPos + 28,0); - poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.pushPose(); + poseStack.translate(leftPos + (imageWidth - 1.5f* 161) / 2,topPos + 28,0); + poseStack.scale(1.5f,1.5f,1.5f); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_BACKGROUND, 0, 0, 0, 161, 4); int m = VillagerData.getMinXpPerLevel(k); if (l < m || !VillagerData.canLevelUp(k)) { @@ -302,7 +302,7 @@ private void renderProgressBar(PoseStack poseStack) { int q = Math.min(Mth.floor((float)p * f), 161 - o); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.EXPERIENCE_BAR_RESULT, 161, 4, o, 0, o, 0, 0, q, 4); } - poseStack.pose().popPose(); + poseStack.popPose(); } @Override public void renderLabels(PoseStack poseStack, int i, int j) { @@ -328,13 +328,13 @@ public void renderBg(PoseStack poseStack, float f, int i, int j) { LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SMALL_PANEL,leftPos,topPos,imageWidth,imageHeight); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 12,topPos + 79,110,93); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_RECESSED_PANEL,leftPos + 126,topPos + 79,157,93); - poseStack.pose().pushPose(); - poseStack.pose().translate(leftPos + 47,topPos + 131,0); - poseStack.pose().scale(1.5f,1.5f,1.5f); + poseStack.pushPose(); + poseStack.translate(leftPos + 47,topPos + 131,0); + poseStack.scale(1.5f,1.5f,1.5f); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ARROW,0,0,22,15); if (getSelectedMerchantOffer() != null && getSelectedMerchantOffer().isOutOfStock()) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.ERROR_CROSS, 4, 0, 15, 15); - poseStack.pose().popPose(); + poseStack.popPose(); if (getSelectedMerchantOffer() instanceof LegacyMerchantOffer o && o.getRequiredLevel() > menu.merchantLevel) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PADLOCK, leftPos + 56, topPos + 134, 16, 16); if (menu.showProgressBar) diff --git a/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java b/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java index 56008800..5e8454f6 100644 --- a/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java +++ b/common/src/main/java/wily/legacy/client/screen/LegacyTabButton.java @@ -66,11 +66,11 @@ public void renderIconSprite(ResourceLocation icon, PoseStack poseStack){ LegacyGuiGraphics.of(poseStack).blitSprite(icon, getX() + width / 2 - 12, getY() + height / 2 - 12, 24, 24); } public void renderItemIcon(ItemStack itemIcon, PoseStack poseStack){ - poseStack.pose().pushPose(); - poseStack.pose().translate(getX() + width / 2f - 12, getY() + height / 2f - 12, 0); - poseStack.pose().scale(1.5f, 1.5f, 1.5f); + poseStack.pushPose(); + poseStack.translate(getX() + width / 2f - 12, getY() + height / 2f - 12, 0); + poseStack.scale(1.5f, 1.5f, 1.5f); poseStack.renderItem(itemIcon, 0, 0); - poseStack.pose().popPose(); + poseStack.popPose(); } @Override @@ -79,7 +79,7 @@ protected void renderWidget(PoseStack poseStack, int i, int j, float f) { poseStack.setColor(1.0f, 1.0f, 1.0f, this.alpha); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); - poseStack.pose().pushPose(); + poseStack.pushPose(); Offset translate = offset.apply(this); if (!translate.equals(Offset.ZERO)) { translate.apply(poseStack.pose()); @@ -92,7 +92,7 @@ protected void renderWidget(PoseStack poseStack, int i, int j, float f) { if (icon == null) this.renderString(poseStack, minecraft.font, CommonColor.INVENTORY_GRAY_TEXT.get() | Mth.ceil(this.alpha * 255.0f) << 24); else icon.apply(this).render(poseStack,i,j,f); } - poseStack.pose().popPose(); + poseStack.popPose(); } public boolean isMouseOver(double d, double e) { diff --git a/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java b/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java index 86aa52c9..75254163 100644 --- a/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/LoadSaveScreen.java @@ -215,16 +215,16 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) super.renderDefaultBackground(poseStack, i, j, f); resourcePackSelector.renderTooltipBox(poseStack,panel); panel.render(poseStack,i,j,f); - poseStack.pose().pushPose(); - poseStack.pose().translate(0.5f,0,0); + poseStack.pushPose(); + poseStack.translate(0.5f,0,0); LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.SQUARE_ENTITY_PANEL,panel.x + 12, panel.y + 9, 32,32); - poseStack.pose().popPose(); - poseStack.pose().pushPose(); - poseStack.pose().translate(0,0.5f,0); + poseStack.popPose(); + poseStack.pushPose(); + poseStack.translate(0,0.5f,0); poseStack.blit(SaveRenderableList.iconCache.getUnchecked(summary).textureLocation(),panel.x + 14, panel.y + 10, 0,0,29,29,29,29); poseStack.drawString(font,summary.getLevelName(),panel.x + 48, panel.y + 12, CommonColor.INVENTORY_GRAY_TEXT.get(),false); poseStack.drawString(font,Component.translatable("legacy.menu.load_save.created_in", (summary.hasCheats() ? GameType.CREATIVE : GameType.SURVIVAL).getShortDisplayName()),panel.x + 48, panel.y + 29, CommonColor.INVENTORY_GRAY_TEXT.get(),false); - poseStack.pose().popPose(); + poseStack.popPose(); poseStack.drawString(font,Component.translatable("commands.seed.success",((LegacyWorldSettings)(Object)summary.getSettings()).getDisplaySeed()),panel.x + 13, panel.y + 49, CommonColor.INVENTORY_GRAY_TEXT.get(),false); } diff --git a/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java b/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java index efa12706..3b37d903 100644 --- a/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/OverlayPanelScreen.java @@ -28,7 +28,7 @@ public void render(PoseStack poseStack, int i, int j, float f) { parent.render(poseStack, 0, 0, f); deferredTooltipRendering = null; } - poseStack.pose().translate(0,0, 1200); + poseStack.translate(0,0, 1200); super.render(poseStack, i, j, f); } diff --git a/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java b/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java index 869c2e5c..eac605f1 100644 --- a/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/PlayGameScreen.java @@ -95,8 +95,8 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) LegacyGuiGraphics.of(poseStack).blitSprite(LegacySprites.PANEL_RECESS, panel.x + 9, panel.y + 9, panel.width - 18, panel.height - 18 - (tabList.selectedTab == 0 ? 21 : 0)); if (tabList.selectedTab == 0){ if (saveRenderableList.currentlyDisplayedLevels != null) { - poseStack.pose().pushPose(); - poseStack.pose().translate(panel.x + 11.25f, panel.y + panel.height - 22.75, 0); + poseStack.pushPose(); + poseStack.translate(panel.x + 11.25f, panel.y + panel.height - 22.75, 0); long storage = new File("/").getTotalSpace(); long fixedStorage = SaveRenderableList.sizeCache.asMap().values().stream().max(Comparator.comparingLong(l->l)).orElse(0L) * (saveRenderableList.currentlyDisplayedLevels.size() + 1); long storageSize = fixedStorage != 0 ? Math.min(storage,fixedStorage) : storage; @@ -104,13 +104,13 @@ public void renderDefaultBackground(PoseStack poseStack, int i, int j, float f) Long size; if ((size = SaveRenderableList.sizeCache.getIfPresent(level)) == null) continue; float scaledSize = size * (panel.width - 21f)/ storageSize; - poseStack.pose().pushPose(); - poseStack.pose().scale(scaledSize,1,1); + poseStack.pushPose(); + poseStack.scale(scaledSize,1,1); poseStack.fill(0, 0, 1, 11,getFocused() instanceof AbstractButton b && saveRenderableList.renderables.contains(b) && saveRenderableList.renderables.indexOf(b) == saveRenderableList.currentlyDisplayedLevels.indexOf(level) ? CommonColor.SELECTED_STORAGE_SAVE.get() : CommonColor.STORAGE_SAVE.get()); - poseStack.pose().popPose(); - poseStack.pose().translate(scaledSize, 0, 0); + poseStack.popPose(); + poseStack.translate(scaledSize, 0, 0); } - poseStack.pose().popPose(); + poseStack.popPose(); } ScreenUtil.renderPanelTranslucentRecess(poseStack, panel.x + 9, panel.y + panel.height - 25, panel.width - 18 , 16); } diff --git a/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java b/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java index e8b42d91..72ca7c19 100644 --- a/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java +++ b/common/src/main/java/wily/legacy/client/screen/RecipeIconHolder.java @@ -139,25 +139,25 @@ public static ItemStack getActualItem(Ingredient ingredient){ @Override public void renderSelection(PoseStack graphics, int i, int j, float f) { if (isValidIndex()) { - graphics.pose().pushPose(); - graphics.pose().translate(getXCorner() - 4.5f, getYCorner(), 0f); + graphics.pushPose(); + graphics.translate(getXCorner() - 4.5f, getYCorner(), 0f); applyOffset(graphics); RenderSystem.disableDepthTest(); if (getFocusedRecipes().size() == 2) { LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.CRAFTING_2_SLOTS_SELECTION, 0, -12, 36, 78); }else if (getFocusedRecipes().size() > 2) LegacyGuiGraphics.of(graphics).blitSprite(LegacySprites.CRAFTING_SELECTION, 0, -39, 36, 105); - graphics.pose().popPose(); + graphics.popPose(); if (getFocusedRecipes().size() >= 2){ ScreenUtil.secureTranslucentRender(graphics, !canCraft(getFocusedRecipes().get(1)), 0.5f, (u)-> renderItem(graphics, getFocusedRecipes().get(1).getResultItem(minecraft.level.registryAccess()),getX(),getY() + 27,false)); if (getFocusedRecipes().size() >= 3) ScreenUtil.secureTranslucentRender(graphics, !canCraft(getFocusedRecipes().get(getFocusedRecipes().size() - 1)), 0.5f, (u)-> renderItem(graphics, getFocusedRecipes().get(getFocusedRecipes().size() - 1).getResultItem(minecraft.level.registryAccess()),getX(),getY() - 27,false)); } RenderSystem.enableDepthTest(); } - graphics.pose().pushPose(); - graphics.pose().translate(0,selectionOffset * 27,0); + graphics.pushPose(); + graphics.translate(0,selectionOffset * 27,0); super.renderSelection(graphics,i,j,f); - graphics.pose().popPose(); + graphics.popPose(); } protected boolean canScroll(){ return getRecipes().size() >= 3; diff --git a/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java b/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java index 9107ea44..4f1299b6 100644 --- a/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java +++ b/common/src/main/java/wily/legacy/client/screen/ScrollableRenderer.java @@ -19,12 +19,12 @@ public ScrollableRenderer(LegacyScrollRenderer renderer){ public final LegacyScrollRenderer scrollRenderer; public void render(PoseStack graphics, int x, int y, int width, int height, Runnable scrollable){ graphics.enableScissor(x,y, x + width, y + height); - graphics.pose().pushPose(); + graphics.pushPose(); float s = Math.min(1.0f,(Util.getMillis() - scrollRenderer.lastScroll) / 480f); visualLabelY += (scrolled.get() - visualLabelY) * s; - graphics.pose().translate(0, -visualLabelY * 12,0); + graphics.translate(0, -visualLabelY * 12,0); scrollable.run(); - graphics.pose().popPose(); + graphics.popPose(); graphics.disableScissor(); if (scrolled.max > 0){ if (scrolled.get() < scrolled.max) scrollRenderer.renderScroll(graphics, ScreenDirection.DOWN,x + width - 13, y + 3 + height); diff --git a/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java b/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java index 61715b99..2864e615 100644 --- a/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java +++ b/common/src/main/java/wily/legacy/client/screen/ServerRenderableList.java @@ -162,14 +162,14 @@ protected void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float p } boolean bl2 = !this.isCompatible(); poseStack.drawString(minecraft.font, getMessage(), getX() + 32 + 3, getY() + 3, 0xFFFFFF); - poseStack.pose().pushPose(); - poseStack.pose().translate(getX() + 35, getY() + 10,0); - poseStack.pose().scale(2/3f,2/3f,2/3f); + poseStack.pushPose(); + poseStack.translate(getX() + 35, getY() + 10,0); + poseStack.scale(2/3f,2/3f,2/3f); List list = minecraft.font.split(server.motd, Math.max(234,minecraft.font.width(server.motd) / 2 + 20)); for (int p = 0; p < Math.min(2,list.size()); ++p) { ScreenUtil.renderScrollingString(poseStack,minecraft.font, list.get(p), 0, minecraft.font.lineHeight * p,234 , 11 + minecraft.font.lineHeight * p, -8355712, false,minecraft.font.width(list.get(p))* 2/3); } - poseStack.pose().popPose(); + poseStack.popPose(); Component component = bl2 ? server.version.copy().withStyle(ChatFormatting.RED) : server.status; int q = minecraft.font.width(component); poseStack.drawString(minecraft.font, component, getX() + 270 - q - 15 - 2, getY() + 3, -8355712, false); From ae055ca79f0b8ed41760dbc8e5432b8cc7c95690 Mon Sep 17 00:00:00 2001 From: aric3435 <157071384+arichornloverALT@users.noreply.github.com> Date: Sat, 31 Aug 2024 23:01:08 -0500 Subject: [PATCH 4/6] LegacyCommonInputs (1.19.4 Port) This is a legacy version of CommonInputs. Made for 1.19.x and lower. This is necessary to fix errors and to resolve the lack of CommonInputs. --- .../wily/legacy/client/LegacyCommonInputs.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 common/src/main/java/wily/legacy/client/LegacyCommonInputs.java diff --git a/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java b/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java new file mode 100644 index 00000000..ca725676 --- /dev/null +++ b/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java @@ -0,0 +1,17 @@ +package wily.legacy.client; + +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; + +public class LegacyCommonInputs { + + public static boolean selected(Screen screen) { + if (screen == null) { + return false; + } + long windowHandle = Minecraft.getInstance().getWindow().getWindow(); + return InputConstants.isKeyDown(windowHandle, InputConstants.KEY_SPACE) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_ENTER); + } +} From bf57ac01ca5d8c58e158cef638b54f9c1ba09af5 Mon Sep 17 00:00:00 2001 From: aric3435 <157071384+arichornloverALT@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:45:20 -0500 Subject: [PATCH 5/6] Add all current 1.19.4 code. (Legacy4J v1.7.1) Not finished code. this commit was made just so I could have the ability to compare the changes easily for Legacy4J v1.7.3. --- .../legacy/client/LegacyCommonInputs.java | 41 +++++++++++++++++-- .../legacy/client/screen/KeyboardScreen.java | 11 ++--- .../client/screen/SaveRenderableList.java | 29 ++++++++++--- 3 files changed, 64 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java b/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java index ca725676..d25378a0 100644 --- a/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java +++ b/common/src/main/java/wily/legacy/client/LegacyCommonInputs.java @@ -6,12 +6,45 @@ public class LegacyCommonInputs { - public static boolean selected(Screen screen) { - if (screen == null) { - return false; - } + public static boolean selected(int keyCode) { + long windowHandle = Minecraft.getInstance().getWindow().getWindow(); + return InputConstants.isKeyDown(windowHandle, keyCode); + } +} + +/* +package wily.legacy.client; + +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; + +public class LegacyCommonInputs { + + public static boolean selected(int keyCode) { + long windowHandle = Minecraft.getInstance().getWindow().getWindow(); + return InputConstants.isKeyDown(windowHandle, keyCode); + } + + public static boolean isSpaceOrEnterPressed() { long windowHandle = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(windowHandle, InputConstants.KEY_SPACE) || InputConstants.isKeyDown(windowHandle, InputConstants.KEY_ENTER); } + + public static boolean isMouseButtonPressed(int button) { + long windowHandle = Minecraft.getInstance().getWindow().getWindow(); + return InputConstants.isMouseButtonDown(windowHandle, button); + } + + public static boolean isModifierKeyPressed() { + long windowHandle = Minecraft.getInstance().getWindow().getWindow(); + return InputConstants.isKeyDown(windowHandle, InputConstants.KEY_LSHIFT) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_RSHIFT) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_LCONTROL) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_RCONTROL) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_LALT) || + InputConstants.isKeyDown(windowHandle, InputConstants.KEY_RALT); + } } +*/ \ No newline at end of file diff --git a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java index 8a2c13d6..f7455f60 100644 --- a/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java +++ b/common/src/main/java/wily/legacy/client/screen/KeyboardScreen.java @@ -27,6 +27,7 @@ import wily.legacy.Legacy4JClient; import wily.legacy.client.CommonColor; import wily.legacy.client.ControlType; +import wily.legacy.client.LegacyCommonInputs; import wily.legacy.client.LegacyGuiGraphics; import wily.legacy.client.LegacyResourceManager; import wily.legacy.client.controller.BindingState; @@ -127,12 +128,8 @@ public void addControlTooltips(ControlTooltip.Renderer renderer) { renderer.add(()-> ControlType.getActiveType().isKbm() ? null : ControllerBinding.RIGHT_STICK.bindingState.getIcon(), ()-> ControlTooltip.getAction("legacy.action.move_keyboard")); } - private static boolean isSpaceOrEnterPressed(int keyCode) { - return keyCode == InputConstants.KEY_SPACE || keyCode == InputConstants.KEY_RETURN; - } - - public static boolean isOpenKey(int i){ - return isSpaceOrEnterPressed(i) && i != InputConstants.KEY_SPACE; + public static boolean isOpenKey(int keyCode) { + return LegacyCommonInputs.selected(keyCode) && keyCode != InputConstants.KEY_SPACE; } public static KeyboardScreen fromEditBox(int ordinal, Screen parent){ return new KeyboardScreen(()->getScreenActualEditBox(ordinal,parent),parent); @@ -372,7 +369,7 @@ public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) { @Override public boolean keyReleased(int i, int j, int k) { - if (this.active && this.visible && isSpaceOrEnterPressed(i) && pressTime > 0) { + if (this.active && this.visible && LegacyCommonInputs.selected(i) && pressTime > 0) { this.onRelease(); return true; } else { diff --git a/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java b/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java index e19e3fb9..4f6c035e 100644 --- a/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java +++ b/common/src/main/java/wily/legacy/client/screen/SaveRenderableList.java @@ -14,12 +14,15 @@ import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractButton; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.toasts.SystemToast; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.client.gui.screens.worldselection.EditWorldScreen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -79,7 +82,18 @@ public class SaveRenderableList extends RenderableVList { public static LoadingCache sizeCache = CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override public Long load(LevelSummary key) { - return FileUtils.sizeOfDirectory(Minecraft.getInstance().getLevelSource().getLevelPath(key.getLevelId()).toFile()); + return FileUtils.sizeOfDirectory(Minecraft.getInstance().getLevelSource().getBaseDir().resolve(key.getLevelId()).toFile()); + } + }); + public static LoadingCache sizeCache = CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public Long load(LevelSummary key) { + try { + return FileUtils.sizeOfDirectory(Minecraft.getInstance().getLevelSource().getBaseDir().resolve(key.getLevelId()).toFile()); + } catch (IOException e) { + LOGGER.error("Failed to get directory size for level: {}", key.getLevelId(), e); + return 0L; + } } }); public static LoadingCache iconCache = CacheBuilder.newBuilder().build(new CacheLoader<>() { @@ -90,7 +104,6 @@ public DynamicTexture load(LevelSummary key) { BasicFileAttributes basicFileAttributes = Files.readAttributes(iconFile, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); if (basicFileAttributes.isSymbolicLink()) { List list = new ArrayList<>(); - Minecraft.getInstance().getLevelSource().getWorldDirValidator().validateSymlink(iconFile, list); if (!list.isEmpty()) { Legacy4J.LOGGER.warn("{}", String.join(", ", list)); iconFile = null; @@ -231,21 +244,25 @@ protected MutableComponent createNarrationMessage() { protected void renderWidget(PoseStack poseStack, int i, int j, float f) { super.renderWidget(poseStack, i, j, f); RenderSystem.enableBlend(); - poseStack.blit(iconCache.getUnchecked(summary).textureLocation(), getX() + 5, getY() + 5, 0, 0, 20, 20, 20, 20); + RenderSystem.setShaderTexture(0, iconCache.getUnchecked(summary).getId()); + blit(poseStack, getX() + 5, getY() + 5, 0, 0, 20, 20, 20, 20); RenderSystem.disableBlend(); if (minecraft.options.touchscreen().get().booleanValue() || isHovered) { - poseStack.fill(getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); + LegacyGuiGraphics guiGraphics = LegacyGuiGraphics.of(poseStack); + fill(poseStack, getX() + 5, getY() + 5, getX() + 25, getY() + 25, -1601138544); boolean hoverIcon = ScreenUtil.isMouseOver(i, j, getX() + 5, getY() + 5, 20, height); ResourceLocation resourceLocation = hoverIcon ? JOIN_HIGHLIGHTED : JOIN; ResourceLocation resourceLocation2 = hoverIcon ? WARNING_HIGHLIGHTED : WARNING; ResourceLocation resourceLocation3 = hoverIcon ? ERROR_HIGHLIGHTED : ERROR; ResourceLocation resourceLocation4 = hoverIcon ? MARKED_JOIN_HIGHLIGHTED : MARKED_JOIN; +/* SymLink doesn't exist in 1.19.4 & older. if (summary instanceof LevelSummary.SymlinkLevelSummary) { LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation4, getX(), getY(), 32, 32); return; } +*/ if (summary.isLocked()) { LegacyGuiGraphics.of(poseStack).blitSprite(resourceLocation3, getX(), getY(), 32, 32); if (hoverIcon) { @@ -320,7 +337,7 @@ public void joinWorld(LevelSummary summary) { return; } if (summary instanceof LevelSummary.SymlinkLevelSummary) { - this.minecraft.setScreen(new SymlinkWarningScreen(this.screen)); +// this.minecraft.setScreen(new SymlinkWarningScreen(this.screen)); return; } LevelSummary.BackupStatus backupStatus = summary.backupStatus(); @@ -342,7 +359,7 @@ public void joinWorld(LevelSummary summary) { LOGGER.error("Failed to backup level {}", levelId, iOException); } catch (ContentValidationException contentValidationException) { LOGGER.warn("{}", contentValidationException.getMessage()); - this.minecraft.setScreen(new SymlinkWarningScreen(this.screen)); +// this.minecraft.setScreen(new SymlinkWarningScreen(this.screen)); } } this.loadWorld(summary); From ed5af53beb06e88812a7bb016cbe97f44f2ef2f1 Mon Sep 17 00:00:00 2001 From: aric3435 <157071384+arichornloverALT@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:48:36 -0500 Subject: [PATCH 6/6] Update gradle.properties --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3e6578c6..471f3434 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.19.4 enabled_platforms=fabric,forge archives_base_name=Legacy4J -mod_version=1.7.1 +mod_version=1.7.3 mod_id=legacy mod_license=MIT mod_name=Legacy4J @@ -25,4 +25,4 @@ sdl_dependency=dev.isxander:libsdl4j:3.6896c4c-38 curseforge_id=955526 modrinth_id=gHvKJofA -stage=release \ No newline at end of file +stage=release