|
1 | 1 | package net.darkhax.bookshelf.api.util; |
2 | 2 |
|
| 3 | +import net.darkhax.bookshelf.api.Services; |
| 4 | +import net.darkhax.bookshelf.mixin.client.AccessorFontManager; |
| 5 | +import net.darkhax.bookshelf.mixin.client.AccessorMinecraft; |
3 | 6 | import net.darkhax.bookshelf.mixin.entity.AccessorEntity; |
| 7 | +import net.minecraft.client.Minecraft; |
4 | 8 | import net.minecraft.network.chat.Component; |
5 | 9 | import net.minecraft.network.chat.HoverEvent; |
6 | 10 | import net.minecraft.network.chat.MutableComponent; |
|
11 | 15 | import net.minecraft.world.entity.Entity; |
12 | 16 | import net.minecraft.world.item.ItemStack; |
13 | 17 |
|
| 18 | +import java.util.Collections; |
| 19 | +import java.util.Set; |
| 20 | + |
14 | 21 | public final class TextHelper { |
15 | 22 |
|
| 23 | + public static final ResourceLocation FONT_ALT = new ResourceLocation("minecraft", "alt"); |
| 24 | + public static final ResourceLocation FONT_DEFAULT = new ResourceLocation("minecraft", "default"); |
| 25 | + public static final ResourceLocation FONT_ILLAGER = new ResourceLocation("minecraft", "illageralt"); |
| 26 | + public static final ResourceLocation FONT_UNIFORM = new ResourceLocation("minecraft", "uniform"); |
| 27 | + |
16 | 28 | public static MutableComponent getFormatedTime(int ticks, boolean includeHover) { |
17 | 29 |
|
18 | 30 | MutableComponent component = new TextComponent(StringUtil.formatTickDuration(ticks)); |
@@ -77,4 +89,14 @@ public static Component applyFont(Component text, ResourceLocation font) { |
77 | 89 | text.getSiblings().forEach(sib -> applyFont(sib, font)); |
78 | 90 | return text; |
79 | 91 | } |
| 92 | + |
| 93 | + public static Set<ResourceLocation> getRegisteredFonts() { |
| 94 | + |
| 95 | + if (!Services.PLATFORM.isPhysicalClient()) { |
| 96 | + |
| 97 | + return Collections.emptySet(); |
| 98 | + } |
| 99 | + |
| 100 | + return ((AccessorFontManager) (((AccessorMinecraft) Minecraft.getInstance()).bookshelf$getFontManager())).bookshelf$getFonts().keySet(); |
| 101 | + } |
80 | 102 | } |
0 commit comments