Jump to content

custom GUI mod


Vadim Kurbatov

Empfohlene Beiträge

The mod must be tied to the logic of the Forge API, Minecraft 1.19.
The main task - is to make your own gui for the inventory or just a separate gui, which will implement the basic functions for the marketplace (as in the various plugins). This needs to be implemented specifically by a mod. So far I've tried creating a class that inherits the Screen and setting as new ( minecraft.setScreen(new CustomScreen())), but the main inventory stops working (not moving things from slot to slot). Also tried overriding the InventoryScreen class, but the problem is the same as above. Decided to start simple, namely adding a button to the main inventory. Logic: listening for the ScreenEvent event, and setting the new button as a widget. 

@SubscribeEvent
    public static void openInventoryGui(ScreenEvent e) {
        Minecraft minecraft = Minecraft.getInstance();
        if (minecraft.screen != null) {
            Screen current = e.getScreen();
            if (current.passEvents) {
                Button button = new Button(10, 10, 10, 10, Component.literal("TEST"), (a) -> {
                    System.out.println("Press");
                });
                e.getScreen().renderables.add(button);
            }
        }
    }

But so far the button does not work (should output text to the console). 
Regarding ScreenEvent.InitScreenEvent - I could not do anything with it (it is not in the class, found no such event).

What can I read or what guides to look at this topic? Or maybe someone has advice or experience in this matter?
 

Link zu diesem Kommentar
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...
B
B