Jump to content

[SOLVED] Rendering An Entity


De Joker

Recommended Posts

Hey, so i created an Entity that extends Entity. I registered it correctly and I see the spawn egg and i can spawn it without any errors.

The problem is when i render it, It does not render correctly. I always see the model next to the player and not where the entity is. 

(The render is registered correctly as well)

 

I think i need to use some GL code but i really didnt see any explantion of this. 

 

Here is my render class: (I used boat textures just for testing purposes)

 

package me.dejoker.broomstick.render;

import me.dejoker.broomstick.entities.EntityBroomstick;
import me.dejoker.broomstick.models.ModelBroomstick;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderBroomstick extends Render<EntityBroomstick>
{
    private static final ResourceLocation BOAT_TEXTURES = new ResourceLocation("textures/entity/boat/boat_oak.png");

	ModelBase modelBroom = new ModelBroomstick();
	
	protected RenderBroomstick(RenderManager renderManager)
	{
		super(renderManager);
	}

	@Override
	public void doRender(EntityBroomstick entity, double x, double y, double z, float entityYaw, float partialTicks)
	{
        modelBroom.render(entity, 0f, 0f, -0.1f, 0f, 0f, 0.0625f);
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
	}
	
	@Override
	protected ResourceLocation getEntityTexture(EntityBroomstick entity)
	{
		return BOAT_TEXTURES;
	}

}

 

2019-01-19_17_39_14.png.b05593aed8abecea87396f7314046056.png

Edited by De Joker
Link to comment
Share on other sites

33 minutes ago, diesieben07 said:

You need to use GLStateManager.translate(x, y, z) before rendering the model. And you need to pushMatrix before and popMatrix after, to return the matrix to it's original state afterwards.

Thanks! That did work.

 

Another thing I might ask is why when i extend EntityLiving the model register correctly and  when i extend Entityit does not?

Edited by De Joker
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



×
×
  • Create New...

Important Information

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