I need help with adding a button to the main menu #1795
-
I'm trying to put a button on the title screen but i get an error message back claiming that the string can't be converted to text (the text I'm trying to display inside the button): C:\Users\Jones\Desktop\mystery-mod-1.17.1\src\main\java\net\mystery\mod\mixin\TitleScreenMixin.java:23: error: incompatible types: String cannot be converted to Text this.addButton(new ButtonWidget(this.width / 2 - 100 + 205, y, 50, 20, "bruh", (buttonWidget) -> { package net.mystery.mod.mixin;
I used this tutorial and I my code looks exactly the same (apart from the value of the string) but it doesn't work for me. Please help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You need to use a Minecraft
(there are other types of Also, you can use Fabric API (fabric-screen-api-v1 to be specific) to add buttons to screens without mixins. See the |
Beta Was this translation helpful? Give feedback.
-
Do this: import net.minecraft.client.gui.screen.Screen; @mixin(TitleScreen.class)
} then add a folder named assets to the resources in that assets folder make a folder with the name of your mod then in that folder make a lang folder and at last make a file called en_us.json.(The path"C:\Your Path\modname\src\main\resources\assets\modname\lang\en_us.json" this is ow it should look : { |
Beta Was this translation helpful? Give feedback.
Do this:
`package pack1.pack2.pack3;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.world.SelectWorldScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@mixin(TitleScreen.class)
public class FilesName extends Screen {