|
1 | 1 | package gregtech.mixins.mui2; |
2 | 2 |
|
| 3 | +import net.minecraft.client.gui.FontRenderer; |
| 4 | + |
| 5 | +import com.cleanroommc.modularui.api.drawable.IKey; |
3 | 6 | import com.cleanroommc.modularui.drawable.text.RichTextCompiler; |
| 7 | +import com.llamalad7.mixinextras.sugar.Local; |
4 | 8 | import org.spongepowered.asm.mixin.Mixin; |
| 9 | +import org.spongepowered.asm.mixin.Shadow; |
5 | 10 | import org.spongepowered.asm.mixin.injection.At; |
| 11 | +import org.spongepowered.asm.mixin.injection.Inject; |
6 | 12 | import org.spongepowered.asm.mixin.injection.ModifyArg; |
| 13 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 14 | + |
| 15 | +import java.util.List; |
7 | 16 |
|
8 | 17 | @Mixin(value = RichTextCompiler.class, remap = false) |
9 | 18 | public class RichTextCompilerMixin { |
10 | 19 |
|
| 20 | + @Shadow |
| 21 | + private int x; |
| 22 | + |
| 23 | + @Shadow |
| 24 | + private FontRenderer fr; |
| 25 | + |
11 | 26 | @ModifyArg(method = "trimRight", |
12 | 27 | at = @At(value = "INVOKE", |
13 | 28 | target = "Ljava/lang/String;substring(II)Ljava/lang/String;"), |
14 | 29 | index = 1) |
15 | 30 | private static int fixTrim(int beginIndex) { |
16 | 31 | return beginIndex + 1; |
17 | 32 | } |
| 33 | + |
| 34 | + @Inject(method = "compile", |
| 35 | + at = @At(value = "INVOKE", |
| 36 | + target = "Lcom/cleanroommc/modularui/drawable/text/RichTextCompiler;addLineElement(Ljava/lang/Object;)V", |
| 37 | + ordinal = 0)) |
| 38 | + private void moveXString(List<Object> raw, CallbackInfo ci, @Local IKey key) { |
| 39 | + x += fr.getStringWidth(key.get()); |
| 40 | + } |
18 | 41 | } |
0 commit comments