Update new Text() to Text.of or Text.translatable
This commit is contained in:
parent
da3dd53e91
commit
a458f0546d
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.0'
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import me.neophyte.mods.savecoords.gui.impl.DIContainer;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SaveCoordinatesClient implements ClientModInitializer {
|
||||
|
||||
@ -35,7 +35,7 @@ public class SaveCoordinatesClient implements ClientModInitializer {
|
||||
translationKey = TranslationKeys.TOOLTIP_PING_ENABLED;
|
||||
}
|
||||
|
||||
MinecraftClient.getInstance().player.sendMessage(new TranslatableText(translationKey), true);
|
||||
MinecraftClient.getInstance().player.sendMessage(Text.translatable(translationKey), true);
|
||||
}
|
||||
|
||||
while(pingKeyBinding.wasPressed()) {
|
||||
|
||||
@ -15,9 +15,7 @@ import me.neophyte.mods.savecoords.IKeyBinds.IKeyBinding;
|
||||
import me.neophyte.mods.savecoords.gui.IRootPanel;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.InputUtil.Type;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
// TODO:
|
||||
// Clean the mess below on order of event handling
|
||||
@ -33,9 +31,9 @@ class ConfigViewHandler extends ViewHandlerBase<List<IKeyBinding>> {
|
||||
private ConfigListPanel listPanel;
|
||||
|
||||
public ConfigViewHandler() {
|
||||
this.saveButton = new WButton(new TranslatableText(TranslationKeys.MENU_SAVE));
|
||||
this.backButton = new WButton(new TranslatableText(TranslationKeys.MENU_BACK));
|
||||
this.resetButton = new WButton(new TranslatableText(TranslationKeys.MENU_RESET));
|
||||
this.saveButton = new WButton(Text.translatable(TranslationKeys.MENU_SAVE));
|
||||
this.backButton = new WButton(Text.translatable(TranslationKeys.MENU_BACK));
|
||||
this.resetButton = new WButton(Text.translatable(TranslationKeys.MENU_RESET));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -217,9 +215,9 @@ class ConfigViewHandler extends ViewHandlerBase<List<IKeyBinding>> {
|
||||
private int code;
|
||||
|
||||
ConfigItemPanel() {
|
||||
this.configLabel = new WLabel("");
|
||||
this.configLabel = new WLabel(Text.of(""));
|
||||
this.configButton = new WButton();
|
||||
this.resetButton = new WButton(new TranslatableText(TranslationKeys.MENU_RESET));
|
||||
this.resetButton = new WButton(Text.translatable(TranslationKeys.MENU_RESET));
|
||||
}
|
||||
|
||||
void setInitialConfig(IKeyBinding config) {
|
||||
@ -277,7 +275,7 @@ class ConfigViewHandler extends ViewHandlerBase<List<IKeyBinding>> {
|
||||
|
||||
private void updateWidgetData(Type type, int code) {
|
||||
if(focussing) {
|
||||
this.configButton.setLabel(new LiteralText("_"));
|
||||
this.configButton.setLabel(Text.of("_"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import me.neophyte.mods.savecoords.IFileStore;
|
||||
import me.neophyte.mods.savecoords.TranslationKeys;
|
||||
import me.neophyte.mods.savecoords.model.PlayerRawPosition;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class CurrentPositionPingOperation extends PingPositionOperation{
|
||||
|
||||
@ -28,7 +28,7 @@ public class CurrentPositionPingOperation extends PingPositionOperation{
|
||||
if (enabled) {
|
||||
super.executeOperation(fileStore, position);
|
||||
} else {
|
||||
MinecraftClient.getInstance().player.sendMessage(new TranslatableText(TranslationKeys.TOOLTIP_PING_LOCK),
|
||||
MinecraftClient.getInstance().player.sendMessage(Text.translatable(TranslationKeys.TOOLTIP_PING_LOCK),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,8 +16,7 @@ import me.neophyte.mods.savecoords.model.PlayerPosition;
|
||||
import me.neophyte.mods.savecoords.model.PlayerRawPosition;
|
||||
import me.neophyte.mods.savecoords.model.PositionMetadata;
|
||||
import me.neophyte.mods.savecoords.util.ResourceUtils;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
|
||||
@ -173,7 +172,7 @@ class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
}
|
||||
|
||||
private WWidget CreateLabelForCoordinate(String label) {
|
||||
WButton labelButton = new WButton(new LiteralText(label));
|
||||
WButton labelButton = new WButton(Text.of(label));
|
||||
labelButton.setEnabled(false);
|
||||
return labelButton;
|
||||
}
|
||||
@ -187,7 +186,7 @@ class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
}
|
||||
|
||||
private WTextField CreateLocationField(PlayerPosition existingPosition) {
|
||||
WTextField location = new WTextField(new TranslatableText(TranslationKeys.MENU_LOCATION));
|
||||
WTextField location = new WTextField(Text.translatable(TranslationKeys.MENU_LOCATION));
|
||||
|
||||
if (existingPosition != null) {
|
||||
location.setText(existingPosition.getLocationName());
|
||||
@ -199,7 +198,7 @@ class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
}
|
||||
|
||||
private WTextField CreateNotesField(PlayerPosition existingPosition) {
|
||||
WTextField notes = new WTextField(new TranslatableText(TranslationKeys.MENU_NOTES));
|
||||
WTextField notes = new WTextField(Text.translatable(TranslationKeys.MENU_NOTES));
|
||||
|
||||
if (existingPosition != null && existingPosition.getPositionMetadata() != null) {
|
||||
notes.setText(existingPosition.getPositionMetadata().getNotes());
|
||||
@ -209,7 +208,7 @@ class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
}
|
||||
|
||||
private WTextField CreateWorldField(String defaultWorld) {
|
||||
WTextField world = new WTextField(new TranslatableText(TranslationKeys.MENU_WORLD_NAME));
|
||||
WTextField world = new WTextField(Text.translatable(TranslationKeys.MENU_WORLD_NAME));
|
||||
world.setMaxLength(7);
|
||||
world.setText(defaultWorld);
|
||||
return world;
|
||||
@ -222,6 +221,6 @@ class DefaultViewHandler extends ViewHandlerBase<PlayerPosition> {
|
||||
}
|
||||
|
||||
private WButton CreateButton(String translationKey) {
|
||||
return new WButton(new TranslatableText(translationKey));
|
||||
return new WButton(Text.translatable(translationKey));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import me.neophyte.mods.savecoords.IDimensionAware;
|
||||
import me.neophyte.mods.savecoords.IDimensionAware.IDimension;
|
||||
import me.neophyte.mods.savecoords.model.PlayerRawPosition;
|
||||
import me.neophyte.mods.savecoords.util.PartialCircularList;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class DimensionButton extends WButton {
|
||||
|
||||
@ -27,13 +27,13 @@ public class DimensionButton extends WButton {
|
||||
IDimension currentDimension = allDimensions.current();
|
||||
|
||||
sprite.setImage(currentDimension.getSpriteIdentifier());
|
||||
setLabel(new LiteralText(currentDimension.getName()));
|
||||
setLabel(Text.of(currentDimension.getName()));
|
||||
|
||||
setOnClick(() -> {
|
||||
allDimensions.next();
|
||||
IDimension current = getDimension();
|
||||
sprite.setImage(current.getSpriteIdentifier());
|
||||
setLabel(new LiteralText(current.getName()));
|
||||
setLabel(Text.of(current.getName()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,7 @@ import me.neophyte.mods.savecoords.gui.IRootPanel;
|
||||
import me.neophyte.mods.savecoords.model.PlayerPosition;
|
||||
import me.neophyte.mods.savecoords.model.PlayerRawPosition;
|
||||
import me.neophyte.mods.savecoords.util.ResourceUtils;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
|
||||
@ -58,7 +57,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
}
|
||||
|
||||
private WButton createBackButton() {
|
||||
return new WButton(new TranslatableText(TranslationKeys.MENU_BACK));
|
||||
return new WButton(Text.translatable(TranslationKeys.MENU_BACK));
|
||||
}
|
||||
|
||||
private WListPanel<PlayerPosition, CoordinatesListItemPanel> createListPanel(List<PlayerPosition> positions) {
|
||||
@ -122,14 +121,14 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.netherCalculator = netherCalculator;
|
||||
this.coordinateConvertState = true;
|
||||
|
||||
this.coordinates = new WLabel("");
|
||||
this.location = new WLabel("");
|
||||
this.world = new WLabel("");
|
||||
this.coordinates = new WLabel(Text.of(""));
|
||||
this.location = new WLabel(Text.of(""));
|
||||
this.world = new WLabel(Text.of(""));
|
||||
this.icon = new WSprite(ResourceUtils.getIdentifier("close"));
|
||||
this.deleteButton = createDeleteButton();
|
||||
this.detailButton = new WButton(new LiteralText(""));
|
||||
this.pingButton = new WButton(new LiteralText(""));
|
||||
this.convertButton = new WButton(new LiteralText(""));
|
||||
this.detailButton = new WButton(Text.of(""));
|
||||
this.pingButton = new WButton(Text.of(""));
|
||||
this.convertButton = new WButton(Text.of(""));
|
||||
|
||||
this.pingButton.setIcon(ResourceUtils.createPingIcon());
|
||||
this.detailButton.setIcon(ResourceUtils.createDetailsIcon());
|
||||
@ -157,17 +156,17 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
}
|
||||
|
||||
private WButton createDeleteButton() {
|
||||
TexturedButton button = new TexturedButton(new LiteralText("x"));
|
||||
TexturedButton button = new TexturedButton(Text.of("x"));
|
||||
button.setTexture(ResourceUtils.getIdentifier("close"));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
void setPosition(PlayerPosition position) {
|
||||
this.location.setText(new LiteralText(position.getLocationName()));
|
||||
this.location.setText(Text.of(position.getLocationName()));
|
||||
this.location.setColor(0x3939ac);
|
||||
if (position.getPositionMetadata() != null) {
|
||||
this.world.setText(new LiteralText("[" + position.getPositionMetadata().getWorldName() + "]"));
|
||||
this.world.setText(Text.of("[" + position.getPositionMetadata().getWorldName() + "]"));
|
||||
this.world.setColor(0xb80000);
|
||||
}
|
||||
|
||||
@ -183,7 +182,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
|
||||
this.icon.setImage(ResourceUtils.getIdentifier(position.getWorldDimension()));
|
||||
this.coordinates
|
||||
.setText(new LiteralText(position.getX() + ", " + position.getY() + ", " + position.getZ()));
|
||||
.setText(Text.of(position.getX() + ", " + position.getY() + ", " + position.getZ()));
|
||||
this.convertButton.setOnClick(() -> setRawPosition(netherCalculator.convert(position)));
|
||||
this.pingButton.setOnClick(() -> onPing.accept(position));
|
||||
this.coordinateConvertState = !coordinateConvertState;
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.function.Supplier;
|
||||
import me.neophyte.mods.savecoords.IFileStore;
|
||||
import me.neophyte.mods.savecoords.model.PlayerRawPosition;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
class PingPositionOperation extends ViewOperationBase<PlayerRawPosition> {
|
||||
|
||||
@ -15,6 +16,6 @@ class PingPositionOperation extends ViewOperationBase<PlayerRawPosition> {
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
protected void executeOperation(IFileStore fileStore, PlayerRawPosition position) throws Exception {
|
||||
MinecraftClient.getInstance().player.sendChatMessage(position.toString());
|
||||
MinecraftClient.getInstance().player.sendChatMessage(position.toString(), Text.of(position.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.client.util.InputUtil.Type;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
class KeyBinds implements IKeyBinds {
|
||||
|
||||
@ -120,7 +119,7 @@ class KeyBinds implements IKeyBinds {
|
||||
|
||||
@Override
|
||||
public Text getNameLocalizedText() {
|
||||
return new TranslatableText(getTranslationKey());
|
||||
return Text.translatable(getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
},
|
||||
"mixins": [],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.3",
|
||||
"fabricloader": ">=0.14.9",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.18.x",
|
||||
"minecraft": "1.19.x",
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user