diff --git a/src/main/java/io/github/cruciblemc/necrotempus/modules/mixin/mixins/minecraft/FontRenderer2Mixin.java b/src/main/java/io/github/cruciblemc/necrotempus/modules/mixin/mixins/minecraft/FontRenderer2Mixin.java index 39acc52..b19d7ef 100644 --- a/src/main/java/io/github/cruciblemc/necrotempus/modules/mixin/mixins/minecraft/FontRenderer2Mixin.java +++ b/src/main/java/io/github/cruciblemc/necrotempus/modules/mixin/mixins/minecraft/FontRenderer2Mixin.java @@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -33,11 +34,21 @@ public class FontRenderer2Mixin { @Shadow private float alpha; - @Inject(method = "Lnet/minecraft/client/gui/FontRenderer;getCharWidth(C)I", at = @At("HEAD"), cancellable = true) + @Group(name = "necrotempus_fontRenderer_chatWidth", min = 1) + @Inject(method = "Lnet/minecraft/client/gui/FontRenderer;getCharWidth(C)I", at = @At("HEAD"), cancellable = true, expect = 0) public void getCharWidth(char character, CallbackInfoReturnable cir) { CustomGlyphs customGlyphs = GlyphsRegistry.getCandidate(character); if (customGlyphs != null) { - cir.setReturnValue(customGlyphs.getFinalCharacterWidth()); + cir.setReturnValue(customGlyphs.getFinalCharacterWidth()); + } + } + + @Group(name = "necrotempus_fontRenderer_chatWidth", min = 1) + @Inject(method = "Lnet/minecraft/client/gui/FontRenderer;getCharWidthFloat(C)F", at = @At("HEAD"), cancellable = true, remap = false, expect = 0) + public void getCharWidthFloat(char character, CallbackInfoReturnable cir) { + CustomGlyphs customGlyphs = GlyphsRegistry.getCandidate(character); + if (customGlyphs != null) { + cir.setReturnValue((float) customGlyphs.getFinalCharacterWidth()); } }