Jump to content

[1.16.5] Trying to add a screen before uploading to the world.


idev

Recommended Posts

Trying to add a screen before uploading to the world. I did not find examples anywhere, I had to write something of my own. I'm not sure if this approach is correct, I'm not very sure. However, this works more or less. The screen appears but disappears immediately.

And I need to wait for the buttons to be pressed before it disappears. How can I implement this?

 

@Mod.EventBusSubscriber(modid = XCraft.MODID, value = Dist.CLIENT)
public class ListenEntityJoinWorldEvent {
    @SubscribeEvent
    public static void joinEntity(EntityJoinWorldEvent event) {
        if (event.getEntity() instanceof ClientPlayerEntity) {
            Minecraft.getInstance().forceSetScreen(new DemoScreen());
            System.out.println("PlayerEntity join in WORLD");
        }
    }
}

I would be glad if you point out mistakes.

Link to comment
Share on other sites

29 minutes ago, diesieben07 said:

No need to use forceSetScreen (it really doesn't force anything, no idea why it is called that), just use setScreen.

Then if you want to prevent anything from closing this screen, you need to use GuiOpenEvent.

I do not understand. I started listening to GuiOpenEvent
But what will make it not close?

Link to comment
Share on other sites

8 minutes ago, diesieben07 said:

Вы читали документацию по GuiOpenEvent?

 

Unfortunately, I have not found a more or less detailed description. Climbing in the GuiOpenEvent itself, I found only a description. That, in general, was clear before.

I quote: This event is called before any Gui will open. If you don't want this to happen, cancel the event. If you want to override this Gui, simply set the gui variable to your own Gui.

That is, I need to redefine the open screen anyway? I found nothing about the other. You said about canceling the closure, and I tried to reproduce it, but I did not find anything I needed. Maybe I misunderstood

Link to comment
Share on other sites

Just now, diesieben07 said:

События кузницы в целом описаны в документации:  https://mcforge.readthedocs.io/en/latest/events/intro/

@Mod.EventBusSubscriber(modid = XCraft.MODID, value = Dist.CLIENT)
public class ListenGuiOpenEvent{
    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public static void guiOpen(GuiOpenEvent event) {
        if (event.getGui() instanceof DemoScreen) {
            System.out.println("Gui Demo open scene");
        }
    }
}

Oh, I'm sorry, but I'm not talking about that a bit. I calmly added the events themselves. You wrote above about canceling the closure, I thought it was something like a method, most likely I was looking in the wrong place

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.