Jump to content

Recommended Posts

Posted

So I want to make an animation for a attack for my mob, the problem is I don't know how, I've looked at the code for the iron golems model, but there are methods I haven't seen before there, so I don't know how to adapt the code.

I also haven't been able to find any tutorials on it either (or at least ones that are not out dated).

 

can someone explain it to me or show me how to create these animations?

 

if so that would be great.

 

thanks for your time.

Im serious don't look at it!!

Posted

ok, so this is some code that I put together from the iron golem class, problem is there is a syntax error on armR.attackTimer, what's wrong with it?

 

public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_){
    	  
    	  EntityUndead undead = (EntityUndead)undead;
          int i = ((EntityIronGolem) ArmR).getAttackTimer();

          if (i > 0)
          {
              this.ArmR.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - p_78086_2_, 10.0F);
              
          }
         
      }
     

  

  private float func_78172_a(float p_78172_1_, float p_78172_2_){
// TODO Auto-generated method stub
return 0;
} 

 

Im serious don't look at it!!

Posted

Boonie - bruh, animating is one of those things that doesn't have tutorials and requires you to actually sit and read code for hours to write something that will work well.

 

If I were you I'd dig into whole vanilla rendering system before even touching writing anything on your own.

 

Note:

Renderer is same for all Entities, the renderer takes Entity argument when performing rendering - that Entity can hold data regarding animation.

In case of golem it is .getAttackTimer().

 

To apply attack animations onto your entity you can simply save variable inside it - then when doing somethign with it - synchronize it to client and make client do animation.

 

To apply animations to existing entities you would need to recreate and replace their renderer (EDIT: or use RenderLivingEvent) and apply IExtendedEntityProperties to save additional variables.

 

EDIT

how to you get the method for when the entity attacks.

 

Without checking I don't think there is method for checking if entity attacks - only player has such thing (for swinging his arms).

You can only "grab" the exact moment of performing attack by LivingAttackEvent and getting attacker from damageSource.

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

Posted

Facing - check out GuiIngame and search for debug, I belive it had direction player is looking at in 1.7.10 (I am on 1.8, with nice EnumFacing).

Staring/Looking - rayTrace - rayTracing code is like everywhere. Tuts are on net too.

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

Posted

Golems use world.setEntityState(flag) when they attackEntityAsMob - this sends a byte flag to the client side, which calls your entity's handleHealthUpdate(flag) method. Golems use that to set their attack timer on the client side as a flag for the model to begin animating, and the algorithm in the golem model is based on sine or cosine to create a smooth up/down motion all based on that one timer.

 

As others have suggested, your best bet is to literally just sit and read through the vanilla code for an hour or however long it takes you to understand how it works, and then do something similar.

 

Keep in mind that any variables you have in your entity are probably only known on the server side; thus, if you want to use them in your animation, you need to somehow inform the client of their current value. The method I described above is quite useful for most situations, or you can use DataWatcher or custom packets if you are in need of more precise control.

Posted

You can follow the golem code, but the approach to animation is pretty simple. You just need to program the following:

 

1) Need a counter variable in your entity class to indicate how far into the animation you are. Most people make it a decrement counter, so if the total animation was 20 ticks (1 second) you'd set it to 20 at start of attack.

 

2) You need to sync the attack counter from Step #1 from server to client, using custom packets (or data watcher, or entity state)

 

3) In your entity model, in your render method you just need to set the rotation angles and positions based on the value of the attack counter from the entity passed into the method.

 

4) Don't forget to decrement the attack counter (either in entity update method or the model render method).

 

That's it!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.