Posted February 3, 201312 yr I added an item that I want to be a carrot named jerry. The only problem I am having is with the registerRenderers() Method. for some reason eclipse doesn't like when I try to override it. I've tried not overriding it, taking it out of CommonProxy, and many other fixes, so I'm not quite sure what to do. I want to make sure I have done all the basic stuff first before I add any of the awesome features I have planned, so I can't really do anything until this problem gets fixed. Thanks for anyone who helps! Here's the code- http://pastebin.com/NG4Mdrn3
February 3, 201312 yr I bet that the error you are getting is the following: The method registerRenderers() of type ClientProxy must override or implement a supertype method If that is the case then the solution is simple, either make the registerRenders() call super(); on it's first line to make it call CommonProxy's registerRenders() as is required when you @Override static methods. Or since you DON'T want to call the common proxy's regsiter renders at all, just make the registerRenders method non-static by removing the static keyword from it. @Override public void registerRenders() { } If you guys dont get it.. then well ya.. try harder...
February 4, 201312 yr Author Thanks for the suggestions! but when I tried to call super(), it said "Constructor call must be the first statement in a constructor", even though I put it in the first line. public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { super(); MinecraftForgeClient.preloadTexture(jerry); } I tried calling it in both Client and Common proxy just to check if it worked. And when I tried to make it non-static, it told me that I couldn't call it here @Init public void load(FMLInitializationEvent event) { ClientProxy.registerRenderers(); //it said this cannot call a non-static method LanguageRegistry.addName(jerry, "Jerry the Carrot"); } Thanks for the help!
February 4, 201312 yr Your code is not self-consistent, therefore you get problems. Compare th two lines: public void registerRenderers() and public static void registerRenderers() the signatures of both methods are different, therefore they are considered different methods by java, even though they are called the same. Either make them both static or non-static. It seems also to me, that you dont understand the difference between static and non-static methods. Static methods are called without implicit this-parameter(means you dont need to have an object of their class to call them), and so they can only access static fields and methods of the same class. I also doubt that using @Override with static methods makes any sense at all.
February 4, 201312 yr You also have to read about java language and OOP more before trying to make something useful with them. The keyword super by itself can only be used inside of a constructor(Constructor is the method that is implicitly called by Java when you are creating new objects of the class by using the new keyword. It has the same name as the class itself. Some languages also have destructors, methods that are called right before the object instance is destroyed). To call superclass counterparts of an overriden method, write super.TheNameOfTheMethod(parameters).
February 4, 201312 yr either remove the static keyword from the method, or make both of them static and call super on the first line. As i said, you don't have any reason to call the CommonProxy's method, so why make it static and call super at all? If you guys dont get it.. then well ya.. try harder...
February 5, 201312 yr Author Thanks for the help everyone. It turns out that the reason my mod wouldn't run was because the path names were different because I changed the name of the mod. All the problems I had were because It was not calling the right places. I got confused and put in stuff that shouldn't have been there. that'll teach me to be more attentive to specificity. Hope you all have a good day! (the stuff about static vs instance was due to the fact that I took those code snippets from two different versions ie I edited the code) and I'm not even going to worry about the super thing.
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.