Skip to content

Commit 23e6fce

Browse files
committed
mixin to fix RichTextCompiler not handling newlines correctly
1 parent 9541894 commit 23e6fce

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package gregtech.mixins.mui2;
2+
3+
import com.cleanroommc.modularui.drawable.text.RichTextCompiler;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
5+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
10+
// todo remove once fixed in mui2
11+
@Mixin(value = RichTextCompiler.class, remap = false)
12+
public abstract class TextCompilerMixin {
13+
14+
@Shadow
15+
protected abstract void newLine();
16+
17+
@WrapOperation(method = "compile",
18+
at = @At(value = "INVOKE",
19+
target = "Lcom/cleanroommc/modularui/drawable/text/RichTextCompiler;compileString(Ljava/lang/String;)V"))
20+
public void fixString(RichTextCompiler instance, String c, Operation<Void> original) {
21+
String[] lines = c.replace("\\n", "/n").split("/n");
22+
for (int i = 0; i < lines.length; i++) {
23+
original.call(instance, lines[i]);
24+
if (i + 1 != lines.length) newLine();
25+
}
26+
}
27+
}

src/main/resources/mixins.gregtech.mui2.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"injectors": {
88
"maxShiftBy": 10
99
},
10-
"mixins": [],
10+
"mixins": [
11+
"TextCompilerMixin"
12+
],
1113
"client": [
1214
"LangKeyMixin"
1315
],

0 commit comments

Comments
 (0)