Jump to content

[1.14.3] Change Entity Model Based on Variable


pH7

Recommended Posts

Hi,

 

I want to change between two models for an entity I have, depending on whether or not it is being ridden. I was thinking of something like an if(isBeingRidden) statement inside the entity's Model class to change the model, but this is an EntityType, not an EntityModel, method.

 

I tried to see how Minecraft does it (let's say for a Zombie attacking) but as of now, I can't access any vanilla Entity or Render class. I did notice the use of DataParameters in Entity classes; and thus used one to store and update whether or not my entity is being ridden. I'm not sure how, and where to use it, though.

 

Thanks,

Kres

'Everyone is a genius,

But if you judge a fish by its ability to climb trees, it will live its whole life believing that it is stupid.'

 

-Albert Einstein

----------------------------------------------------------

If Arthas's horse is named "Invincible", then why can I clearly see him?

Link to comment
Share on other sites

I've sorted myself out so I'm answering this in order for this thread to be closed.

 

All I had to do was to create a boolean isMounted in my entity's model class, and call the doRender() method in my entity's renderer class; where inside I would have checked if the entity isBeingRidden() and change the isMounted boolean accordingly within doRender().

 

Example:

	public void doRender(ScorpionEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
		boolean state = entity.isBeingRidden();
		ScorpionModel<ScorpionEntity> scorpion = this.getEntityModel();
		scorpion.isMounted = state;

		super.doRender(entity, x, y, z, entityYaw, partialTicks);
	}

Works like a charm

'Everyone is a genius,

But if you judge a fish by its ability to climb trees, it will live its whole life believing that it is stupid.'

 

-Albert Einstein

----------------------------------------------------------

If Arthas's horse is named "Invincible", then why can I clearly see him?

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.