Fix a whole bunch of rendering jank due to the 1.19.4 update

This commit is contained in:
Sollace 2023-06-02 21:04:12 +01:00
parent 62aac0f711
commit 776f3b9718
3 changed files with 18 additions and 26 deletions

View file

@ -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);
}

View file

@ -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");
}
}

View file

@ -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<Item> knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList();
SpellTraits.getItems(trait)