Jump to content

registerEntityRenderingHandler deprecated??


Aideux

Recommended Posts

Hey so I've been learning how to render custom Mobs in Minecraft from a book, but the code they use in the book (registerEntityRenderingHandler) is now deprecated. The book said to put this line in the ClientProxy class, but now I'm not so sure how to fix this problem, and every time I try to launch my mod, Minecraft crashes. Can someone please help me out with this? Thank you so much!!!

 

P.S. I've seen posts about this where people recommend using RenderingRegistry#registerEntityRenderingHandler, but I'm not really sure what this means or why there is a pound symbol in the middle of the statement. Can someone also clear this up for me? Thank you so much!!! I'm posting my code just in case the crash was another problem and I'm just a dummy!!

 

Main entity mod code:

package com.aideux.mobexample;

import com.aideux.basemod.BaseMod;

import net.minecraft.client.model.ModelZombie;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class MobExample 
{
public static int currentEntityId = 0;

public static void preInit()
{
	createEntityWithEgg(EntityGelZombie.class, "CustomMob", 0x00FF00, 0xFF0000);
}

public static void init()
{
	BaseMod.proxy.registerEntityRenderers();
}

public static void createEntityWithEgg(Class entityClass, String entityName, int solidColor, int spotColor)
{
	int entityId = currentEntityId++;
	EntityRegistry.registerModEntity(entityClass, entityName, entityId, BaseMod.instance, 250, 1, true, solidColor, spotColor);
}
}

 

ClientProxy class:

 

package com.aideux.basemod;

import com.aideux.mobexample.EntityGelZombie;
import com.aideux.mobexample.RenderGelZombie;

import net.minecraft.client.model.ModelZombie;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy
{
@Override
public void registerEntityRenderers() 
{
	RenderingRegistry.registerEntityRenderingHandler(EntityGelZombie.class, new RenderGelZombie(new ModelZombie(), 0.5f));
    }
}

Link to comment
Share on other sites

Foo#bar

refers to the instance method/field of the

Foo

class called

bar

.

Foo.bar

refers to a static method/field.

 

If you look at the doc comment of the deprecated

RenderingRegistry#registerEntityRenderingHandler

overload, it tells you to "use the factory version during Preinitialization." This means you need to call the non-deprecated overload of

RenderingRegistry#registerEntityRenderingHandler

with the

IRenderFactory

argument during the preInit phase.

 

Implement

IRenderFactory

with an anonymous class (if you're targeting Java 6/7) or a lambda/method reference (if you're targeting Java 8).

 

In future, post the crash report when asking for help with a crash.

 

Edit: Smileys are annoying.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Foo#bar

refers to the instance method/field of the

Foo

class called

bar

.

Foo.bar

refers to a static method/field.

 

If you look at the doc comment of the deprecated

RenderingRegistry#registerEntityRenderingHandler

overload, it tells you to "use the factory version during Preinitialization." This means you need to call the non-deprecated overload of

RenderingRegistry#registerEntityRenderingHandler

with the

IRenderFactory

argument during the preInit phase.

 

Implement

IRenderFactory

with an anonymous class (if you're targeting Java 6/7) or a lambda/method reference (if you're targeting Java 8).

 

In future, post the crash report when asking for help with a crash.

 

I'm sorry, I'm still super new at this. Do you think you might be able to give me an example of what I should be typing? I'm a very new programmer.

Link to comment
Share on other sites

What part exactly do you not understand?

 

I don't understand which version of registerEntityRenderingHandler is the factory version, and I've tried both of the available options in both the ClientProxy and preInit methods. Also, I've never heard of IRenderFactory, so I'm not really sure how to implement it into my code. Maybe could you show me how it's used in code so I can better understand it? I'm very much a visual learner! Thank you!

Link to comment
Share on other sites

I don't understand which version of registerEntityRenderingHandler is the factory version
The one that has an
IRenderFactory

parameter, of course.

Also, I've never heard of IRenderFactory, so I'm not really sure how to implement it into my code.
It's an interface. You implement it and it will create your renderer when queried. If you do not understand what an interface is or how to implement it then you need to learn Java first.
Maybe could you show me how it's used in code so I can better understand it?

Search the MinecraftForge github repo.

Could you please just give me an example? Like I said, I really need visuals to be able to learn and pull apart code for myself. I've done some research, but none of it has been helpful, and I really need this to work.

 

I've tried

RenderingRegistry.registerEntityRenderingHandler(EntityGelZombie.class, RenderGelZombie::new);

but not only is registerEntityRenderingHandler still not working, RenderGelZombie::new is telling me that the "target type of this expression must be a functional interface". Now, I've also read through some code on github, but none of it seems applicable to what I'm doing, mainly because I can't get RenderGelZombie to act as a functional interface, and I still have no idea if I need to create a separate class IRenderFactory or if I need to initialize my EntityRender class in a different way. I am not much of a Java programmer and I prefer C# when it comes to OOP, but I am in the dark right now and I would really appreciate some concrete examples, rather than just advising me to look online. I mean, there can't be a billion different ways to do this. Thank you again, I really appreciate it.

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.



×
×
  • Create New...

Important Information

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