Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit d883251

Browse files
committed
feat: 1.19 update
1 parent f955cb8 commit d883251

File tree

20 files changed

+101
-98
lines changed

20 files changed

+101
-98
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- '1.18'
7+
- '1.19'
88
paths-ignore:
99
- 'README.md'
1010

common/src/main/java/com/github/franckyi/guapi/api/GuapiHelper.java

+12-13
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import com.github.franckyi.guapi.api.util.Align;
1111
import com.github.franckyi.guapi.api.util.Insets;
1212
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
13-
import net.minecraft.network.chat.*;
13+
import net.minecraft.network.chat.ClickEvent;
14+
import net.minecraft.network.chat.Component;
15+
import net.minecraft.network.chat.MutableComponent;
1416
import net.minecraft.resources.ResourceLocation;
1517
import net.minecraft.world.item.ItemStack;
1618

@@ -199,6 +201,7 @@ public static <E> ListViewBuilder<E> listView(Class<E> eClass, int itemHeight) {
199201
return node().createListView(eClass, itemHeight);
200202
}
201203

204+
@SafeVarargs
202205
public static <E> ListViewBuilder<E> listView(int itemHeight, E... items) {
203206
return node().createListView(itemHeight, items);
204207
}
@@ -391,26 +394,22 @@ public static SceneBuilder scene(Consumer<SceneBuilder> with) {
391394
return node().createScene(with);
392395
}
393396

394-
public static final MutableComponent EMPTY_TEXT = (MutableComponent) TextComponent.EMPTY;
397+
public static final MutableComponent EMPTY_TEXT = Component.empty();
395398

396-
public static TextComponent text() {
399+
public static MutableComponent text() {
397400
return text("");
398401
}
399402

400-
public static TextComponent text(String text) {
401-
return new TextComponent(text);
403+
public static MutableComponent text(String text) {
404+
return Component.literal(text);
402405
}
403406

404-
public static TranslatableComponent translated() {
405-
return translated(null);
407+
public static MutableComponent translated(String key) {
408+
return Component.translatable(key);
406409
}
407410

408-
public static TranslatableComponent translated(String key) {
409-
return new TranslatableComponent(key);
410-
}
411-
412-
public static TranslatableComponent translated(String key, Object... args) {
413-
return new TranslatableComponent(key, args);
411+
public static MutableComponent translated(String key, Object... args) {
412+
return Component.translatable(key, args);
414413
}
415414

416415
public static ClickEvent event(ClickEvent.Action action, String value) {

common/src/main/java/com/github/franckyi/guapi/base/ScreenHandlerImpl.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.github.franckyi.databindings.api.IntegerProperty;
44
import com.github.franckyi.databindings.api.ObjectProperty;
55
import com.github.franckyi.guapi.api.Guapi;
6+
import com.github.franckyi.guapi.api.GuapiHelper;
67
import com.github.franckyi.guapi.api.ScreenHandler;
78
import com.github.franckyi.guapi.api.event.ScreenEvent;
89
import com.github.franckyi.guapi.api.node.Scene;
@@ -11,7 +12,7 @@
1112
import com.mojang.blaze3d.vertex.PoseStack;
1213
import net.minecraft.client.Minecraft;
1314
import net.minecraft.client.gui.screens.Screen;
14-
import net.minecraft.network.chat.TextComponent;
15+
import org.jetbrains.annotations.NotNull;
1516

1617
import java.util.ArrayDeque;
1718
import java.util.Deque;
@@ -170,11 +171,11 @@ private <E extends ScreenEvent> boolean handleEvent(ScreenEventType<E> type, E e
170171

171172
private final class GuapiScreen extends Screen {
172173
private GuapiScreen() {
173-
super(TextComponent.EMPTY);
174+
super(GuapiHelper.EMPTY_TEXT);
174175
}
175176

176177
@Override
177-
public void render(PoseStack matrices, int mouseX, int mouseY, float partialTicks) {
178+
public void render(@NotNull PoseStack matrices, int mouseX, int mouseY, float partialTicks) {
178179
if (!currentSceneProperty().hasValue()) return;
179180
if (getCurrentScene().isTexturedBackground()) {
180181
renderDirtBackground(0);

common/src/main/java/com/github/franckyi/guapi/base/theme/vanilla/delegate/VanillaSliderSkinDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import com.github.franckyi.guapi.api.node.Slider;
44
import net.minecraft.client.gui.components.AbstractSliderButton;
5-
import net.minecraft.network.chat.TextComponent;
5+
import net.minecraft.network.chat.Component;
66
import net.minecraft.util.Mth;
77
import org.lwjgl.glfw.GLFW;
88

99
public class VanillaSliderSkinDelegate extends AbstractSliderButton implements VanillaWidgetSkinDelegate {
1010
private final Slider node;
1111

1212
public VanillaSliderSkinDelegate(Slider node) {
13-
super(node.getX(), node.getY(), node.getWidth(), node.getHeight(), TextComponent.EMPTY, node.getValue());
13+
super(node.getX(), node.getY(), node.getWidth(), node.getHeight(), Component.empty(), node.getValue());
1414
this.node = node;
1515
initNodeWidget(node);
1616
node.valueProperty().addListener(this::updateValue);

common/src/main/java/com/github/franckyi/guapi/base/theme/vanilla/delegate/VanillaTextFieldSkinDelegate.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import net.minecraft.network.chat.Component;
1010
import net.minecraft.network.chat.FormattedText;
1111
import net.minecraft.network.chat.Style;
12-
import net.minecraft.network.chat.TextComponent;
1312
import net.minecraft.util.FormattedCharSequence;
1413
import net.minecraft.util.Mth;
14+
import org.jetbrains.annotations.NotNull;
1515

1616
import java.util.Objects;
1717

@@ -86,7 +86,7 @@ private void updatePlaceholder() {
8686
}
8787

8888
public Component renderText(String str, int firstCharacterIndex) {
89-
return node.getTextRenderer() == null ? new TextComponent(str) : node.getTextRenderer().render(str, firstCharacterIndex);
89+
return node.getTextRenderer() == null ? Component.literal(str) : node.getTextRenderer().render(str, firstCharacterIndex);
9090
}
9191

9292
@Override
@@ -110,7 +110,7 @@ public void setHighlightPos(int value) {
110110
}
111111

112112
@Override
113-
public void insertText(String string) {
113+
public void insertText(@NotNull String string) {
114114
int oldCursorPos = getCursorPosition();
115115
int oldHighlightPos = node.getHighlightPosition();
116116
String oldText = getValue();
@@ -167,7 +167,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
167167
}
168168

169169
@Override
170-
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
170+
public void renderButton(@NotNull PoseStack matrices, int mouseX, int mouseY, float delta) {
171171
Font font = Minecraft.getInstance().font;
172172
if (isVisible()) {
173173
if (self.isBordered()) {

common/src/main/java/com/github/franckyi/guapi/base/theme/vanilla/delegate/VanillaTexturedButtonSkinDelegate.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
import com.github.franckyi.guapi.api.node.TexturedButton;
44
import com.mojang.blaze3d.vertex.PoseStack;
55
import net.minecraft.client.gui.components.Button;
6-
import net.minecraft.network.chat.TextComponent;
6+
import net.minecraft.network.chat.Component;
7+
import org.jetbrains.annotations.NotNull;
78

89
public class VanillaTexturedButtonSkinDelegate<N extends TexturedButton> extends Button implements VanillaWidgetSkinDelegate {
910
protected final N node;
1011

1112
public VanillaTexturedButtonSkinDelegate(N node) {
12-
super(node.getX(), node.getY(), node.getWidth(), node.getHeight(), node.getTooltip().isEmpty() ? TextComponent.EMPTY : node.getTooltip().get(0), button -> {
13+
super(node.getX(), node.getY(), node.getWidth(), node.getHeight(), node.getTooltip().isEmpty() ? Component.empty() : node.getTooltip().get(0), button -> {
1314
});
1415
this.node = node;
1516
initNodeWidget(node);
1617
}
1718

1819
@Override
19-
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
20+
public void renderButton(@NotNull PoseStack matrices, int mouseX, int mouseY, float delta) {
2021
if (node.isDrawButton()) {
2122
super.renderButton(matrices, mouseX, mouseY, delta);
2223
}

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/controller/entry/TextEntryController.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.github.franckyi.ibeeditor.client.screen.view.entry.TextEntryView;
66
import com.github.franckyi.ibeeditor.client.util.texteditor.*;
77
import net.minecraft.network.chat.Component;
8-
import net.minecraft.network.chat.TextComponent;
8+
import net.minecraft.network.chat.MutableComponent;
99

1010
import java.util.ArrayList;
1111
import java.util.Iterator;
@@ -84,20 +84,20 @@ private void onTextUpdate(int oldCursorPos, int oldHighlightPos, String oldText,
8484

8585
private Component renderText(String str, int firstCharacterIndex) {
8686
if (!str.isEmpty()) {
87-
TextEditorOutputFormatter formatter = new TextEditorOutputFormatter((TextComponent) text().append(text("")));
87+
TextEditorOutputFormatter formatter = new TextEditorOutputFormatter(text().append(text("")));
8888
formatter.format(str, firstCharacterIndex, formattings);
8989
return formatter.getText();
9090
}
9191
return EMPTY_TEXT;
9292
}
9393

94-
private TextComponent createText() {
95-
TextEditorOutputFormatter formatter = new TextEditorOutputFormatter((TextComponent) text().append(text("")));
94+
private MutableComponent createText() {
95+
TextEditorOutputFormatter formatter = new TextEditorOutputFormatter(text().append(text("")));
9696
formatter.format(view.getTextField().getText(), 0, formattings);
9797
return formatter.getText();
9898
}
9999

100-
private void initFormattings(TextComponent text) {
100+
private void initFormattings(MutableComponent text) {
101101
TextEditorInputParser parser = new TextEditorInputParser();
102102
parser.parse(text);
103103
formattings.setAll(parser.getFormattings());

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/category/block/BlockContainerCategoryModel.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.github.franckyi.ibeeditor.client.screen.model.entry.TextEntryModel;
66
import com.github.franckyi.ibeeditor.common.ModTexts;
77
import net.minecraft.network.chat.Component;
8-
import net.minecraft.network.chat.TextComponent;
8+
import net.minecraft.network.chat.MutableComponent;
99

1010
public class BlockContainerCategoryModel extends BlockEditorCategoryModel {
1111
public BlockContainerCategoryModel(BlockEditorModel editor) {
@@ -20,12 +20,12 @@ protected void setupEntries() {
2020
);
2121
}
2222

23-
private TextComponent getCustomName() {
23+
private MutableComponent getCustomName() {
2424
String s = getData().getString("CustomName");
25-
return s.isEmpty() ? null : (TextComponent) Component.Serializer.fromJson(s);
25+
return s.isEmpty() ? null : Component.Serializer.fromJson(s);
2626
}
2727

28-
private void setCustomName(TextComponent value) {
28+
private void setCustomName(MutableComponent value) {
2929
if (!value.getString().isEmpty()) {
3030
getData().putString("CustomName", Component.Serializer.toJson(value));
3131
} else if (getData().getString("CustomName").isEmpty()) {

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/category/entity/EntityGeneralCategoryModel.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.github.franckyi.ibeeditor.client.screen.model.entry.TextEntryModel;
88
import com.github.franckyi.ibeeditor.common.ModTexts;
99
import net.minecraft.network.chat.Component;
10-
import net.minecraft.network.chat.TextComponent;
10+
import net.minecraft.network.chat.MutableComponent;
1111

1212
public class EntityGeneralCategoryModel extends EntityCategoryModel {
1313
public EntityGeneralCategoryModel(EntityEditorModel model) {
@@ -28,12 +28,12 @@ protected void setupEntries() {
2828
);
2929
}
3030

31-
private TextComponent getCustomName() {
31+
private MutableComponent getCustomName() {
3232
String s = getData().getString("CustomName");
33-
return s.isEmpty() ? null : (TextComponent) Component.Serializer.fromJson(s);
33+
return s.isEmpty() ? null : Component.Serializer.fromJson(s);
3434
}
3535

36-
private void setCustomName(TextComponent value) {
36+
private void setCustomName(MutableComponent value) {
3737
if (!value.getString().isEmpty()) {
3838
getData().putString("CustomName", Component.Serializer.toJson(value));
3939
} else if (getData().getString("CustomName").isEmpty()) {

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/category/item/ItemDisplayCategoryModel.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import net.minecraft.nbt.Tag;
1212
import net.minecraft.network.chat.Component;
1313
import net.minecraft.network.chat.MutableComponent;
14-
import net.minecraft.network.chat.TextComponent;
14+
import net.minecraft.network.chat.contents.LiteralContents;
1515
import net.minecraft.world.item.ItemStack;
1616

1717
public class ItemDisplayCategoryModel extends ItemEditorCategoryModel {
@@ -27,7 +27,6 @@ protected void setupEntries() {
2727
getDisplay().getList("Lore", Tag.TAG_STRING).stream()
2828
.map(Tag::getAsString)
2929
.map(Component.Serializer::fromJson)
30-
.map(TextComponent.class::cast)
3130
.map(this::createLoreEntry)
3231
.forEach(getEntries()::add);
3332
}
@@ -47,7 +46,7 @@ public EntryModel createNewListEntry() {
4746
return createLoreEntry(null);
4847
}
4948

50-
private EntryModel createLoreEntry(TextComponent value) {
49+
private EntryModel createLoreEntry(MutableComponent value) {
5150
TextEntryModel entry = new TextEntryModel(this, null, value, this::addLore);
5251
entry.listIndexProperty().addListener(index -> entry.setLabel(ModTexts.lore(index + 1)));
5352
return entry;
@@ -67,14 +66,14 @@ public void apply() {
6766
}
6867
}
6968

70-
private TextComponent getItemName() {
69+
private MutableComponent getItemName() {
7170
String s = getDisplay().getString(ItemStack.TAG_DISPLAY_NAME);
72-
return s.isEmpty() ? null : (TextComponent) Component.Serializer.fromJson(s);
71+
return s.isEmpty() ? null : Component.Serializer.fromJson(s);
7372
}
7473

75-
private void setItemName(TextComponent value) {
74+
private void setItemName(MutableComponent value) {
7675
if (!value.getString().isEmpty()) {
77-
if (value.getText().isEmpty() && !value.getSiblings().isEmpty()) {
76+
if (!value.getSiblings().isEmpty() && value.getContents() instanceof LiteralContents lc && lc.text().isEmpty()) {
7877
value.withStyle(style -> style.withItalic(false));
7978
}
8079
getOrCreateDisplay().putString(ItemStack.TAG_DISPLAY_NAME, Component.Serializer.toJson(value));
@@ -83,8 +82,8 @@ private void setItemName(TextComponent value) {
8382
}
8483
}
8584

86-
private void addLore(TextComponent value) {
87-
if (!value.getString().isEmpty() && value.getText().isEmpty() && !value.getSiblings().isEmpty()) {
85+
private void addLore(MutableComponent value) {
86+
if (!value.getString().isEmpty() && value.getContents() instanceof LiteralContents lc && lc.text().isEmpty() && !value.getSiblings().isEmpty()) {
8887
value.withStyle(style -> style.withItalic(false).withColor(ChatFormatting.WHITE));
8988
}
9089
newLore.add(StringTag.valueOf(Component.Serializer.toJson(value)));

common/src/main/java/com/github/franckyi/ibeeditor/client/screen/model/entry/TextEntryModel.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
import com.github.franckyi.ibeeditor.client.screen.model.category.CategoryModel;
44
import net.minecraft.network.chat.MutableComponent;
5-
import net.minecraft.network.chat.TextComponent;
65

76
import java.util.function.Consumer;
87

98
import static com.github.franckyi.guapi.api.GuapiHelper.*;
109

11-
public class TextEntryModel extends ValueEntryModel<TextComponent> {
12-
public TextEntryModel(CategoryModel category, MutableComponent label, TextComponent value, Consumer<TextComponent> action) {
10+
public class TextEntryModel extends ValueEntryModel<MutableComponent> {
11+
public TextEntryModel(CategoryModel category, MutableComponent label, MutableComponent value, Consumer<MutableComponent> action) {
1312
super(category, label, value == null ? text() : value, action);
1413
}
1514

common/src/main/java/com/github/franckyi/ibeeditor/client/util/ScreenScalingManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void setScreenScale(int value) {
100100
}
101101

102102
private int getDefaultScale() {
103-
return mc().options.guiScale;
103+
return mc().options.guiScale().get();
104104
}
105105

106106
public int getMaxScale() {

0 commit comments

Comments
 (0)