Jump to content

Correct way to call/use methods/functions from Minecraft source classes?


Sirpwnsamin

Recommended Posts

Hello, Sirpwnsamin here, with another noob question :P

 

I have a clue on what all these functions do and what I can use them for in my mod, but whenever I try to use them, I get the same error. For example, when I try this;

 

if (EntityPlayer.isSneaking()){

        //do stuff

        }

 

I get the error "Cannot make a static reference to the non-static method isSneaking() from type EntityPlayer"

 

The only quick fix available is to make the method static, which edits a source file and also causes errors in the source file.

 

If anyone could explain to me the correct way to call functions or methods from other source class files, or give me any help at all on this topic, I will be very great full.

Link to comment
Share on other sites

Step 1:

EntityPlayer player != EntityPlayer

 

Step 2:

Read the javadoc

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

Most of the classes that you are referring to have non-static methods and variables. This mean that you have to have an instance of that class to call those methods on. For example, each player(since they are an instance of the class EntityPlayer) has its own isSneaking() method. Therefore, you have to have an instance of the class you are calling already created in order to use those methods.

 

Also, don't modify base classes. From what I've read on the Mojang page, you cannot modify the code that has already been written: it's illegal to redistribute modified base classes. Instead, make other classes that extends from the base classes and use @Override to modify the methods. Then find a way to implement your classes into the game.

 

To check if you accidentally modified a base class, re-obfuscate your mod(package it) then check the zip file that is created. If you see any classes that you did not write(usually a combination of three lowercase letters) that mean you modified a base class in some way.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm Murray Brenda by name, a single mom of three kid's, got scammed on forex trade, never taught of getting tricked in such a way, was convinced by a social media friend to invest on the forex platform of which i heed to, after 1 week of thinking about the proposal, i invested $5Gs, then the trade increased and i was asked to deposit so i stay on the trade and avoid running loss and i did, it was so hurtful when i realize that i have been scammed, i reached out to the directors and support service, non where responding, i was always asked for more payment after one payment has been made, after having my funds back with the help of AlienWizbot i was so happy and rejoiceful simply because it was at the edge of giving up, i gave the last trial simply because coming from a reliable source i taught of giving it  try, only then did i came to find out the truth about impostors testimony online which has ended many people losing more money to scam, you can reach out to Alienwizbot by sms (+1 6262645164) or E-mail alienwizbot(@)Gmail(.)com, best service ever experienced, do hire him for all kinds of cyber issues or hacks.  
    • so basically ive been trying to make a modded server for 1.7.10 and i follow the tutorial perfectly but every tutorial has something called a bat file in there folder when they install forge client into a folder but it doesn't show for me i only get these options in the folder config, libraries, logs, mods, eula, forge 1.7.10, minecraft server 1.7.10 and server proprieties so im not sure what to do and google hasn't really been helping
    • { "type": "magic_overhaul:rune_inscribing", "base": { "item": "//base item" }, "template": { "item": "//template item" }, "output": { "count": 1, "item": "//output item" } } ^ Ok, where is your recipe JSON placed in your file structure? What's it called? And paste the actual JSON you're testing with, because it needs to be valid.
    • I'm trying to run Forge 1.12.2 on Minecraft  so I can use certain mods, but this error popped up. I've seen multiple errors but I just can't figure this one out. Unable to locate the Java runtime. Error details: 0x00000000 - system: The operation completed successfully. Filename on disk:  Path: . Exists: Directory
    • https://mclo.gs/b422RFc
  • Topics

×
×
  • Create New...

Important Information

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