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;
if (state.getOffset() == 1) {
// TODO: Kirin's scrollbars in 1.19.4 are kind of jank
final int fixForPositionalBug = 10;
int top = 0 + fixForPositionalBug;
int top = 0;
for (SpellbookRecipe recipe : this.client.world.getRecipeManager().listAllOfType(URecipes.SPELLBOOK)) {
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);
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");
}
}

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);
RenderSystem.setShaderColor(1, 1, 1, 1);
RenderSystem.setShaderTexture(0, tab.icon().get());
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);
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);
});
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);
// 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())
addButton(new TraitButton(width / 2 - 8, 8, trait));
addButton(new Label(width / 2, 26).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(-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();
SpellTraits.getItems(trait)