Skip to content

Commit

Permalink
Fix ChocoPedia UI issues ( Closes #79 )
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Jun 28, 2024
1 parent 19982fe commit 2905325
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.chococraft.client.gui;


import com.mojang.blaze3d.vertex.PoseStack;
import net.chococraft.Chococraft;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -60,27 +59,26 @@ public void init() {

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);

PoseStack poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(this.guiLeft, this.guiTop, 0);
super.render(guiGraphics, mouseX, mouseY, partialTicks);

guiGraphics.blit(TEXTURE, 0, 0, 0, 0, this.xSize, this.ySize);

if (this.currentPage == 0) {
guiGraphics.drawString(font, bookTitle, (this.xSize / 2) - (this.font.width(bookTitle) / 2), 24, 0, false);
guiGraphics.drawString(font, bookAuthor, (this.xSize / 2) - (this.font.width(bookAuthor) / 2), 44, 0, false);
guiGraphics.drawString(font, bookTitle, guiLeft + (this.xSize / 2) - (this.font.width(bookTitle) / 2), guiTop + 24, 0, false);
guiGraphics.drawString(font, bookAuthor, guiLeft + (this.xSize / 2) - (this.font.width(bookAuthor) / 2), guiTop + 44, 0, false);
} else {
if (currentPage > 1) {
this.pageMsg = Component.translatable("book.pageIndicator", currentPage - 1, Math.max(pageCount - 1, 1));
guiGraphics.drawString(font, this.pageMsg, ((this.xSize / 2) - (this.font.width(bookAuthor) / 2) - 6), 14, 0, false);
guiGraphics.drawString(font, this.pageMsg, guiLeft + ((this.xSize / 2) - (this.font.width(bookAuthor) / 2) - 6), guiTop + 14, 0, false);
}

this.renderPage(guiGraphics);
}
poseStack.popPose();
super.render(guiGraphics, mouseX, mouseY, partialTicks);
}

@Override
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
this.renderTransparentBackground(guiGraphics);
guiGraphics.blit(TEXTURE, guiLeft, guiTop, 0, 0, 192, 192);
}

private void renderPage(GuiGraphics guiGraphics) {
Expand Down

0 comments on commit 2905325

Please sign in to comment.