diff --git a/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementWidget.java b/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementWidget.java index 04a1693..c8583ef 100644 --- a/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementWidget.java +++ b/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementWidget.java @@ -69,7 +69,7 @@ private void refreshHover() { } int titleWidth = 29 + mc.font.width(this.title) + k; BetterAdvancementsScreen screen = betterAdvancementTabGui.getScreen(); - this.criterionGrid = CriterionGrid.findOptimalCriterionGrid(this.advancementNode.advancement(), advancementProgress, screen.width / 2, mc.font); + this.criterionGrid = CriterionGrid.findOptimalCriterionGrid(this.advancementNode.holder(), this.advancementNode.advancement(), advancementProgress, screen.width / 2, mc.font); int maxWidth; if (!CriterionGrid.requiresShift || Screen.hasShiftDown()) { diff --git a/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementsScreenButton.java b/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementsScreenButton.java index 0990e29..f8af6ff 100644 --- a/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementsScreenButton.java +++ b/Common/src/main/java/betteradvancements/common/gui/BetterAdvancementsScreenButton.java @@ -27,7 +27,7 @@ public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouse this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.getWidth() && mouseY < this.getY() + this.getHeight(); guiGraphics.blit(Resources.Gui.TABS, this.getX(), this.getY(), 56, 0, 28, 32); if (this.isHovered) { - guiGraphics.renderTooltip(mc.font, Component.literal("Advancements"), mouseX, mouseY); + guiGraphics.renderTooltip(mc.font, Component.translatable("gui.advancements"), mouseX, mouseY); } RenderSystem.defaultBlendFunc(); guiGraphics.renderFakeItem(new ItemStack(Items.BOOK), this.getX() + 6, this.getY() + 10); diff --git a/Common/src/main/java/betteradvancements/common/util/CriterionGrid.java b/Common/src/main/java/betteradvancements/common/util/CriterionGrid.java index a512861..3fadab9 100644 --- a/Common/src/main/java/betteradvancements/common/util/CriterionGrid.java +++ b/Common/src/main/java/betteradvancements/common/util/CriterionGrid.java @@ -2,6 +2,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.advancements.Criterion; import net.minecraft.advancements.CriterionProgress; @@ -81,7 +82,7 @@ public Column(List cells, int width) { // Of all the possible grids whose aspect ratio is less than the maximum, this method returns the one with the smallest number of rows. // If there is no such grid, this method returns a single-column grid. - public static CriterionGrid findOptimalCriterionGrid(Advancement advancement, AdvancementProgress progress, int maxWidth, Font font) { + public static CriterionGrid findOptimalCriterionGrid(AdvancementHolder holder, Advancement advancement, AdvancementProgress progress, int maxWidth, Font font) { if (progress == null || progress.isDone() || detailLevel.equals(CriteriaDetail.OFF)) { return CriterionGrid.empty; } @@ -93,10 +94,11 @@ public static CriterionGrid findOptimalCriterionGrid(Advancement advancement, Ad List cellContents = new ArrayList<>(); for (String criterion : criteria.keySet()) { CriterionProgress criterionProgress = progress.getCriterion(criterion); + String criterionKey = "betteradvancements.criterion." + holder.id() + "." + criterion; if (criterionProgress != null && criterionProgress.isDone()) { if (detailLevel.showObtained()) { MutableComponent text = Component.literal(" + ").withStyle(ChatFormatting.GREEN); - MutableComponent text2 = Component.literal(criterion).withStyle(ChatFormatting.WHITE); + MutableComponent text2 = Component.translatableWithFallback(criterionKey, criterion).withStyle(ChatFormatting.WHITE); text.append(text2); cellContents.add(text.getString()); } @@ -104,7 +106,7 @@ public static CriterionGrid findOptimalCriterionGrid(Advancement advancement, Ad else { if (detailLevel.showUnobtained()) { MutableComponent text = Component.literal(" x ").withStyle(ChatFormatting.DARK_RED); - MutableComponent text2 = Component.literal(criterion).withStyle(ChatFormatting.WHITE); + MutableComponent text2 = Component.translatableWithFallback(criterionKey, criterion).withStyle(ChatFormatting.WHITE); text.append(text2); cellContents.add(text.getString()); } @@ -114,7 +116,7 @@ public static CriterionGrid findOptimalCriterionGrid(Advancement advancement, Ad if (!detailLevel.showUnobtained()) { MutableComponent text = Component.literal(" x ").withStyle(ChatFormatting.DARK_RED); - MutableComponent text2 = Component.literal(numUnobtained + " remaining").withStyle(ChatFormatting.WHITE, ChatFormatting.ITALIC); + MutableComponent text2 = Component.translatable("betteradvancements.remaining", numUnobtained).withStyle(ChatFormatting.WHITE, ChatFormatting.ITALIC); text.append(text2); cellContents.add(text.getString()); } diff --git a/Common/src/main/resources/assets/betteradvancements/lang/en_us.json b/Common/src/main/resources/assets/betteradvancements/lang/en_us.json new file mode 100644 index 0000000..0c65a0c --- /dev/null +++ b/Common/src/main/resources/assets/betteradvancements/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "betteradvancements.remaining": "%d remaining" +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 45bc5b8..59e0801 100644 --- a/gradle.properties +++ b/gradle.properties @@ -47,4 +47,4 @@ curseHomepageLink=https://www.curseforge.com/minecraft/mc-mods/better-advancemen modrinthProjectId=Q2OqKxDG # Version -specificationVersion=0.4.1 +specificationVersion=0.4.2