diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index 603e9c79..436e0c79 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -37,7 +37,6 @@ import de.florianmichael.viafabricplus.settings.impl.VisualSettings; import de.florianmichael.viafabricplus.util.DataCustomPayload; import net.minecraft.block.*; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.FontStorage; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ServerAddress; import net.minecraft.client.option.SimpleOption; @@ -109,11 +108,7 @@ public class ClientsideFixes { // Reloads some clientside stuff when the protocol version changes ChangeProtocolVersionCallback.EVENT.register((oldVersion, newVersion) -> { MinecraftClient.getInstance().execute(() -> { - // Clear all font caches to enforce a reload of all fonts (this is needed because we change the font renderer behavior) - for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) { - storage.glyphRendererCache.clear(); - storage.glyphCache.clear(); - } + VisualSettings.global().filterNonExistingGlyphs.onValueChanged(); // Reloads all bounding boxes of the blocks that we changed for (Block block : Registries.BLOCK) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java index 513a85f6..d969a987 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java @@ -87,7 +87,11 @@ public abstract class MixinFontStorage { @Unique private boolean viaFabricPlus$shouldBeInvisible(final int codePoint) { - return (this.id.equals(MinecraftClient.DEFAULT_FONT_ID) || this.id.equals(MinecraftClient.UNICODE_FONT_ID)) && !RenderableGlyphDiff.isGlyphRenderable(codePoint); + if (VisualSettings.global().filterNonExistingGlyphs.getValue()) { + return (this.id.equals(MinecraftClient.DEFAULT_FONT_ID) || this.id.equals(MinecraftClient.UNICODE_FONT_ID)) && !RenderableGlyphDiff.isGlyphRenderable(codePoint); + } else { + return false; + } } @Unique diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/base/AbstractSetting.java b/src/main/java/de/florianmichael/viafabricplus/settings/base/AbstractSetting.java index 6145c200..c12c4fec 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/base/AbstractSetting.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/base/AbstractSetting.java @@ -60,6 +60,9 @@ public abstract class AbstractSetting { public abstract void write(final JsonObject object); public abstract void read(final JsonObject object); + public void onValueChanged() { + } + public MutableText getName() { return name; } @@ -91,6 +94,7 @@ public abstract class AbstractSetting { public void setValue(T value) { this.value = value; + onValueChanged(); } public Text getTooltip() { diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java index 206ef936..632025ff 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java @@ -20,9 +20,12 @@ package de.florianmichael.viafabricplus.settings.impl; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.settings.base.BooleanSetting; import de.florianmichael.viafabricplus.settings.base.ModeSetting; import de.florianmichael.viafabricplus.settings.base.SettingGroup; import de.florianmichael.viafabricplus.settings.base.VersionedBooleanSetting; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.FontStorage; import net.minecraft.text.Text; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialoader.util.VersionRange; @@ -36,6 +39,19 @@ public class VisualSettings extends SettingGroup { Text.translatable("change_game_menu_screen_layout.viafabricplus.adjusted"), Text.translatable("base.viafabricplus.off") ); + public final BooleanSetting filterNonExistingGlyphs = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.filter_non_existing_glyphs"), true) { + + @Override + public void onValueChanged() { + final MinecraftClient client = MinecraftClient.getInstance(); + if (client != null) { + for (FontStorage storage : client.fontManager.fontStorages.values()) { + storage.glyphRendererCache.clear(); + storage.glyphCache.clear(); + } + } + } + }; // 1.21 -> 1.20.5 public final VersionedBooleanSetting hideDownloadTerrainScreenTransitionEffects = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_download_terrain_screen_transition_effects"), VersionRange.andOlder(ProtocolVersion.v1_20_5)); diff --git a/src/main/resources/assets/viafabricplus/lang/de_de.json b/src/main/resources/assets/viafabricplus/lang/de_de.json index 30ecca15..b4c26693 100644 --- a/src/main/resources/assets/viafabricplus/lang/de_de.json +++ b/src/main/resources/assets/viafabricplus/lang/de_de.json @@ -101,6 +101,7 @@ "visual_settings.viafabricplus.hide_crafting_recipe_book": "Bastelrezeptbuch verstecken", "visual_settings.viafabricplus.hide_modern_jigsaw_screen_features": "Moderne Puzzle-Funktionen ausblenden", "visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages": "Unicode-Schrift für nicht-ASCII-Sprachen erzwingen", + "visual_settings.viafabricplus.filter_non_existing_glyphs": "Nicht vorhandene Glyphen filtern", "force_version.viafabricplus.title": "Version festlegen, mit der der Server gepingt/verbunden werden soll", diff --git a/src/main/resources/assets/viafabricplus/lang/en_us.json b/src/main/resources/assets/viafabricplus/lang/en_us.json index 044d85d3..ba338f63 100644 --- a/src/main/resources/assets/viafabricplus/lang/en_us.json +++ b/src/main/resources/assets/viafabricplus/lang/en_us.json @@ -103,6 +103,7 @@ "visual_settings.viafabricplus.hide_crafting_recipe_book": "Hide crafting recipe book", "visual_settings.viafabricplus.hide_modern_jigsaw_screen_features": "Hide modern Jigsaw screen features", "visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages": "Force Unicode font for non-ASCII languages", + "visual_settings.viafabricplus.filter_non_existing_glyphs": "Filter non existing glyphs", "force_version.viafabricplus.title": "Please select the version with which the server should be pinged/connected",