diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2022-06-16 17:00:59 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2022-06-16 17:00:59 +0300 |
commit | bf3e130211f6e0c9a1b6fad555fb3d38f6f984ea (patch) | |
tree | 332da6a8a349d2fd9c141ce9d3586c057be20c6d | |
parent | 9ca8ba7f9d1baac7dd8e7a66fb6a03675df3af1c (diff) | |
parent | a9b3426f17ca3de3557ebcea7b3c7494d8fe3054 (diff) | |
download | LibGui-bf3e130211f6e0c9a1b6fad555fb3d38f6f984ea.tar.gz LibGui-bf3e130211f6e0c9a1b6fad555fb3d38f6f984ea.tar.bz2 LibGui-bf3e130211f6e0c9a1b6fad555fb3d38f6f984ea.zip |
Merge branch 'unstable/6.0'
# Conflicts:
# gradle.properties
# src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ModMenuSupport.java
# src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java
# src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
28 files changed, 91 insertions, 139 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java index d443770..2739d51 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/GuiBlockEntity.java @@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerContext; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.BlockPos; @@ -36,7 +35,7 @@ public class GuiBlockEntity extends BlockEntity implements ImplementedInventory, @Override public Text getDisplayName() { - return new LiteralText("test title"); + return Text.literal("test title"); } @Nullable diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java b/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java index 69be1f4..6c74e28 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/TestDescription.java @@ -4,7 +4,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.SyncedGuiDescription; @@ -29,7 +29,7 @@ public class TestDescription extends SyncedGuiDescription { WItemSlot slot = WItemSlot.of(blockInventory, 0, 4, 1); root.add(slot, 0, 1); - WButton buttonA = new WButton(new LiteralText("Send Message")); + WButton buttonA = new WButton(Text.literal("Send Message")); buttonA.setOnClick(() -> { ScreenNetworking.of(this, NetworkSide.CLIENT).send(TEST_MESSAGE, buf -> {}); @@ -38,15 +38,15 @@ public class TestDescription extends SyncedGuiDescription { root.add(buttonA, 0, 3, 4, 1); - WButton buttonB = new WButton(new LiteralText("Show Warnings")); + WButton buttonB = new WButton(Text.literal("Show Warnings")); buttonB.setOnClick(() -> slot.setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png")))); root.add(buttonB, 5, 3, 4, 1); - root.add(new WButton(new LiteralText("Button C")), 0, 5, 4, 1); - root.add(new WButton(new LiteralText("Button D")), 5, 5, 4, 1); - root.add(new WTextField(new LiteralText("Type something...")).setMaxLength(64), 0, 7, 5, 1); + root.add(new WButton(Text.literal("Button C")), 0, 5, 4, 1); + root.add(new WButton(Text.literal("Button D")), 5, 5, 4, 1); + root.add(new WTextField(Text.literal("Type something...")).setMaxLength(64), 0, 7, 5, 1); - root.add(new WLabel(new LiteralText("Large slot:")), 0, 9); + root.add(new WLabel(Text.literal("Large slot:")), 0, 9); root.add(WItemSlot.outputOf(blockInventory, 0), 4, 9); root.add(WItemSlot.of(blockInventory, 7).setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))), 7, 9); diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java index abd36e6..f89de7a 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java @@ -1,22 +1,20 @@ package io.github.cottonmc.test.client; +import net.minecraft.text.Text; + import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; import io.github.cottonmc.cotton.gui.widget.WButton; import io.github.cottonmc.cotton.gui.widget.WGridPanel; - import io.github.cottonmc.cotton.gui.widget.WLabel; - import io.github.cottonmc.cotton.gui.widget.data.Insets; -import net.minecraft.text.LiteralText; - public class InsetsTestGui extends LightweightGuiDescription { public InsetsTestGui() { WGridPanel root = (WGridPanel) rootPanel; - root.add(new WLabel(new LiteralText("Insets demo")), 0, 0); - root.add(new WButton(new LiteralText("Default")).setOnClick(() -> root.setInsets(Insets.ROOT_PANEL)), 0, 1, 2, 1); - root.add(new WButton(new LiteralText("None")).setOnClick(() -> root.setInsets(Insets.NONE)), 2, 1, 2, 1); - root.add(new WButton(new LiteralText("Large")).setOnClick(() -> root.setInsets(new Insets(16))), 4, 1, 2, 1); + root.add(new WLabel(Text.literal("Insets demo")), 0, 0); + root.add(new WButton(Text.literal("Default")).setOnClick(() -> root.setInsets(Insets.ROOT_PANEL)), 0, 1, 2, 1); + root.add(new WButton(Text.literal("None")).setOnClick(() -> root.setInsets(Insets.NONE)), 2, 1, 2, 1); + root.add(new WButton(Text.literal("Large")).setOnClick(() -> root.setInsets(new Insets(16))), 4, 1, 2, 1); } } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java index fd031f5..c396a7f 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -2,11 +2,11 @@ package io.github.cottonmc.test.client; import com.mojang.brigadier.Command; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.HandledScreens; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.CottonClientScreen; import io.github.cottonmc.cotton.gui.client.CottonHud; @@ -20,7 +20,7 @@ import io.github.cottonmc.test.TestDescription; import java.util.function.Function; -import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; public class LibGuiTestClient implements ClientModInitializer { @@ -37,7 +37,7 @@ public class LibGuiTestClient implements ClientModInitializer { ); CottonHud.add(new WHudTest(), 10, -20, 10, 10); - CottonHud.add(new WLabel(new LiteralText("Test label")), 10, -30, 10, 10); + CottonHud.add(new WLabel(Text.literal("Test label")), 10, -30, 10, 10); ClientCommandManager.DISPATCHER.register( literal("libgui") diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java index 5a8f3f0..bfc25c4 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java @@ -1,7 +1,7 @@ package io.github.cottonmc.test.client; import net.minecraft.item.Items; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; import io.github.cottonmc.cotton.gui.widget.WBox; @@ -20,12 +20,12 @@ public class ScrollingTestGui extends LightweightGuiDescription { WBox box = new WBox(Axis.VERTICAL); for (int i = 0; i < 20; i++) { - box.add(new WLabeledSlider(0, 10, new LiteralText("Slider #" + i))); + box.add(new WLabeledSlider(0, 10, Text.literal("Slider #" + i))); } box.add(new WButton(new ItemIcon(Items.APPLE))); - root.add(new WLabel(new LiteralText("Scrolling test")).setVerticalAlignment(VerticalAlignment.CENTER), 0, 0, 5, 2); + root.add(new WLabel(Text.literal("Scrolling test")).setVerticalAlignment(VerticalAlignment.CENTER), 0, 0, 5, 2); root.add(new WScrollPanel(box), 0, 2, 5, 3); root.validate(this); } diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java index 6fa716d..8ed93f9 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java @@ -1,7 +1,7 @@ package io.github.cottonmc.test.client; import net.minecraft.item.Items; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; import io.github.cottonmc.cotton.gui.impl.modmenu.WKirbSprite; @@ -12,8 +12,8 @@ import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon; public class TabTestGui extends LightweightGuiDescription { public TabTestGui() { WTabPanel tabs = new WTabPanel(); - tabs.add(new WKirbSprite(), builder -> builder.title(new LiteralText("Kirb"))); - tabs.add(new WLabel(new LiteralText("just another tab")), builder -> builder.icon(new ItemIcon(Items.ANDESITE))); + tabs.add(new WKirbSprite(), builder -> builder.title(Text.literal("Kirb"))); + tabs.add(new WLabel(Text.literal("just another tab")), builder -> builder.icon(new ItemIcon(Items.ANDESITE))); tabs.setSize(7 * 18, 5 * 18); setRootPanel(tabs); diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java index 56b399c..672e56d 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java @@ -3,7 +3,7 @@ package io.github.cottonmc.test.client; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; @@ -31,11 +31,11 @@ public class TestClientGui extends LightweightGuiDescription { WGridPanel root = new WGridPanel(22); root.setInsets(Insets.ROOT_PANEL); this.setRootPanel(root); - WLabel title = new WLabel(new LiteralText("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) { + WLabel title = new WLabel(Text.literal("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) { @Environment(EnvType.CLIENT) @Override public void addTooltip(TooltipBuilder tooltip) { - tooltip.add(new LiteralText("Radical!")); + tooltip.add(Text.literal("Radical!")); } }; WTiledSprite wood = new WTiledSprite( @@ -49,7 +49,7 @@ public class TestClientGui extends LightweightGuiDescription { root.add(title, 0, 0); WTextField text = new WTextField(); - text.setSuggestion("Search"); + text.setSuggestion(Text.literal("Search")); root.add(text, 0, 1, 8, 1); text.setSize(7*18, 20); /* diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TextFieldTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TextFieldTestGui.java index dc2b68c..ce2a7b6 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TextFieldTestGui.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TextFieldTestGui.java @@ -1,7 +1,7 @@ package io.github.cottonmc.test.client; import net.minecraft.item.Items; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; import io.github.cottonmc.cotton.gui.widget.WButton; @@ -12,9 +12,9 @@ import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon; public class TextFieldTestGui extends LightweightGuiDescription { public TextFieldTestGui() { WGridPanel grid = (WGridPanel) rootPanel; - WTextField textField = new WTextField(new LiteralText("Type something")).setMaxLength(Integer.MAX_VALUE); + WTextField textField = new WTextField(Text.literal("Type something")).setMaxLength(Integer.MAX_VALUE); grid.add(textField, 0, 0, 6, 1); - grid.add(new WButton(new ItemIcon(Items.BARRIER), new LiteralText("Clear")).setOnClick(() -> textField.setText("")), 0, 2, 6, 1); + grid.add(new WButton(new ItemIcon(Items.BARRIER), Text.literal("Clear")).setOnClick(() -> textField.setText("")), 0, 2, 6, 1); rootPanel.validate(this); } } diff --git a/GuiTest/src/main/resources/fabric.mod.json b/GuiTest/src/main/resources/fabric.mod.json index bd2416f..1528093 100644 --- a/GuiTest/src/main/resources/fabric.mod.json +++ b/GuiTest/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ "main": [ "io.github.cottonmc.test.LibGuiTest"], "client": [ "io.github.cottonmc.test.client.LibGuiTestClient" ] }, - "depends": { + "depends": { "fabricloader": ">=0.4.0", "libgui": "*", "jankson": "*", diff --git a/gradle.properties b/gradle.properties index 169ed03..e265817 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.2 - loader_version=0.13.3 + minecraft_version=1.19-pre1 + yarn_mappings=1.19-pre1+build.1 + loader_version=0.14.5 # Mod Properties - mod_version = 5.4.2 + mod_version = 6.0.0-beta.5 maven_group = io.github.cottonmc archives_base_name = LibGui # Dependencies - fabric_version=0.48.0+1.18.2 - jankson_version=4.0.0+j1.2.0 - modmenu_version=3.1.0 + fabric_version=0.53.0+1.19 + jankson_version=4.1.1+j1.2.1 + modmenu_version=3.1.1 libninepatch_version=1.1.0 diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java index 1751d4d..0ae199e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java @@ -1,9 +1,9 @@ package io.github.cottonmc.cotton.gui.client; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ScreenTexts; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -44,7 +44,7 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl { private final MouseInputHandler<CottonClientScreen> mouseInputHandler = new MouseInputHandler<>(this); public CottonClientScreen(GuiDescription description) { - this(new LiteralText(""), description); + this(ScreenTexts.EMPTY, description); } public CottonClientScreen(Text title, GuiDescription description) { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index af11018..e8a2b51 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -1,12 +1,12 @@ package io.github.cottonmc.cotton.gui.client; +import net.minecraft.client.gui.screen.ScreenTexts; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.render.DiffuseLighting; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.text.LiteralText; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -41,7 +41,7 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl * @since 5.2.0 */ public CottonInventoryScreen(T description, PlayerInventory inventory) { - this(description, inventory, new LiteralText("")); + this(description, inventory, ScreenTexts.EMPTY); } /** diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java index 33d8b43..4fcb3f2 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java @@ -146,8 +146,7 @@ public class ScreenDrawing { buffer.vertex(model, x + width, y + height, 0).texture(u2, v2).next(); buffer.vertex(model, x + width, y, 0).texture(u2, v1).next(); buffer.vertex(model, x, y, 0).texture(u1, v1).next(); - buffer.end(); - BufferRenderer.draw(buffer); + BufferRenderer.drawWithShader(buffer.end()); RenderSystem.disableBlend(); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java index 3f17aa4..f54e9fa 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/VisualLogger.java @@ -5,7 +5,6 @@ import net.fabricmc.api.Environment; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; import net.minecraft.text.OrderedText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -45,9 +44,9 @@ public final class VisualLogger { logger.log(level, message, params); if (FabricLoader.getInstance().isDevelopmentEnvironment()) { - var text = new LiteralText(clazz.getSimpleName() + '/'); - text.append(new LiteralText(level.name()).formatted(formatting)); - text.append(new LiteralText(": " + ParameterizedMessage.format(message, params))); + var text = Text.literal(clazz.getSimpleName() + '/'); + text.append(Text.literal(level.name()).formatted(formatting)); + text.append(Text.literal(": " + ParameterizedMessage.format(message, params))); WARNINGS.add(text); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationHelper.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationHelper.java index 54567be..f279d30 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationHelper.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationHelper.java @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; @@ -26,7 +26,7 @@ public final class NarrationHelper { // replicates Screen.addElementNarrations if (narratableWidgets.size() > 1) { - builder.put(NarrationPart.POSITION, new TranslatableText(NarrationMessages.Vanilla.SCREEN_POSITION_KEY, i + 1, childCount)); + builder.put(NarrationPart.POSITION, Text.translatable(NarrationMessages.Vanilla.SCREEN_POSITION_KEY, i + 1, childCount)); if (child.isFocused()) { builder.put(NarrationPart.USAGE, NarrationMessages.Vanilla.COMPONENT_LIST_USAGE); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationMessages.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationMessages.java index d76dba1..5f4563b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationMessages.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/NarrationMessages.java @@ -1,29 +1,28 @@ package io.github.cottonmc.cotton.gui.impl.client; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; public final class NarrationMessages { public static final String ITEM_SLOT_TITLE_KEY = "widget.libgui.item_slot.narration.title"; public static final String LABELED_SLIDER_TITLE_KEY = "widget.libgui.labeled_slider.narration.title"; - public static final Text SCROLL_BAR_TITLE = new TranslatableText("widget.libgui.scroll_bar.narration.title"); + public static final Text SCROLL_BAR_TITLE = Text.translatable("widget.libgui.scroll_bar.narration.title"); public static final String SLIDER_MESSAGE_KEY = "widget.libgui.slider.narration.title"; - public static final Text SLIDER_USAGE = new TranslatableText("widget.libgui.slider.narration.usage"); + public static final Text SLIDER_USAGE = Text.translatable("widget.libgui.slider.narration.usage"); public static final String TAB_TITLE_KEY = "widget.libgui.tab.narration.title"; public static final String TAB_POSITION_KEY = "widget.libgui.tab.narration.position"; public static final String TEXT_FIELD_TITLE_KEY = "widget.libgui.text_field.narration.title"; public static final String TEXT_FIELD_SUGGESTION_KEY = "widget.libgui.text_field.narration.suggestion"; public static final String TOGGLE_BUTTON_NAMED_KEY = "widget.libgui.toggle_button.narration.named"; - public static final Text TOGGLE_BUTTON_OFF = new TranslatableText("widget.libgui.toggle_button.narration.off"); - public static final Text TOGGLE_BUTTON_ON = new TranslatableText("widget.libgui.toggle_button.narration.on"); + public static final Text TOGGLE_BUTTON_OFF = Text.translatable("widget.libgui.toggle_button.narration.off"); + public static final Text TOGGLE_BUTTON_ON = Text.translatable("widget.libgui.toggle_button.narration.on"); public static final String TOGGLE_BUTTON_UNNAMED_KEY = "widget.libgui.toggle_button.narration.unnamed"; public static final class Vanilla { - public static final Text BUTTON_USAGE_FOCUSED = new TranslatableText("narration.button.usage.focused"); - public static final Text BUTTON_USAGE_HOVERED = new TranslatableText("narration.button.usage.hovered"); - public static final Text COMPONENT_LIST_USAGE = new TranslatableText("narration.component_list.usage"); - public static final Text INVENTORY = new TranslatableText("container.inventory"); + public static final Text BUTTON_USAGE_FOCUSED = Text.translatable("narration.button.usage.focused"); + public static final Text BUTTON_USAGE_HOVERED = Text.translatable("narration.button.usage.hovered"); + public static final Text COMPONENT_LIST_USAGE = Text.translatable("narration.component_list.usage"); + public static final Text INVENTORY = Text.translatable("container.inventory"); public static final String SCREEN_POSITION_KEY = "narrator.position.screen"; - public static final Text HOTBAR = new TranslatableText("options.attack.hotbar"); + public static final Text HOTBAR = Text.translatable("options.attack.hotbar"); } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ConfigGui.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ConfigGui.java index b1faf17..2931d46 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ConfigGui.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ConfigGui.java @@ -2,7 +2,8 @@ package io.github.cottonmc.cotton.gui.impl.modmenu; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.TranslatableText; +import net.minecraft.client.gui.screen.ScreenTexts; +import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.BackgroundPainter; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; @@ -20,7 +21,7 @@ public class ConfigGui extends LightweightGuiDescription { root.setInsets(Insets.ROOT_PANEL); setRootPanel(root); - WToggleButton darkmodeButton = new WToggleButton(new TranslatableText("option.libgui.darkmode")) { + WToggleButton darkmodeButton = new WToggleButton(Text.translatable("option.libgui.darkmode")) { @Override public void onToggle(boolean on) { LibGuiClient.config.darkMode = on; @@ -31,7 +32,7 @@ public class ConfigGui extends LightweightGuiDescription { root.add(darkmodeButton, 0, 2, 6, 1); WTextField testField = new WTextField(); - testField.setSuggestion("test"); + testField.setSuggestion(Text.literal("test")); root.add(testField, 0, 3, 4, 1); /* @@ -50,7 +51,7 @@ public class ConfigGui extends LightweightGuiDescription { root.add(new WKirbSprite(), 5, 4); - WButton doneButton = new WButton(new TranslatableText("gui.done")); + WButton doneButton = new WButton(ScreenTexts.DONE); doneButton.setOnClick(()->{ MinecraftClient.getInstance().setScreen(previous); }); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ModMenuSupport.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ModMenuSupport.java index b089694..f5baccb 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ModMenuSupport.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/modmenu/ModMenuSupport.java @@ -1,6 +1,6 @@ package io.github.cottonmc.cotton.gui.impl.modmenu; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; @@ -9,7 +9,7 @@ import io.github.cottonmc.cotton.gui.client.CottonClientScreen; public class ModMenuSupport implements ModMenuApi { @Override public ConfigScreenFactory<?> getModConfigScreenFactory() { - return screen -> new CottonClientScreen(new TranslatableText("options.libgui.libgui_settings"), new ConfigGui(screen)) { + return screen -> new CottonClientScreen(Text.translatable("options.libgui.libgui_settings"), new ConfigGui(screen)) { @Override public void close() { this.client.setScreen(screen); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index fa850ed..83ad651 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages; @@ -367,7 +367,7 @@ public abstract class WAbstractSlider extends WWidget { @Environment(EnvType.CLIENT) @Override public void addNarrations(NarrationMessageBuilder builder) { - builder.put(NarrationPart.TITLE, new TranslatableText(NarrationMessages.SLIDER_MESSAGE_KEY, value, min, max)); + builder.put(NarrationPart.TITLE, Text.translatable(NarrationMessages.SLIDER_MESSAGE_KEY, value, min, max)); builder.put(NarrationPart.USAGE, NarrationMessages.SLIDER_USAGE); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java index a35ead8..b6a6dd8 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java @@ -4,9 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.PropertyDelegate; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -205,13 +203,13 @@ public class WBar extends WWidget { if (tooltipLabel != null) { int value = (field >= 0) ? properties.get(field) : 0; int valMax = (max >= 0) ? properties.get(max) : maxValue; - information.add(new TranslatableText(tooltipLabel, Integer.valueOf(value), Integer.valueOf(valMax))); + information.add(Text.translatable(tooltipLabel, value, valMax)); } if (tooltipTextComponent != null) { try { information.add(tooltipTextComponent); } catch (Throwable t) { - information.add(new LiteralText(t.getLocalizedMessage())); + information.add(Text.literal(t.getLocalizedMessage())); } } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java index 21abe8b..178f6c5 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java @@ -9,7 +9,9 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; -import net.minecraft.tag.Tag; +import net.minecraft.tag.TagKey; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryEntry; import com.google.common.collect.ImmutableList; @@ -32,7 +34,7 @@ public class WItem extends WWidget { setItems(items); } - public WItem(Tag<? extends ItemConvertible> tag) { + public WItem(TagKey<? extends ItemConvertible> tag) { this(getRenderStacks(tag)); } @@ -104,13 +106,15 @@ public class WItem extends WWidget { } /** - * Gets the render stacks ({@link Item#getStackForRender()}) of each item in a tag. + * Gets the default stacks ({@link Item#getDefaultStack()} ()}) of each item in a tag. */ - private static List<ItemStack> getRenderStacks(Tag<? extends ItemConvertible> tag) { + @SuppressWarnings("unchecked") + private static List<ItemStack> getRenderStacks(TagKey<? extends ItemConvertible> tag) { + Registry<ItemConvertible> registry = (Registry<ItemConvertible>) Registry.REGISTRIES.get(tag.registry().getValue()); ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); - for (ItemConvertible item : tag.values()) { - builder.add(new ItemStack(item)); + for (RegistryEntry<ItemConvertible> item : registry.getOrCreateEntryList((TagKey<ItemConvertible>) tag)) { + builder.add(item.value().asItem().getDefaultStack()); } return builder.build(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java index 288c922..ec8ae96 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java @@ -12,7 +12,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import io.github.cottonmc.cotton.gui.GuiDescription; import io.github.cottonmc.cotton.gui.ValidatedSlot; @@ -463,9 +462,9 @@ public class WItemSlot extends WWidget { if (name != null) parts.add(name); if (focusedSlot >= 0) { - parts.add(new TranslatableText(NarrationMessages.ITEM_SLOT_TITLE_KEY, focusedSlot + 1, slotsWide * slotsHigh)); + parts.add(Text.translatable(NarrationMessages.ITEM_SLOT_TITLE_KEY, focusedSlot + 1, slotsWide * slotsHigh)); } else if (hoveredSlot >= 0) { - parts.add(new TranslatableText(NarrationMessages.ITEM_SLOT_TITLE_KEY, hoveredSlot + 1, slotsWide * slotsHigh)); + parts.add(Text.translatable(NarrationMessages.ITEM_SLOT_TITLE_KEY, hoveredSlot + 1, slotsWide * slotsHigh)); } builder.put(NarrationPart.TITLE, parts.toArray(new Text[0])); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java index f2c9540..752d919 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java @@ -8,7 +8,6 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -18,7 +17,6 @@ import io.github.cottonmc.cotton.gui.impl.client.LibGuiConfig; import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment; import io.github.cottonmc.cotton.gui.widget.data.InputResult; import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; /** @@ -46,19 +44,6 @@ public class WLabel extends WWidget { * * @param text the text of the label * @param color the color of the label - * @deprecated Use {@link #WLabel(Text, int)} instead. - */ - @Deprecated(forRemoval = true, since = "5.4.0") - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - public WLabel(String text, int color) { - this(new LiteralText(text), color); - } - - /** - * Constructs a new label. - * - * @param text the text of the label - * @param color the color of the label */ public WLabel(Text text, int color) { this.text = text; @@ -70,18 +55,6 @@ public class WLabel extends WWidget { * Constructs a new label with the {@linkplain #DEFAULT_TEXT_COLOR default text color}. * * @param text the text of the label - * @deprecated Use {@link #WLabel(Text)} instead. - */ - @Deprecated(forRemoval = true, since = "5.4.0") - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - public WLabel(String text) { - this(text, DEFAULT_TEXT_COLOR); - } - - /** - * Constructs a new label with the {@linkplain #DEFAULT_TEXT_COLOR default text color}. - * - * @param text the text of the label * @since 1.8.0 */ public WLabel(Text text) { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java index 2f972ff..a8a912b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java @@ -6,7 +6,6 @@ import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3f; @@ -220,7 +219,7 @@ public class WLabeledSlider extends WAbstractSlider { @Override public void addNarrations(NarrationMessageBuilder builder) { if (getLabel() != null) { - builder.put(NarrationPart.TITLE, new TranslatableText(NarrationMessages.LABELED_SLIDER_TITLE_KEY, getLabel(), value, min, max)); + builder.put(NarrationPart.TITLE, Text.translatable(NarrationMessages.LABELED_SLIDER_TITLE_KEY, getLabel(), value, min, max)); builder.put(NarrationPart.USAGE, NarrationMessages.SLIDER_USAGE); } else { super.addNarrations(builder); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java index 95c43f4..ab1703c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java @@ -10,7 +10,6 @@ import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.client.BackgroundPainter; @@ -363,10 +362,10 @@ public class WTabPanel extends WPanel { Text label = data.getTitle(); if (label != null) { - builder.put(NarrationPart.TITLE, new TranslatableText(NarrationMessages.TAB_TITLE_KEY, label)); + builder.put(NarrationPart.TITLE, Text.translatable(NarrationMessages.TAB_TITLE_KEY, label)); } - builder.put(NarrationPart.POSITION, new TranslatableText(NarrationMessages.TAB_POSITION_KEY, tabWidgets.indexOf(this) + 1, tabWidgets.size())); + builder.put(NarrationPart.POSITION, Text.translatable(NarrationMessages.TAB_POSITION_KEY, tabWidgets.indexOf(this) + 1, tabWidgets.size())); } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java index 6251c2e..69c8755 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java @@ -16,9 +16,7 @@ import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Matrix4f; @@ -26,7 +24,6 @@ import io.github.cottonmc.cotton.gui.client.BackgroundPainter; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages; import io.github.cottonmc.cotton.gui.widget.data.InputResult; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; @@ -264,8 +261,7 @@ public class WTextField extends WWidget { buffer.vertex(model, x + width, y + height, 0).next(); buffer.vertex(model, x + width, y, 0).next(); buffer.vertex(model, x, y, 0).next(); - buffer.end(); - BufferRenderer.draw(buffer); + BufferRenderer.drawWithShader(buffer.end()); RenderSystem.disableColorLogicOp(); RenderSystem.enableTexture(); } @@ -313,16 +309,6 @@ public class WTextField extends WWidget { return suggestion; } - /** - * @deprecated Use {@link #setSuggestion(Text)} instead. - */ - @Deprecated(forRemoval = true, since = "5.4.0") - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - public WTextField setSuggestion(@Nullable String suggestion) { - this.suggestion = suggestion != null ? new LiteralText(suggestion) : null; - return this; - } - public WTextField setSuggestion(@Nullable Text suggestion) { this.suggestion = suggestion; return this; @@ -508,10 +494,10 @@ public class WTextField extends WWidget { @Override public void addNarrations(NarrationMessageBuilder builder) { - builder.put(NarrationPart.TITLE, new TranslatableText(NarrationMessages.TEXT_FIELD_TITLE_KEY, text)); + builder.put(NarrationPart.TITLE, Text.translatable(NarrationMessages.TEXT_FIELD_TITLE_KEY, text)); if (suggestion != null) { - builder.put(NarrationPart.HINT, new TranslatableText(NarrationMessages.TEXT_FIELD_SUGGESTION_KEY, suggestion)); + builder.put(NarrationPart.HINT, Text.translatable(NarrationMessages.TEXT_FIELD_SUGGESTION_KEY, suggestion)); } } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java index ca0285f..1149a9b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java @@ -9,7 +9,6 @@ import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.client.LibGui; @@ -214,9 +213,9 @@ public class WToggleButton extends WWidget { Text title; if (label != null) { - title = new TranslatableText(NarrationMessages.TOGGLE_BUTTON_NAMED_KEY, label, onOff); + title = Text.translatable(NarrationMessages.TOGGLE_BUTTON_NAMED_KEY, label, onOff); } else { - title = new TranslatableText(NarrationMessages.TOGGLE_BUTTON_UNNAMED_KEY, onOff); + title = Text.translatable(NarrationMessages.TOGGLE_BUTTON_UNNAMED_KEY, onOff); } builder.put(NarrationPart.TITLE, title); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 085ceac..b3597f3 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "fabric-lifecycle-events-v1": "^2.0.2", "fabric-networking-api-v1": "^1.0.21", "fabric-rendering-v1": "^1.10.7", - "minecraft": "~1.18.2", + "minecraft": ">=1.19-beta.1", "jankson": "^4.0.0", "libninepatch": "^1.1.0" }, |