idev Posted March 27, 2021 Posted March 27, 2021 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. Quote
idev Posted March 27, 2021 Author Posted March 27, 2021 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? Quote
idev Posted March 27, 2021 Author Posted March 27, 2021 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 Quote
idev Posted March 27, 2021 Author Posted March 27, 2021 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 Quote
Recommended Posts
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.