From b84fac4ea97243ca1ff2d92aeaef97d0c383c1d5 Mon Sep 17 00:00:00 2001 From: Uraneptus Date: Mon, 5 Aug 2024 18:15:24 +0200 Subject: [PATCH] changing book hud now uses a Component instead of displaying raw name --- build.properties | 2 +- changelog.txt | 3 ++- .../java/vazkii/akashictome/client/HUDHandler.java | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.properties b/build.properties index 50529f5..2c9d4b0 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ mapping_channel=official forge_version=43.1.52 mod_id=akashictome dir_repo=./ -build_number=26 +build_number=25 arl_version=1.8.2-56.125 dir_output=../Build Output/AkashicTome/ mapping_version=1.19.2 diff --git a/changelog.txt b/changelog.txt index bbc4039..6c6c125 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1 +1,2 @@ -- Fix: Removing a book from the Tome changes its title to the raw name \ No newline at end of file +- Fix: Removing a book from the Tome changes its title to the raw name +- Fix: Changing book option when looking at a mod's block is using the raw name \ No newline at end of file diff --git a/src/main/java/vazkii/akashictome/client/HUDHandler.java b/src/main/java/vazkii/akashictome/client/HUDHandler.java index ca98089..ca83048 100644 --- a/src/main/java/vazkii/akashictome/client/HUDHandler.java +++ b/src/main/java/vazkii/akashictome/client/HUDHandler.java @@ -6,6 +6,8 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; @@ -49,17 +51,22 @@ public void onDrawScreen(RenderGuiOverlayEvent.Post event) { if (!state.isAir()) { ItemStack drawStack = ItemStack.EMPTY; - String line1 = ""; + MutableComponent line1 = null; String line2 = ""; String mod = MorphingHandler.getModFromState(state); ItemStack morphStack = MorphingHandler.getShiftStackForMod(tomeStack, mod); + if (!morphStack.isEmpty() && !ItemStack.isSame(morphStack, tomeStack)) { drawStack = morphStack; - line1 = ItemNBTHelper.getCompound(morphStack, MorphingHandler.TAG_TOME_DISPLAY_NAME, false).getString("text"); + line1 = Component.Serializer.fromJson(ItemNBTHelper.getCompound(morphStack, MorphingHandler.TAG_TOME_DISPLAY_NAME, false).getString("text")).withStyle(ChatFormatting.GREEN); line2 = ChatFormatting.GRAY + I18n.get("akashictome.click_morph"); } + if (line1 == null) { + line1 = Component.literal(""); + } + if (!drawStack.isEmpty()) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -68,7 +75,7 @@ public void onDrawScreen(RenderGuiOverlayEvent.Post event) { mc.getItemRenderer().renderGuiItem(drawStack, sx, sy); mc.font.drawShadow(event.getPoseStack(), line1, sx + 20, sy + 4, 0xFFFFFFFF); - mc.font.drawShadow(event.getPoseStack(), line2, sx + 25, sy + 14, 0xFFFFFFFF); + mc.font.drawShadow(event.getPoseStack(), line2, sx + 20, sy + 14, 0xFFFFFFFF); } } }