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.
#starting with a screen
16 messages · Page 1 of 1 (latest)
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>
The wiki might be slightly outdated, though your parentheses look like they might not line up. This error is probably due to that, unless you're trying to use a servercommandsource for a client command.
So what exactly should I do? I want to make sure it’s not going to cause any issues
What mc version?
1.20.1
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
}
Does 1.20.4 work with 1.20.1 all of the time or should it generally be ok?
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.
Because if 1.20.4 works for the most part, I’d prefer to use the more recent fabric will
Wiki*
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.
ok so i looked into it but im still quite confused as to how i do this
if i wanted to use this, would i just slap it into the main file and call it a day, or have the register thing run in onInitialize