Jump to content

[1.7.10] Alternating textures on entity?


DaveTheModder

Recommended Posts

Hey all,

 

I'm trying to create an NPC mod for personal use. I might release it, but I'm not sure.

 

I want to have the textures cycle through about 5-10 different textures after onInteract.

 

How would I do this? I looked into the Ghast and Zombie render classes to find how they change textures, but didn't see anything decipherable. Can anyone run me through on how something like this would work?

 

Thanks for all help!

Link to comment
Share on other sites

Create Renderer class with ModelBiped (that you probably know).

 

Most importantly - There is ONE renderer for all entities of given type (NPC).

Renderer takes Entity as argument - inside your EntityNPC you will need to store some variable.

I suggest it to be some integer "animationPhase".

Now - when some action accurs you will need to send packet from server to client that will set this NPC's integer to something.

Now in renderer you can make IF that will take that integer from NPC and run animations. Only thing left is to put .png into assets and make static ResourceLocations for them. Simply return different textures for given animationPhase.

 

Example:

@SideOnly(Side.CLIENT)
public class RenderNPC extends RenderBiped
{
public RenderNPC(RenderManager rm)
{
	super(rm, new ModelZombie(), 0.5F, 1.0F);
}

@Override
protected ResourceLocation getEntityTexture(Entity entity)
{
	return this.getNPCTexture((EntityNPC)entity);
}

protected ResourceLocation getNPCTexture(EntityNPC npc)
{
	int animate = npc.getAnimationPhase();
	// number of ifs that will get animation phase and return different ResourceLocation.
}
}

 

Note: DO NOT change value of AnimationPhase inside renderer - rendering runs on rendering loop, not game loop - update that value in update() method of entity (increment /decrement for example - to change phases).

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

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.