Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.