Skip to content

Commit

Permalink
Merge branch 'unstable/6.0'
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
Juuxel committed Jun 16, 2022
2 parents 9ca8ba7 + a9b3426 commit bf3e130
Show file tree
Hide file tree
Showing 28 changed files with 91 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;
Expand Down Expand Up @@ -36,7 +35,7 @@ public boolean canPlayerUse(PlayerEntity player) {

@Override
public Text getDisplayName() {
return new LiteralText("test title");
return Text.literal("test title");
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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;
Expand All @@ -29,7 +29,7 @@ public TestDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory pl
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 -> {});
Expand All @@ -38,15 +38,15 @@ public TestDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory pl

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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;
Expand All @@ -20,7 +20,7 @@

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 {

Expand All @@ -37,7 +37,7 @@ public void onInitializeClient() {
);

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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,12 +20,12 @@ public ScrollingTestGui() {
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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,8 +12,8 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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;
Expand Down Expand Up @@ -31,11 +31,11 @@ public TestClientGui() {
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(
Expand All @@ -49,7 +49,7 @@ public void addTooltip(TooltipBuilder tooltip) {
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);
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,9 +12,9 @@
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);
}
}
2 changes: 1 addition & 1 deletion GuiTest/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ public static void texturedRect(MatrixStack matrices, int x, int y, int width, i
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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;
Expand Down Expand Up @@ -45,9 +44,9 @@ private void log(String message, Object[] params, Level level, Formatting format
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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;
Expand All @@ -26,7 +26,7 @@ public static void addNarrations(WPanel rootPanel, NarrationMessageBuilder build

// 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}
Loading

0 comments on commit bf3e130

Please sign in to comment.