Answer the question
In order to leave comments, you need to log in
Why is currentScreen always null?
There was a need to write a mod that would automate some things.
I'm using version 1.7.10
I want to get currenScreen but it's null.
Why?
public class KeyHandler {
@SubscribeEvent
public void onPlayerInteractEvent(PlayerInteractEvent event)
{
final GuiContainer screen = (GuiContainer) Minecraft.getMinecraft().currentScreen;
if (screen == null){
mc.thePlayer.addChatComponentMessage(new ChatComponentText("Screen is null :("));
return;
}
}
}
}
@Mod(modid = Main.MODID, version = Main.VERSION)
public class Main
{
public static final String MODID = "Mod";
public static final String VERSION = "1.0";
@EventHandler
public void init(FMLInitializationEvent event)
{
FMLCommonHandler.instance().bus().register(new KeyHandler());
MinecraftForge.EVENT_BUS.register(new KeyHandler());
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question