Jump to content

[UNSOLVED] [1.8] doRender() not being called?


Gwafu

Recommended Posts

I've searched the forums and this is the most related one but is left unsolved.

 

I am trying to create an item based on leash. When the item is activated/right-clicked on a block (fence), it is supposed to create an entity in the block's place. The entity spawns fine but is invisible. Placing debug messages here and there showed that the doRender() method from the entity's render class is not being called.

 

Here's the relevant codes + some brief (very) explanations: http://pastebin.com/SiWKMPSp

 

Any help is appreciated!

Link to comment
Share on other sites

I have also tried placing registerModEntity inside the modfile's init:

 

@EventHandler
public void init(FMLInitializationEvent event)
{	
	EntityRegistry.registerModEntity(EntityRopeKnot.class, "rope", 0, this, 160, Integer.MAX_VALUE, false);

	proxy.init();
}

 

But it is still invisible.

Link to comment
Share on other sites

48 hours? :(

 

And also, placing EntityRegistry.registerModEntity and RenderingRegistry.registerEntityRenderingHandler inside my pre-init method didn't work.

 

I am using Forge 1.8-11.14.1.1402. The latest one is .1404 but I don't see the need to update.

Link to comment
Share on other sites

The render method is called by the doRender method, so by calling the doRender method inside the render method will just loop around.

 

Anyway, I still tried it and it didn't work.

 

I've also simplified/cleaned the code, removing unneeded methods:

 

@SideOnly(Side.CLIENT)
public class RenderRopeKnot extends Render 
{
private static final ResourceLocation TEXTURE = new ResourceLocation(Mod.MODID, "textures/entity/rope_knot.png");
private ModelRopeKnot MODEL = new ModelRopeKnot();

public RenderRopeKnot()
{
	super(Minecraft.getMinecraft().getRenderManager());
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) 
{
	return this.TEXTURE;
}

@Override
public void doRender(Entity entity, double x, double y, double z, float f, float partialTicks)
{
	System.out.println("render");
	EntityRopeKnot entityropeknot = (EntityRopeKnot)entity;
	GlStateManager.pushMatrix();
	GlStateManager.disableCull();
	GlStateManager.translate((float)x, (float)y, (float)z);
	GlStateManager.enableRescaleNormal();
	GlStateManager.scale(-1.0F, -1.0F, 1.0F);
	GlStateManager.enableAlpha();
	this.bindEntityTexture(entityropeknot);
	this.MODEL.render(entityropeknot, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
	GlStateManager.popMatrix();
	super.doRender(entityropeknot, x, y, z, f, partialTicks);
}
}

Link to comment
Share on other sites

One thing that looks wierd to me is that in your render class constructor you call super constructor passing the render manager in. Is that a valid super constructor? The Render class doesn't seem to have that constructor, or maybe I'm blind? The vanilla RenderLeashKnot doesn't do what you're doing either. I'm not sure what issue that might cause, but maybe your renderer isn't even being constructed properly?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I can't remove it since there's no other constructor without the RenderManager thingy inside the Render class. RenderLeashKnot has this as its constructor:

 

    public RenderLeashKnot(RenderManager p_i46158_1_)
    {
        super(p_i46158_1_);
    }

 

which calls Render's constructor:

    protected Render(RenderManager renderManager)
    {
        this.renderManager = renderManager;
    }

 

And the entry for RenderLeashKnot inside RenderManager:

 

this.entityRenderMap.put(EntityLeashKnot.class, new RenderLeashKnot(this));

 

I'm with you, I don't really know what's causing it to not render properly :V.

Link to comment
Share on other sites

You're right -- I was looking at 1.7.10 version of the class which doesn't have that constructor.

 

I'm stumped. You seem to be doing the right things. Maybe double-check that your client proxy code is actually running by putting a console statement by the renderer registration. Also put console statement in the constructor of the render class. Maybe you'll find that it isn't being registered or constructed.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

  • The ClientProxy is called (since my block models work).
  • The constructor for RenderRopeKnot is called.
  • getEntityTexture doesn't get called.
  • And as always, doRender doesn't get called.

 

And in case someone is wondering, the entity spawns (because the entity's onUpdate method works) just without a model/render.

 

I'll try testing it with a 1.7.10 build and see if it's a 1.8 forge problem.

 

EDIT For some reason, the same code works with 1.7.10-10.13.3-1407 (latest). I'll try reinstalling Forge 1.8.

EDIT 2 Reinstalling Forge 1.8 still didn't work. Will try using the latest version (1.8-11.14.1.1405).

EDIT 3 It still didn't work with 1.8-11.14.1.1405.

Link to comment
Share on other sites

If you compare your constructor to the built-in RenderLeashKnot, they do it differently. Instead of a constructor that takes nothing and passes render manager to the super constructor, they take the render manager as a parameter and pass that. Maybe the render manager you're passing isn't the right one for some reason and so you're rendering doesn't get processed.

 

Try copying the constructor from RenderLeashKnot instead of what you're using.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I think there are no other instance of RenderManager than the one Minecraft.getMinecraft().getRenderManager() provides. And also, the constructor from my RenderRopeKnot is the same as the one from RenderLeashKnot, I just passed the RenderManager inside the constructor instead of during initialization.

 

Anyway, I still tried doing it and it didn't work.

 

As a last resort, I'll try looking around mods with public sources and see how they register their entities and renders. :V

 

EDIT I can't seem to find a mod utilizing EntityHanging that is update for 1.8.

4 days and still counting.  :(

Link to comment
Share on other sites

  • 2 weeks later...

Yes it does. I have them at the onUpdate method and also before the spawnEntityInWorld inside createKnot method. Both of the debug messages are being called.

 

There's also a strange thing now that I test it one more time, is that after I reconnect to a test world (save and quit, play in the world), the debug message inside the onUpdate method doesn't get called.

 

I've also tried adding a debug message inside the onValidSurface method, but that method doesn't get called when the entity spawns from the item.

Link to comment
Share on other sites

The entity is a direct copy from the EntityLeashKnot class (with minor edits). I don't know if it is frowned upon or not but it's how I work with creating objects for Minecraft: copy vanilla, see if the new copy works, and work from it.

 

I have removed writeToNBTOptional method and it the entity is still there (albeit still with no render/model) after reloading the world.

Link to comment
Share on other sites

  • 1 month later...

How do I edit Minecraft source files with the current Forge setup?

 

A quick trip to Google shows ASM usage but I think that's taking things too far.

 

Why do you need to edit MC Source now? O.o

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

diesieben suggested to add a conditional breakpoint in RenderManager.renderEntityWithPosYaw to check with my entity. If I understand that correctly, I need to go MC's RenderManager class file and find the renderEntityWithPosYaw method and add if statements and debug messages there.

 

i dunno lol

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.