Fix some rendering bugs with the spellbook

This commit is contained in:
Sollace 2023-06-03 14:02:07 +01:00
parent 2c0d0c7b45
commit c0fa0ae806
3 changed files with 7 additions and 14 deletions

View file

@ -70,17 +70,15 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe
getContentPadding().bottom = 30; getContentPadding().bottom = 30;
if (state.getOffset() == 1) { if (state.getOffset() == 1) {
// TODO: Kirin's scrollbars in 1.19.4 are kind of jank int top = 0;
final int fixForPositionalBug = 10;
int top = 0 + fixForPositionalBug;
for (SpellbookRecipe recipe : this.client.world.getRecipeManager().listAllOfType(URecipes.SPELLBOOK)) { for (SpellbookRecipe recipe : this.client.world.getRecipeManager().listAllOfType(URecipes.SPELLBOOK)) {
if (client.player.getRecipeBook().contains(recipe)) { if (client.player.getRecipeBook().contains(recipe)) {
IngredientTree tree = new IngredientTree(-fixForPositionalBug, top, width - verticalScrollbar.getBounds().width + 2); IngredientTree tree = new IngredientTree(0, top, width - verticalScrollbar.getBounds().width + 2);
recipe.buildCraftingTree(tree); recipe.buildCraftingTree(tree);
top += tree.build(this); top += tree.build(this);
} }
} }
if (top == 0 + fixForPositionalBug) { if (top == 0) {
addButton(new Label(width / 2, 0).setCentered()).getStyle().setText("gui.unicopia.spellbook.page.recipes.empty"); addButton(new Label(width / 2, 0).setCentered()).getStyle().setText("gui.unicopia.spellbook.page.recipes.empty");
} }
} }

View file

@ -170,9 +170,7 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
context.drawTexture(TEXTURE, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); context.drawTexture(TEXTURE, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256);
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
RenderSystem.setShaderTexture(0, tab.icon().get()); context.drawTexture(tab.icon().get(), isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16);
context.drawTexture(TEXTURE, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16);
RenderSystem.setShaderTexture(0, TEXTURE);
}); });
MatrixStack matrices = context.getMatrices(); MatrixStack matrices = context.getMatrices();

View file

@ -114,16 +114,13 @@ public class SpellbookTraitDexPageContent implements SpellbookChapterList.Conten
boolean known = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait); boolean known = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait);
// TODO: Kirin's scrollbars in 1.19.4 are kind of jank addButton(new TraitButton(width / 2 - 8, 8, trait));
final int fixForPositionalBug = 8; addButton(new Label(width / 2, 26).setCentered())
addButton(new TraitButton(width / 2 - 8 - fixForPositionalBug, 8 + fixForPositionalBug, trait));
addButton(new Label(width / 2 - fixForPositionalBug, 26 + fixForPositionalBug).setCentered())
.getStyle() .getStyle()
.setText(known ? Text.translatable("gui.unicopia.trait.label", .setText(known ? Text.translatable("gui.unicopia.trait.label",
Text.translatable("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name") Text.translatable("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name")
) : Text.literal("???")); ) : Text.literal("???"));
IngredientTree tree = new IngredientTree(-fixForPositionalBug, 50 + fixForPositionalBug, width + 18).noLabels(); IngredientTree tree = new IngredientTree(0, 50, width + 18).noLabels();
List<Item> knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList(); List<Item> knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList();
SpellTraits.getItems(trait) SpellTraits.getItems(trait)