From d14430ed5328ccf34732cdeeaf9315bd52b7eacd Mon Sep 17 00:00:00 2001 From: Gugle Date: Sat, 13 Apr 2024 20:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9GUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/screen/inventory/RoyalAnvilScreen.java | 7 ++++++- .../screen/inventory/RoyalGrindstoneScreen.java | 16 +++++++++++----- .../screen/inventory/RoyalSmithingScreen.java | 8 ++++++-- .../inventory/RoyalGrindstoneMenu.java | 8 ++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java index 38c7e8ad0..3234a5711 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java @@ -34,7 +34,12 @@ public class RoyalAnvilScreen extends ItemCombinerScreen { public RoyalAnvilScreen(RoyalAnvilMenu menu, Inventory playerInventory, Component title) { super(menu, playerInventory, title, ANVIL_LOCATION); this.player = playerInventory.player; - this.titleLabelX = 60; + } + + @Override + protected void init() { + super.init(); + this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; } @Override diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java index 3ddef3559..c002d67eb 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java @@ -19,6 +19,12 @@ public RoyalGrindstoneScreen( super(menu, playerInventory, Component.translatable("screen.anvilcraft.royal_grindstone.title")); } + @Override + protected void init() { + super.init(); + this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; + } + @Override public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { this.renderBackground(guiGraphics); @@ -36,18 +42,18 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTick, int protected void renderLabels(GuiGraphics guiGraphics) { if (this.menu.getSlot(2).hasItem()) { - drawLabel((int) (92 + 4.5 - (this.font.width(Component.literal(this.menu.usedGold.toString())) / 2)), 37, - Component.literal(this.menu.usedGold.toString()), guiGraphics); + drawLabel((int) (92 + 4.5 - (this.font.width(Component.literal("" + this.menu.usedGold)) / 2)), 38, + Component.literal("" + this.menu.usedGold), guiGraphics); drawLabel(112, 19, Component.literal( Component.translatable("screen.anvilcraft.royal_grindstone.remove_curse_number") - .getString().replace("%i", this.menu.removeCurseNumber.toString())), guiGraphics); + .getString().replace("%i", "" + this.menu.removeCurseNumber)), guiGraphics); drawLabel(112, 58, Component.literal( Component.translatable("screen.anvilcraft.royal_grindstone.remove_repair_cost") - .getString().replace("%i", this.menu.removeRepairCostNumber.toString())), guiGraphics); + .getString().replace("%i", "" + this.menu.removeRepairCostNumber)), guiGraphics); } } - private void drawLabel(int x, int y, Component component, GuiGraphics guiGraphics) { + private void drawLabel(int x, int y, Component component, @NotNull GuiGraphics guiGraphics) { int i = (this.width - this.imageWidth - 2) / 2; int j = (this.height - this.imageHeight + 23) / 2; x = x + i; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java index 202b1a01e..a77d112c6 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java @@ -54,8 +54,12 @@ public class RoyalSmithingScreen extends ItemCombinerScreen { */ public RoyalSmithingScreen(RoyalSmithingMenu menu, Inventory playerInventory, Component title) { super(menu, playerInventory, title, SMITHING_LOCATION); - this.titleLabelX = 44; - this.titleLabelY = 15; + } + + @Override + protected void init() { + super.init(); + this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; } @Override diff --git a/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalGrindstoneMenu.java b/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalGrindstoneMenu.java index 93426b0e7..64d5081eb 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalGrindstoneMenu.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalGrindstoneMenu.java @@ -31,9 +31,9 @@ public class RoyalGrindstoneMenu extends AbstractContainerMenu { private final Container resultMaterialSlots; private final ContainerLevelAccess access; - public Integer usedGold = 0; - public Integer removeRepairCostNumber = 0; - public Integer removeCurseNumber = 0; + public int usedGold = 0; + public int removeRepairCostNumber = 0; + public int removeCurseNumber = 0; public RoyalGrindstoneMenu(MenuType type, int containerId, Inventory playerInventory) { this(type, containerId, playerInventory, ContainerLevelAccess.NULL); @@ -94,7 +94,7 @@ public void onTake(@NotNull Player player, @NotNull ItemStack stack) { usedGold + resultMaterialSlots.getItem(2).getCount())); } }); - this.addSlot(new Slot(this.resultMaterialSlots, 2, 89, 48) { + this.addSlot(new Slot(this.resultMaterialSlots, 2, 89, 47) { public boolean mayPlace(@NotNull ItemStack stack) { return false; }