diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-19 10:45:51 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-19 10:45:51 -0700 |
commit | 375b44103d136a5c4a598c52d659eef1b26eee17 (patch) | |
tree | 1efc23e39de8ba1eaa0e6b70774a3a0585221c01 /src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java | |
parent | e5e86bedca56374e40fe14fea76a16295cc1673e (diff) | |
download | Iceberg-375b44103d136a5c4a598c52d659eef1b26eee17.tar.gz Iceberg-375b44103d136a5c4a598c52d659eef1b26eee17.tar.bz2 Iceberg-375b44103d136a5c4a598c52d659eef1b26eee17.zip |
Added StringRecomposer helper. Fixed crash bug due to missing fonts.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java index 5b79256..bbd2d6b 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java +++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ScreenMixin.java @@ -1,6 +1,5 @@ package com.anthonyhilyard.iceberg.mixin; -import java.util.ArrayList; import java.util.List; import com.anthonyhilyard.iceberg.util.StringRecomposer; @@ -20,16 +19,18 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTextTooltip; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.network.chat.FormattedText; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.common.MinecraftForge; @Mixin(Screen.class) public class ScreenMixin extends AbstractContainerEventHandler { + @Shadow + protected Font font = null; + @Shadow(remap = false) private Font tooltipFont = null; @@ -48,18 +49,7 @@ public class ScreenMixin extends AbstractContainerEventHandler { if (!components.isEmpty()) { - List<FormattedText> standinLines = new ArrayList<>(); - for (ClientTooltipComponent component : components) - { - if (component instanceof ClientTextTooltip) - { - StringRecomposer recomposer = new StringRecomposer(); - ((ClientTextTooltip)component).text.accept(recomposer); - standinLines.add(recomposer.getFormattedText()); - } - } - - MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(tooltipStack, standinLines, poseStack, postX, postY, tooltipFont, tooltipWidth, tooltipHeight)); + MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(tooltipStack, StringRecomposer.recompose(components), poseStack, postX, postY, ForgeHooksClient.getTooltipFont(tooltipFont, tooltipStack, font), tooltipWidth, tooltipHeight)); } } |