Jump to content

an ability to not render the rider of a spesific entity


Ninjusk

Recommended Posts

i am writing a mod that add vehicles that don't need the player to render because it will render its own version of the player. i am using Render Player API but id rather not use it if i didn't have to. I was wondering the possibility of adding a function to the Entity class similar to public boolean shouldRiderSit() that would ask if the rider should be rendered at all. i think it would just require an edit to the entity class to add the function and to the Renderliving class where  at the beginning of its render it would check to see it the entity its riding returns true(or false based on how you name the function) and if it does simply exits the render function.

 

Its just an idea i had, i don't think it would be that hard to implement but i could be wrong.

 

thanks for at least taking the time to read this

Link to comment
Share on other sites

So the true suggestion here is too make a way to dynamically change the armors texture?

no its more of a way to just not render the entity or telling the game that even tho the entity exists, that he/she/it should not be rendered in world when the entity has mounted an vehicle. in the case of my mod the rendering of the entity is being taken over by the vehicle render because the rider(only players are allowed) will be rendered in a different position that is not possible with the normal player render. I feel this would open up for a massive number of vehicles that were not previously possible like motorcycles where the player is holding the grips of the cycle. or also useful for mods like flans where the plane can roll but the player is still rendered straight up, you could give over the players render to the planes render allowing the player to be rendered at the same roll and pitch as the plane.

Link to comment
Share on other sites

It wouldn't be too difficult to replace the player renderer with one which allows you to disable rendering completely, if certain conditions are met. You don't even need to use reflection, just replace it in the List.

 

but if you mod the render list wouldn't other entities of that type not be rendered? i did a test in an older version of minecraft(1.4.7) where i added one function to Entity.java and one edit to a function in RenderManager.java and in my test it wound not matter if you had RenderPlayerAPI installed or not because it stops the render before the DoRender function is called. here my proposed code

Entity.Java

	/**
 * used to determine if the rider of this entity should be Rendered. 
 * 
 * @return false the Rider of this entity will not be Rendered
 */
public boolean shouldRiderRender()
{
	return true;
}

 

RenderManager.java

	
public void renderEntityWithPosYaw(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
               //Added code starts here
               //if the entity is riding another entity and that entity.shouldRiderRender returns false 
               //the rider render will be skipped
	if(par1Entity.ridingEntity != null && !par1Entity.ridingEntity.shouldRiderRender())
	{
		return;
	}
               //Added code ends here

//the rest of the function

I am how ever going to look into better non-base class modding ways of doing this. but for now this is what im proposing.

 

Link to comment
Share on other sites

ivegot an easy solution.

 

ModelBipedMain, used in PlayerRenderer returns the current player model used.

 

you could use following :

 

modelBipedMain.bipedHead.showmodel == false;

 

do that for every part of the player.

remember to  .showmodel== true; as a default, so when the player un mounts the bike, it will bee visible again.

this does not allow you though to acces the model of armor, as they are private fields :/

so bike riding would have to happen without armor.

or you can find a way around this :)

Link to comment
Share on other sites

It wouldn't be too difficult to replace the player renderer with one which allows you to disable rendering completely, if certain conditions are met. You don't even need to use reflection, just replace it in the List.

but if you mod the render list wouldn't other entities of that type not be rendered?

 

No? You will choose what conditions to call the original render function - it will only not render if you make it not render.

Link to comment
Share on other sites

ivegot an easy solution.

 

ModelBipedMain, used in PlayerRenderer returns the current player model used.

 

you could use following :

 

modelBipedMain.bipedHead.showmodel == false;

 

do that for every part of the player.

remember to  .showmodel== true; as a default, so when the player un mounts the bike, it will bee visible again.

this does not allow you though to acces the model of armor, as they are private fields :/

so bike riding would have to happen without armor.

or you can find a way around this :)

 

if you are talking about something you do with PlayerRender API im trying to remove the need for it because if you look at how the How the API works, lets just take the function renderPlayer in your RenderPlayerBase file. in the code that calls your renderPlayer function it looks for any other registered renderPlayer Functions and runs a loop to call all of them now the way i currently unrender the player is by in my renderPlayer function i just return if a case is true.

	
        @Override
public void renderPlayer(EntityPlayer entityplayer, double d, double d1, double d2, float f, float f2)
{
	if (entityplayer.ridingEntity != null && isRidingVechicle(entityplayer))
	{
		return;
	}
	else
	{
		super.renderPlayer(entityplayer, d, d1, d2, f, f2);	
	}

}

this works if great if there is not another RenderPlayerAPI Mod installed but if there is and it Has a RenderPlayer Function then it will just screw up the My Render because the Player will be Rendered once my way(on a tron LightCycle) and again probably sitting with his/ her body stuck in the front of the bike.  So unless There is a better way of doing this(i am open to suggestions) im stuck using a method to not render the player that doesn't really work well in a bunch of cases.

Link to comment
Share on other sites

http://www.minecraftforum.net/topic/1688664-151-sspsmpwin-a-cape-v83-rpg-inventory-mod-3d-items-jewelery-capes-and-much-more/

 

 

thats what i did without any baseclass editing.

custom armor models, capes rendered to the player, other models rendered to him, a new inventory, all without baseclass editing.

only problem is that is incompatible with any mod that does edit the player renderer.

Smartmoving does not do that.

Mine Little Pony does.

 

So bascily, all you need to do is catch an instance of RenderPlayer, use the field ModelBipedMain, and set your player 'invisible'.

as i told before, you can't acces the aror model fields, because they are private fields :/

i really wouldnt know any other ways of doing what you need, and in my opinion, the easiest to get, without using any api or editing baseclasses. You could even set it so the player cant mount the vehicle if he wears armor, or you can just unrender the entire armor sets by bypassing and itercepting the model renderer and anihilate the renderer (a hack, basicly). i did the same thing for custom armor, but rendered stuff with it , instead of removing stuff :)

Link to comment
Share on other sites

Wrap the rendering instance to your need, I'm too lazy to research it but pseudo code:

public class RenderWrapper extends Render{
private Render wrappedRenderer;
public static List<Class<? extends Entity>> norend = new ArrayList();
static{
norend.add(yourEntity.class);
}

public RenderWrapper(Render r){
wrappedRender = r
}

public void doRender(Entity e, //Otros parameters){
if(e.isRiding && !norend.containse(e.entityRidden.getClass()))
wrappedRender.doRender(e, other parameters);
}
}

{

Using client proxy of course

public void postInit(FMLPostInitializationEvent e){
Rederplayer r = RenderingRegistry.renderList.get(playerrender);
RenderingRegistry.renderList.remove(r);
RenderingRegistry.registerEntityRender(EntityPlayer.class,new RenderWrapper(r);//super pseudo
}

No Asm reflection(I think), base edits.

I think its my java of the variables.

Link to comment
Share on other sites

It wraps.... not replaces. Meaning you can wrap the wrapper...and if someone replaces the render before it those changes are kept. The problem is if some blundersome programmer replaces or wraps out of order (forced invisibility is a top priority, so should be done last)

I think its my java of the variables.

Link to comment
Share on other sites

but remember we always will have asm.

whats asm?

java byte code manipulating, basicly u can edify classes on runtime, adding, remove or event editing things take a look at asm tutorial on the forg wiki, code chickens core and nei src, also bukkit forge src

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.