Jump to content

Recommended Posts

Posted

Hello everyone.

 

I'm pretty new to modding with Forge and forums and I apologize if this is in the wrong place or anything.

 

I'm pulling my hair out trying to figure out how to properly register and render a new entity in 1.8.9.

 

I have no idea what the IRenderFactory is or how to use it and I'm not even really sure rendering is my only problem.

I have the entity class and the model class for the mob and a render class but I'm hitting a wall trying to find examples of how to do it properly with the new update. Everyone is just saying "use the registerEntityRenderingHandler" thing but I really have no idea specifically how to do this. This is my first mod.

 

Could someone out there help me out? Thank you!!

 

I have seen this topic:  [1.8]Error Spawning in Entities, and this one,  [1.8.9] Entity rendering registering recently changed?, but I need more information about how to actually do what they talk about.

 

Also I'm not sure how to link a post. >> Sorry....

 

Please be gentle...

Posted

If you're targeting Java 6/7, just create an anonymous class that implements

IRenderFactory

and overrides

createRenderFor

to return a new instance of the your

Render

class.

 

If you're targeting Java 8, you can use a method reference to pass your

Render

class's constructor (

RenderMyEntity::new

) as an

IRenderFactory

instead.

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.

Posted
  On 1/29/2016 at 7:15 AM, DragonessAtHeart said:

Could you maybe give an example of how to use it?

 

Well I am pretty lazy with my registry so I literally dump all my classes through a Proxy method:

@Override
public void sidedEntityRegistry(Class<? extends Entity> c){
	try {
		final Class cc = (Class<? extends Render>) c.getClassLoader().loadClass("rankshank/pikmine/client/render/entity/" + c.getName().substring(c.getName().lastIndexOf("Entity")).replace("Entity", "Render"));
		RenderingRegistry.registerEntityRenderingHandler(c, new IRenderFactory<Entity>(){
                            @Override 
                            public Render createRenderFor(RenderManager rm) {
                                try {
                                    return (Render) cc.getConstructor(RenderManager.class).newInstance(rm);
                                } catch(Exception e){
                                      e.printStackTrace();
                                return null;}}});
	    } catch (Exception e) {
		e.printStackTrace();
	    }
}

Works a treat though since I follow a set naming standard. You can just do direct class references if iteration is too 'scary'

  Quote
I think its my java of the variables.

Posted

I am trying to target Java 8, but thank you for mentioning both.

 

"you can use a method reference to pass your Render class's constructor (RenderMyEntity::new) as an IRenderFactory instead."

 

The render class here we are talking about is the new mob's render class?

 

I feel like I want to do something like this,

registerEntityRenderingHandler(EntityNewMob.class, IRenderFactory (RenderNewMob::new));

but that isn't how you do it.

 

Also oh my goodness RANKSHANK there is so much going on there!

 

I'll have to study that code to see if I can't figure out what is going on.

 

Can you tell me where I need to start researching to figure it out or try to explain it a bit more?

 

If you don't feel like it, that's cool. I can probably figure it out eventually. :)

Posted
  On 1/29/2016 at 7:40 AM, DragonessAtHeart said:

Can you tell me where I need to start researching to figure it out or try to explain it a bit more?

 

It's actually not too bad, the error handling just gunks it up a bit

 

Basically I'm working off the principle that all of my renderers are in rankshank/pikmine/client/render/entity/ and follow the naming format Render{EntityName}.class, their corresponding entity classes just need to follow the naming format Entity{EntityName}.class.

 

Using the known package and transforming the Entity prefix to the Render prefix, I then have a string handle for my Render class.

 

Then using that string handle I query the ClassLoader for the class object which I then create and instance of it using the Render(RenderManager) constructor, which is a consistent constructor throughout my render classes.

 

I then use that as the return value of my RenderFactory which registers the renderer.

 

It all runs off the expectation that I'll continue to follow the same format. I may have to switch to using hard coded strings so that I can subpackage my render folder.

  Quote
I think its my java of the variables.

Posted
  On 1/29/2016 at 7:40 AM, DragonessAtHeart said:

I am trying to target Java 8, but thank you for mentioning both.

 

"you can use a method reference to pass your Render class's constructor (RenderMyEntity::new) as an IRenderFactory instead."

 

The render class here we are talking about is the new mob's render class?

 

I feel like I want to do something like this,

registerEntityRenderingHandler(EntityNewMob.class, IRenderFactory (RenderNewMob::new));

but that isn't how you do it.

 

The parentheses weren't part of the code. Just pass the method reference itself as the

IRenderFactory

argument, you don't need to explicitly cast to or specify that it's an

IRenderFactory

.

 

registerEntityRenderingHandler(EntityNewMob.class, RenderNewMob::new);

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.

Posted

I'm sorry. I didn't mention that I had tried that already unsuccessfully.

 

I am now doing this:

registerEntityRenderingHandler(EntityGiantLizard.class, RenderGiantLizard::new);

 

Which tells me that the registerEntityRenderingHandler method is not defined for my client proxy.

 

I've imported

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraftforge.fml.common.Mod.Instance;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.EntityRegistry;

import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;

import net.minecraftforge.fml.common.registry.LanguageRegistry;

import net.minecraftforge.fml.relauncher.Side;

 

import net.minecraftforge.fml.client.registry.IRenderFactory;

import net.minecraftforge.fml.client.registry.ClientRegistry;

import com.dragonessatheart.firstmod.*;

 

So unless I'm forgetting something, I'm not sure what to do.

 

When I try this:

RenderingRegistry.registerEntityRenderingHandler(EntityGiantLizard.class, RenderGiantLizard::new);

 

It says:

The method registerEntityRenderingHandler(Class<? extends Entity>, Render<? extends Entity>) in the type RenderingRegistry is not applicable for the arguments (Class<EntityGiantLizard>, RenderGiantLizard::new)

 

Which I honestly don't know how to decipher.

 

Thank you!

Posted

The version of forge is: forge-1.8.9-11.15.1.1722, at least that's what it says on the changelog txt name.

 

I know it's at least 1.8.9. The recommended one.

 

RenderGiantLizard is here.

 

  Reveal hidden contents

 

 

 

Thank you so much!

Posted

For a method reference to be used as an interface, the method must have the same signature as the interface's method.

 

IRenderFactory#createRenderFor

takes a single

RenderManager

argument and returns a

Render

, your method must do the same. Constructors implicitly return an instance of their class, so you just need to match the arguments.

 

You don't need to create your own

renderManager

field,

Render#renderManager

already exists with protected access.

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.

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

    • Ignore shrimple, it doesn't work with Oculus. Also, enableShaders was alr true when it said that towards the end of the log. If you could also figure out why my tags are messed up that'd be cool too, but that's a later issue. https://drive.google.com/drive/folders/1ovEKDZECUCl7zZxGfpyQcS4s5PZPQyfa?usp=drive_link
    • accidental duplicate mesage cuz lag
    • https://gnomebot.dev/paste/231527759279685634/1372324909073563730/1372324908629102716 https://gnomebot.dev/paste/231527759279685634/1372320454861262908/1372320454299090996 seems like theres a registry sync error, not sure what that means though, however in an old pack i played on, i actually had a registry sync error happen whenever the world tried too save and it would suddenly stop loading chunks, is there a mod fix for this or some way too bypass registry syncing? is this a server problem? i have no issues with the pack on pc, only on my server.
    • i think the problem is the player animator library but i need it for one of my main mods is there any way i can fix this? The game crashed: rendering overlay Error: java.lang.IllegalArgumentException: Failed to create player model for default heres the crash report: https://pastebin.com/U5Wp8ysb
    • I have been an enthusiastic investor in crypt0currencies for several years, and my digital assets have been integral to my financial strategy. A few months ago, I encountered a distressing predicament when I lost access to my primary cryptocurrency walleet after clicking on an airdrop link that inadvertently connected to my walleet. The dread of potentially losing all my hard-earned funds was overwhelming, leaving me uncertain about where to seek assistance. In my pursuit of solutions, I stumbled upon ChainDigger Retrievers. From our initial consultation to the triumphant recovery of my assets, the team exhibited exceptional expertise. They provided comprehensive explanations of the recovery process, ensuring I was informed at every stage and offering reassurance during this tumultuous time. Their approach was not only meticulous but also compassionate, which significantly alleviated my anxiety. ChainDigger Retrievers unwavering commitment to resolving my issue was evident throughout the process. Leveraging their profound understanding of crypt0currency technology and digital forensics, they initiated an exhaustive investigation to trace the transactions linked to my compromised wallet. Their meticulous analysis and relentless determination were apparent as they left no stone unturned in their quest to recover my funds. After several days of diligent investigation, the team successfully recovered everything I had lost. They uncovered that the link I had clicked contained malware, which scammeers had used to infiltrate my walleet. This revelation was both alarming and enlightening, underscoring the inherent risks associated with crypt0currency transactions when proper precautions are not taken.Thanks to ChainDigger Retrievers, I not only regained everything but also acquired invaluable knowledge about safeguarding my investments. Their expertise and steadfast support transformed a daunting situation into a manageable one, and I am profoundly grateful for their assistance. I can now continue my investment journey with renewed confidence, knowing that I have a trustworthy ally in ChainDigger Retrievers. Their client satisfaction is truly commendable, and I wholeheartedly recommend their services to anyone facing similar challenges in the crypt0currency realm. With their help, I was able to turn a distressing time into a positive outcome, and I will forever be grateful for their support.  
  • Topics

×
×
  • Create New...

Important Information

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