diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-03-19 20:51:47 +0200 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-03-19 20:52:45 +0200 |
commit | fa6cb0b4b38c12835bfd668ec233464088a07427 (patch) | |
tree | 0c408cc242e080df40f7a1ebdfd3fb56364517cb /src/main/java/io | |
parent | 756caa3d5941f44fac9fe15676501e16275cdd3b (diff) | |
download | LibGui-fa6cb0b4b38c12835bfd668ec233464088a07427.tar.gz LibGui-fa6cb0b4b38c12835bfd668ec233464088a07427.tar.bz2 LibGui-fa6cb0b4b38c12835bfd668ec233464088a07427.zip |
Remove environment checking from WText line wrapping
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java index 64a7c3e..7982b2d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java @@ -6,7 +6,6 @@ import io.github.cottonmc.cotton.gui.client.TextHoverRendererScreen; import io.github.cottonmc.cotton.gui.widget.data.Alignment; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.screen.Screen; @@ -28,6 +27,7 @@ public class WText extends WWidget { protected int darkmodeColor; protected Alignment alignment = Alignment.LEFT; private List<Text> wrappedLines; + private boolean wrappingScheduled = false; public WText(Text text) { this(text, WLabel.DEFAULT_TEXT_COLOR); @@ -42,9 +42,7 @@ public class WText extends WWidget { @Override public void setSize(int x, int y) { super.setSize(x, y); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - wrapLines(); - } + wrappingScheduled = true; } @Environment(EnvType.CLIENT) @@ -74,6 +72,11 @@ public class WText extends WWidget { @Environment(EnvType.CLIENT) @Override public void paintBackground(int x, int y, int mouseX, int mouseY) { + if (wrappingScheduled) { + wrapLines(); + wrappingScheduled = false; + } + TextRenderer font = MinecraftClient.getInstance().textRenderer; for (int i = 0; i < wrappedLines.size(); i++) { Text line = wrappedLines.get(i); @@ -108,10 +111,7 @@ public class WText extends WWidget { public WText setText(Text text) { this.text = text; - - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - wrapLines(); - } + wrappingScheduled = true; return this; } |