Jump to content

Recommended Posts

Posted (edited)

I want to get mc.currentScreen, but when I start mod currentScreen == null. Why?

ExampleMod.java

 

  Reveal hidden contents

KeyHandler.java

  Reveal hidden contents

 

 

 

I recive message: Screen is null :(

Why? How to fix it?

Edited by Hello World
Update code
Posted

I want to get mc.currentScreen, but when I start mod currentScreen == null. Why?

ExampleMod.java

 

  Reveal hidden contents

KeyHandler.java

  Reveal hidden contents

 

 

 

I recive message: Screen is null :(

Why? How to fix it?

Posted
@SubscribeEvent
    public  void pickup(PlayerInteractEvent event)
    {
        GuiScreen screen = Minecraft.getMinecraft().currentScreen;
        if (screen == null){
            mc.thePlayer.addChatComponentMessage(new ChatComponentText("Screen is null :("));

            return;
        }

Do you know how to code? in the keyhandler file it says Screen Is Null  

mc.thePlayer.addChatComponentMessage(new ChatComponentText("Screen is null :("));

Posted
  On 2/24/2019 at 2:54 PM, Avan12IsDead said:

Do you know how to code? in the keyhandler file it says Screen Is Null 

Expand  

That is his debug message. He knows what he is doing. He is asking why Minecraft.getMinecraft().currentScreen is null.

Some tips:

  Reveal hidden contents

 

Posted

1. PlayerInteractEvent can be triggered from the server side, in which case the currentScreen is null, as the server side does not have a currently opened GUI. The currentScreen is only client side.

2. Please elucidate what you are trying to do, and we can perhaps figure out an alternative solution. We need some context of your problem.

Some tips:

  Reveal hidden contents

 

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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