Jump to content

Recommended Posts

Posted

Hi, I'm new to minecraft rendering, I' ve searched a bit on the forums and google and managed to pick some information about how to change the default renderer.

But im not sure what to change in order to make my renderer, and how to make the renderer,

 

I have this, (I dont know if works)

 

Player Render

 

 

import net.minecraft.client.model.ModelBiped;

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

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

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.World;

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

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

 

import org.lwjgl.opengl.GL11;

 

import com.mojang.authlib.GameProfile;

 

 

public class RenderPlayer extends EntityPlayer{

 

public static void start() {

RenderingRegistry.registerEntityRenderingHandler(RenderPlayer.class, new Ren());

}

 

public RenderPlayer(World worldIn, GameProfile gameProfileIn) {

super(worldIn, gameProfileIn);

}

 

@Override

public boolean isSpectator() {

return false;

}

 

@Override

public boolean isCreative() {

return false;

}

}

 

 

 

IRenderFactory

 

 

package nwdv.ndmm.render;

 

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

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

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

 

public class Ren implements IRenderFactory{

 

@Override

public Render createRenderFor(RenderManager manager) {

return null;

}

 

}

 

 

 

To change the actual renderer, do I use this?

RenderingRegistry.registerEntityRenderingHandler(RenderPlayer.class, new Ren());

 

To render the player, do i implement this?

@Override

public Render createRenderFor(RenderManager manager) {

return null;

}

 

Thanks in advance,

NewDivide

Posted

1. RenderPlayer extends EntityPlayer

Wtf? Render is not Entity (EntityPlayer). You need to extend Render class or some subclass (e.g living render).

 

2. As of 1.9 (I think) you no longer register Render in Init - you register factory in PreInit instead.

RenderingRegistry.registerEntityRenderingHandler(EntityClass.class, new FactoryClass());

 

Your factory should return Render instance in createRenderFor.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Would this work then?

Player Render:

 

 

 

public class RenderPlayer extends Render implements IRenderFactory{

 

protected RenderPlayer(RenderManager renderManager) {

super(renderManager);

}

 

public static void start() {

RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, (RenderPlayer::new));

}

 

@Override

protected ResourceLocation getEntityTexture(Entity entity) {

return new ResourceLocation("nwmm:textures/entity/newSkin.png");//Path to texture

}

 

@Override

public Render createRenderFor(RenderManager manager) {

//CODE HERE?

return new RenderPlayer(manager);

}

}

 

 

Posted

The

IRenderFactory

must be a separate class to the

Render

(it can also be a lambda, method reference or anonymous class). The whole point of

IRenderFactory

being introduced was to delay the creation of the

Render

instances until the

RenderManager

is ready.

 

If you're extending

Render

directly, you need to override

Render#doRender

to actually render the player. Extend from

RenderPlayer

if you want the default player model to be rendered.

 

Player renderers receive special treatment, so

RenderingRegistry#registerEntityRenderingHandler

probably won't work in this case. You'll need to create your

Render

instances in the init phase and use reflection to assign them to the

RenderManager#playerRenderer

field and the

"default"

and

"slim"

keys of the

RenderManager#skinMap

field.

 

Note that your changes will be completely overwritten if another mod does the same thing.

 

If you want to replace the skin for a specific player, consider doing something similar to what I did for capes here.

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

The

IRenderFactory

must be a separate class to the

Render

(it can also be a lambda, method reference or anonymous class). The whole point of

IRenderFactory

being introduced was to delay the creation of the

Render

instances until the

RenderManager

is ready.

 

If you're extending

Render

directly, you need to override

Render#doRender

to actually render the player. Extend from

RenderPlayer

if you want the default player model to be rendered.

 

Player renderers receive special treatment, so

RenderingRegistry#registerEntityRenderingHandler

probably won't work in this case. You'll need to create your

Render

instances in the init phase and use reflection to assign them to the

RenderManager#playerRenderer

field and the

"default"

and

"slim"

keys of the

RenderManager#skinMap

field.

 

Note that your changes will be completely overwritten if another mod does the same thing.

 

If you want to replace the skin for a specific player, consider doing something similar to what I did for capes here.

 

i ve tried to do it that way, but it seems that @SubscribeEvent doesnt work like i thought,

 

 

 

package nwdv.ndmm.render;

 

import net.minecraft.client.entity.AbstractClientPlayer;

import net.minecraftforge.event.entity.EntityJoinWorldEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

@SideOnly(Side.CLIENT)

public class RenderEvent {

@SubscribeEvent

public void entityJoin(EntityJoinWorldEvent event) {

System.out.println("fire");

}

}

 

 

 

 

this doesnt fire at all, am i doing it wrong?

 

Posted

Have you registered the event handler? I suggest reading a tutorial on event handlers, like this one.

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



×
×
  • Create New...

Important Information

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