#starting with a screen

16 messages · Page 1 of 1 (latest)

vagrant mist
#

import net.minecraft.client.font.MultilineText;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;

public class TutorialScreen extends Screen {
    private final Screen parent;

    protected TutorialScreen(Screen parent) {
        // The parameter is the title of the screen,
        // which will be narrated when you enter the screen.
        super(Text.literal("My tutorial screen"));
        this.parent = parent;
    }

    @Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        super.render(context, mouseX, mouseY, delta);
        context.drawCenteredTextWithShadow(textRenderer, Text.literal("You must see me"), width / 2, height / 2, 0xffffff);
        final MultilineText multilineText = MultilineText.create(textRenderer, Text.literal("The text is pretty long ".repeat(20)), width - 20);
        multilineText.drawWithShadow(context, 10, height / 2, 16, 0xffffff);
    }

    public ButtonWidget button1;
    public ButtonWidget button2;

    @Override
    protected void init() {
        button1 = ButtonWidget.builder(Text.literal("Button 1"), button -> {
                    System.out.println("You clicked button1!");
                })
                .dimensions(width / 2 - 205, 20, 200, 20)
                .tooltip(Tooltip.of(Text.literal("Tooltip of button1")))
                .build();
        button2 = ButtonWidget.builder(Text.literal("Button 2"), button -> {
                    System.out.println("You clicked button2!");
                })
                .dimensions(width / 2 + 5, 20, 200, 20)
                .tooltip(Tooltip.of(Text.literal("Tooltip of button2")))
                .build();

        addDrawableChild(button1);
        addDrawableChild(button2);
    }

    @Override
    public void close() {
        client.setScreen(parent);
    }
}```
im attempting to use the fabric wiki to make a screen. this is my file for actaully making the thing and this is the client file:
```public class CongregateAndConquerClient implements ClientModInitializer {
    private net.minecraft.client.gui.screen.Screen Screen;
    TutorialScreen ts = new TutorialScreen(Screen);
    @Override
    public void onInitializeClient() {
        ts.init();
    }
}```
i can run the game just fine, but nothing happens. how could i make this show up by using a command such as /test? is it possible i am doing something wrong? im sorry i am new to this and just starting out.
#

im trying to follow the wiki but for some reason sendFeedback() is red

#

im getting

#

and

incompatible types: LiteralArgumentBuilder<Object> cannot be converted to LiteralArgumentBuilder<ServerCommandSource>
shrewd mural
vagrant mist
shrewd mural
#

What mc version?

vagrant mist
shrewd mural
#

Here's an example of how mine works. This is 1.20.4, but it should be the same I think.

public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess ignoredCommandRegistryAccess) {
        var autocut = literal("autocut")
                .build();
        var connect = literal("connect")
                .build();
        var connectPassword = argument("password", StringArgumentType.word())
                .executes(AutocutCommandHandler::connectPasswordCommand)
                .build();
        var finish = literal("finish")
                .executes(AutocutCommandHandler::finish)
                .build();
        var finishDatabase = argument("database", StringArgumentType.string())
                .executes(AutocutCommandHandler::finishDatabase)
                .build();
        //@formatter:off
        dispatcher.getRoot().addChild(autocut);
        autocut.addChild(connect);
            connect.addChild(connectPassword);
        autocut.addChild(finish);
            finish.addChild(finishDatabase);
        //@formatter:on
    }
vagrant mist
#

Does 1.20.4 work with 1.20.1 all of the time or should it generally be ok?

shrewd mural
#

Not all of the time, but I don't think commands changed. The wiki is mostly still back in 1.20.1 so that should help too.

vagrant mist
#

Because if 1.20.4 works for the most part, I’d prefer to use the more recent fabric will

#

Wiki*

shrewd mural
#

Try the 1.20.4 tutorials if you like. The major differences between the two are here, so if something goes wrong you can probably work backward.

vagrant mist
vagrant mist