From 776f3b97188f37fb8f73b33eb069b4f9250679f3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 2 Jun 2023 21:04:12 +0100 Subject: [PATCH] Fix a whole bunch of rendering jank due to the 1.19.4 update --- .../client/gui/spellbook/IngredientTree.java | 27 +++++-------------- .../SpellbookCraftingPageContent.java | 8 +++--- .../SpellbookTraitDexPageContent.java | 9 ++++--- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java index 1e68e6e6..737dcabd 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java @@ -5,15 +5,12 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; -import org.joml.Vector4f; - import com.minelittlepony.common.client.gui.*; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.unicopia.ability.magic.spell.crafting.SpellbookRecipe; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.client.gui.ItemTraitsTooltipRenderer; import com.minelittlepony.unicopia.client.render.PassThroughVertexConsumer; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; @@ -239,11 +236,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { @Override public void render(MatrixStack matrices, int x, int y, float tickDelta) { - y -= 2; - - Vector4f pos = new Vector4f(x, y, 0, 1); - pos.mul(matrices.peek().getPositionMatrix()); - drawItem(matrices, (int)pos.x, (int)pos.y); + drawItem(matrices, x, y - 2); } protected void drawItem(MatrixStack matrices, int x, int y) { @@ -281,16 +274,11 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { MinecraftClient.getInstance().getTextureManager().getTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).setFilter(false, false); RenderSystem.setShaderTexture(0, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.setShaderColor(1, 1, 1, 0.2F); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.push(); - matrixStack.translate(x, y, 100); - matrixStack.translate(8, 8, 0); - matrixStack.scale(1, -1, 1); - matrixStack.scale(8, 8, 8); - RenderSystem.applyModelViewMatrix(); + matrices.push(); + matrices.translate(x, y, 100); + matrices.translate(8, 8, 0); + matrices.scale(1, -1, 1); + matrices.scale(8, 8, 8); VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); boolean bl = !model.isSideLit(); if (bl) { @@ -308,8 +296,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { if (bl) { DiffuseLighting.enableGuiDepthLighting(); } - matrixStack.pop(); - RenderSystem.applyModelViewMatrix(); + matrices.pop(); RenderSystem.setShaderColor(1, 1, 1, 1); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java index d9f2c594..3492fb6b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java @@ -69,15 +69,17 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe getContentPadding().bottom = 30; if (state.getOffset() == 1) { - int top = 0; + // TODO: Kirin's scrollbars in 1.19.4 are kind of jank + final int fixForPositionalBug = 10; + int top = 0 + fixForPositionalBug; for (SpellbookRecipe recipe : this.client.world.getRecipeManager().listAllOfType(URecipes.SPELLBOOK)) { if (client.player.getRecipeBook().contains(recipe)) { - IngredientTree tree = new IngredientTree(0, top, width - verticalScrollbar.getBounds().width + 2); + IngredientTree tree = new IngredientTree(-fixForPositionalBug, top, width - verticalScrollbar.getBounds().width + 2); recipe.buildCraftingTree(tree); top += tree.build(this); } } - if (top == 0) { + if (top == 0 + fixForPositionalBug) { addButton(new Label(width / 2, 0).setCentered()).getStyle().setText("gui.unicopia.spellbook.page.recipes.empty"); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java index 7125b993..f3177bc6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java @@ -114,13 +114,16 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel boolean known = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait); - addButton(new TraitButton(width / 2 - 8, 8, trait)); - addButton(new Label(width / 2, 26).setCentered()) + // TODO: Kirin's scrollbars in 1.19.4 are kind of jank + final int fixForPositionalBug = 8; + + addButton(new TraitButton(width / 2 - 8 - fixForPositionalBug, 8 + fixForPositionalBug, trait)); + addButton(new Label(width / 2 - fixForPositionalBug, 26 + fixForPositionalBug).setCentered()) .getStyle() .setText(known ? Text.translatable("gui.unicopia.trait.label", Text.translatable("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name") ) : Text.literal("???")); - IngredientTree tree = new IngredientTree(0, 50, width + 18).noLabels(); + IngredientTree tree = new IngredientTree(-fixForPositionalBug, 50 + fixForPositionalBug, width + 18).noLabels(); List knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList(); SpellTraits.getItems(trait)