diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-11-09 02:05:13 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-11-09 02:12:55 +0800 |
| commit | 2ac4538172cf27cc6873b43c442f3ec203b5057e (patch) | |
| tree | da622155f9e821083a40ec61590a53bb4b1cddf9 /forge/src | |
| parent | edc592c4df62212221f49ef4e62cfc8239e8ab60 (diff) | |
| download | RoughlyEnoughItems-2ac4538172cf27cc6873b43c442f3ec203b5057e.tar.gz RoughlyEnoughItems-2ac4538172cf27cc6873b43c442f3ec203b5057e.tar.bz2 RoughlyEnoughItems-2ac4538172cf27cc6873b43c442f3ec203b5057e.zip | |
Fix #1199
Diffstat (limited to 'forge/src')
| -rw-r--r-- | forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinFontSet.java | 60 | ||||
| -rw-r--r-- | forge/src/main/resources/rei.mixins.json | 1 |
2 files changed, 61 insertions, 0 deletions
diff --git a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinFontSet.java b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinFontSet.java new file mode 100644 index 000000000..0cba3c2ad --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinFontSet.java @@ -0,0 +1,60 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.mixin.forge; + +import com.mojang.blaze3d.font.GlyphInfo; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; +import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.client.gui.font.FontSet; +import net.minecraft.client.gui.font.FontTexture; +import net.minecraft.client.gui.font.glyphs.BakedGlyph; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Collections; +import java.util.List; + +@Mixin(FontSet.class) +public class MixinFontSet { + @Shadow @Mutable @Final private Int2ObjectMap<BakedGlyph> glyphs; + @Shadow @Mutable @Final private Int2ObjectMap<GlyphInfo> glyphInfos; + @Shadow @Mutable @Final private Int2ObjectMap<IntList> glyphsByWidth; + @Shadow @Mutable @Final private List<FontTexture> textures; + + @Inject(method = "<init>", at = @At("RETURN")) + private void init(TextureManager textureManager, ResourceLocation id, CallbackInfo ci) { + this.glyphs = Int2ObjectMaps.synchronize(this.glyphs); + this.glyphInfos = Int2ObjectMaps.synchronize(this.glyphInfos); + this.glyphsByWidth = Int2ObjectMaps.synchronize(this.glyphsByWidth); + this.textures = Collections.synchronizedList(this.textures); + } +} diff --git a/forge/src/main/resources/rei.mixins.json b/forge/src/main/resources/rei.mixins.json index d729d79f9..838df45f2 100644 --- a/forge/src/main/resources/rei.mixins.json +++ b/forge/src/main/resources/rei.mixins.json @@ -5,6 +5,7 @@ "client": [ "MixinClientPacketListener", "MixinEffectRenderingInventoryScreen", + "MixinFontSet", "MixinInputConstants", "MixinRecipeToast" ], |
