Skip to content

Commit

Permalink
changing book hud now uses a Component instead of displaying raw name
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Aug 5, 2024
1 parent c68a53b commit b84fac4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix: Removing a book from the Tome changes its title to the raw name
- 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
13 changes: 10 additions & 3 deletions src/main/java/vazkii/akashictome/client/HUDHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit b84fac4

Please sign in to comment.