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:51:47 +0200 |
commit | cea074d422eba960a73e6df06c96fecbf5ca1385 (patch) | |
tree | c0e02129373a8998dccceb4b986eb02f2fa710d4 /src | |
parent | 0d51207e1ad2879b8ffed68791dcc40485d01418 (diff) | |
download | LibGui-cea074d422eba960a73e6df06c96fecbf5ca1385.tar.gz LibGui-cea074d422eba960a73e6df06c96fecbf5ca1385.tar.bz2 LibGui-cea074d422eba960a73e6df06c96fecbf5ca1385.zip |
Remove environment checking from WText line wrapping
Diffstat (limited to 'src')
-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 f8b83a4..ebf74b2 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; } |