Jump to content

[1.10.2] PotionEffect adding model to entity ?


MCRaichu

Recommended Posts

Hi everyone,

I want to add a model I have made to entities while they are under a potioneffect. Currently I don't know where to start . Has anyone tried this before? Any tips where to start? For better understanding, I want to create a crystallization disease that creates tiny crystals on the infected entity.

 

Thanks in advance,

McRaichu

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

	@SubscribeEvent
	public void onEvent(RenderLivingEvent.Post<EntityLivingBase> event)
	{
		EntityLivingBase entity = event.getEntity();
		RenderLivingBase renderer = event.getRenderer();
		ModelBase model = renderer.getMainModel();
		if(entity instanceof EntityCreeper)
		{
			ModelCreeper mr = (ModelCreeper)model;
			ModelRenderer box = new ModelRenderer(model, 0, 16);
			box.addBox(0.0F, 0.0F, 0.0F, 10, 2, 10);
			mr.body.addChild(box);
		}
	}

 

I did a small test-code. I love the idea of adding to the model because the added parts move with the entity. But the problem is, I have no idea how to set a different texture for my added parts. is it even possible?

 

 

 

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

47 minutes ago, diesieben07 said:

You have to bind your texture like you normally would.

I may have to ask you to get a bit more specific. My understanding was to simply change the model and assign new texture (straight forward).

EntityLivingBase entity = event.getEntity();
RenderLivingBase renderer = event.getRenderer();
ModelBase model = renderer.getMainModel();
if(entity instanceof EntityCreeper)
{
  ModelCreeper mr = (ModelCreeper)model;

  renderer.bindTexture(new ResourceLocation(Gunny.MODID+ ":textures/items/models/vss_item.png"));

  ModelRenderer box = new ModelRenderer(model, 0, 16);
  box.addBox(0.0F, -20.0F, 0.0F, 10, 2, 10);
  mr.body.addChild(box);
}

Maybe I don't get when the event is called and what the difference of Pre and Post are in this case.

 

Edit: Currently the original creeper-texture is still used.

Edited by MCRaichu

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

No, the creeper (just a placeholder in my example) should render as normal but the addition, here the "box", should render with a texture of my choice. Currently the box renders with the creeper-texture.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

okay. to answer all you questions.

1.: the code i posted is in the onEvent(RenderLivingEvent.Post<EntityLivingBase> event) function as shown in Post 4

2.: As mentioned in the first post, I want to add something to any entity that is under a potioneffect. The code I posted, with creeper and the box I add, is just for testing.

3.: Using the model makes it easier to adjust the position of what i add, but with a global model that's not possible.

 

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

 

6 minutes ago, diesieben07 said:

You must add it once at startup from your client proxy,

Wouldn't that require that I know all models when my mod is loaded? That would make it incompatible with other mods (their entities), right? In your experience, what would be your approach to achieve a kind of visual feedback to differentiate between affected entities and unaffected ones. Maybe I should consider a different idea. I just don't like the particle effects of the potions, I wanted something more solid/bigger.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

Looping over all Renderes in PostInit makes sence. I don't have time until sunday to give it a try. May have more question on monday meaning I may bother you again :D. Thanks again.

It doesn't work, I don't know why.

It works, I don't know why.

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.