Jump to content

[1.15.2]Can't call method .getMainWindow()


me1

Recommended Posts

I followed a tutorial and there was the following code:

return InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), glfw);

But for me the 'getMainWindow()' was underlined red.

I looked through the IntelliJ-Hints and the only function whitch returns a 'MainWindow' is 'func_228018_at_()'.

When I run it with MainWindow it starts minecraft but closes it again after some time saying:

[16:19:41] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:109]: ---- Minecraft Crash Report ----
// Hi. I'm Minecraft, and I'm a crashaholic.

Time: 03.04.20 16:19
Description: Initializing game

java.lang.NoSuchMethodError: net.minecraft.client.Minecraft.getMainWindow()Lnet/minecraft/client/MainWindow;
	at com.nkdm.emptyblock.EmptyBlock.getKey(EmptyBlock.java:68) ~[main/:?] {re:classloading}
	at     *...*
    
    
    Process finished with exit code -1

 

When I run it with func_228018_at_ it instantly says:

C:\Users\*ME1*\IdeaProjects\emptyblock\src\main\java\com\nkdm\emptyblock\EmptyBlock.java:68: error: cannot find symbol
        return InputMappings.isKeyDown(Minecraft.getInstance().func_228018_at_().getHandle(), glfw);
                                                              ^
  symbol:   method func_228018_at_()
  location: class Minecraft

 

I use IntelliJ and have the newest mappings.

Please help!

Edited by me1
Link to comment
Share on other sites

16 minutes ago, me1 said:

NoSuchMethodError

That method probably got renamed. You can't call it because it doesn't exist because you have the wrong name.

Use your IDE to search for methods and find one that looks like it does what you want.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

57 minutes ago, me1 said:

@Draco18s That's what I did and that's how I found 'func_228018_at_()'. It's the only one witch returns a 'MainWindow'.

Please don't @ me.
And I don't see what the problem is. If your mappings are up to date, then no one's renamed the method yet. There's no "solution"

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

  • 1 month later...

I had the same problem, and here how I solved it:


import org.lwjgl.glfw.GLFW;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.InputMappings;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class KeyboardHelper 
{	
	private static final long WINDOW = Minecraft.getInstance().func_228018_at_().getHandle();

	@OnlyIn(Dist.CLIENT)
	public static boolean isHoldingShift()
	{
		return InputMappings.isKeyDown(WINDOW, GLFW.GLFW_KEY_LEFT_SHIFT);
	}

 

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.