Skip to content

Commit

Permalink
修改GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 13, 2024
1 parent 8ac8eab commit d14430e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public class RoyalAnvilScreen extends ItemCombinerScreen<RoyalAnvilMenu> {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ public class RoyalSmithingScreen extends ItemCombinerScreen<RoyalSmithingMenu> {
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoyalGrindstoneMenu> type, int containerId, Inventory playerInventory) {
this(type, containerId, playerInventory, ContainerLevelAccess.NULL);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d14430e

Please sign in to comment.