Jump to content

I'm Stuck, can't do anything until I deal with this


temporalus

Recommended Posts

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

 

Link to comment
Share on other sites

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? :P

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

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.

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 am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

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