Class LegAnimation<T extends net.minecraft.world.entity.LivingEntity>

java.lang.Object
dev.oxydien.mathimations.prefabs.LegAnimation<T>
Type Parameters:
T - the type of the entity that this animation is for
All Implemented Interfaces:
IMathAnimation<T>

public class LegAnimation<T extends net.minecraft.world.entity.LivingEntity> extends Object implements IMathAnimation<T>
Animation for the legs of any LivingEntity.

This animation is responsible for animating the legs (somewhat similar to vanilla). It uses the entity's walk animation speed to determine the distance and angle of the legs.

  • Constructor Details

    • LegAnimation

      public LegAnimation(float legLength, float maxLegAngle, LegAnimation.LegAxis walkAxis, List<List<String>> legGroups)
      Creates a new LegsAnimation.

      The leg groups should have paths to the given model parts.

      Example:

           List<List<String>> legGroups = new ArrayList<>();
           legGroups.add(List.of("fl_leg", "bl_leg"));
           legGroups.add(List.of("fr_leg", "br_leg"));
       
      Parameters:
      legLength - the length of the legs (Pivot offset from the ground in pixels: 16 pixels -> 1 block)
      maxLegAngle - the maximum angle of the legs in radians
      walkAxis - the axis on which the legs should rotate
      legGroups - the groups of legs (each group is offset by 180 degrees, so they move opposite to each other)
  • Method Details

    • getTransitionTime

      public float getTransitionTime()
      Specified by:
      getTransitionTime in interface IMathAnimation<T extends net.minecraft.world.entity.LivingEntity>
    • update

      public void update(T entity, AnimationContext actx)
      Description copied from interface: IMathAnimation
      Update the animation
      Specified by:
      update in interface IMathAnimation<T extends net.minecraft.world.entity.LivingEntity>
      Parameters:
      entity - The entity being animated
      actx - The animation context (see AnimationContext)