Skip to content

oxydien/mathimations

Repository files navigation

Mathimations

A lightweight Minecraft animation library for creating smooth, math-based entity animations without keyframes.

Overview

Mathimations allows you to animate Minecraft entities using mathematical functions instead of traditional keyframe systems. Perfect for procedural animations like idle movements, walking cycles, breathing effects, and more.

Instead of defining static keyframes, you write animation logic using sine waves, cosine functions, and other mathematical operations to create smooth, dynamic movements that can adapt to gameplay conditions in real-time.

Features

  • Math-Based Animations - Use trigonometric functions and mathematical expressions instead of keyframes
  • Smooth Transitions - Automatic blending between animations with configurable transition times
  • Layer System - Combine multiple animations simultaneously using layers (e.g., walk + attack + blink)
  • Per-Entity & Global Animations - Register animations for specific entities or all entities of a type
  • Lightweight - Minimal overhead, only modifies model part transformations
  • Animation Sync - Built-in support for synchronized animations across multiple entities
  • Utility Functions - Helpers for common animation patterns (leg cycles, timing windows, trigonometric mapping)
  • Prefabs - Ready-to-use animations like walking cycles for quick setup

🚀 Quick Example

public class IdleAnimation implements IMathAnimation<YourEntity> {
    @Override
    public float getTransitionTime() {
        return 0.4f; // Blend in/out over 0.4 seconds
    }
    
    @Override
    public void update(YourEntity entity, AnimationContext ctx) {
        ModelPartState body = ctx.getPart("body");
        if (body == null) return;
        
        // Create a gentle bobbing motion
        float time = (float) ctx.getTimeSinceEntityStart();
        float bob = (float) Math.sin(time * 2) * 0.05f;
        
        body.translateY(bob);
        body.setPitch((float) Math.sin(time) * 0.1f);
    }
}

Installation

Gradle

// MAKE SURE YOU HAVE Modrinth MAVEN REPOSITORY
repositories {
    exclusiveContent {
        forRepository {
            maven {
                name = "Modrinth"
                url = "https://api.modrinth.com/maven"
            }
        }
        filter {
            includeGroup "maven.modrinth"
        }
    }
}
dependencies {
    modImplementation "maven.modrinth:mathimations:%VERSION_HERE%"
}

Documentation

Key Concepts

How It Works

Mathimations works by manipulating the transformations (position, rotation, scale) of entity model parts during rendering. Since Minecraft shares model instances across all entities of the same type, the system:

  1. Stores animation state per-entity
  2. Calculates transformations each frame using your math functions
  3. Applies transformations just before rendering
  4. Resets the model after rendering

This approach is perfect for procedural animations that respond to game state, but may not be ideal for complex pre-authored animation sequences.

Animation Layers

Organize animations into layers that blend together:

  • Layer 0: Base animations (idle, walk)
  • Layer 1+: Additive animations (attacks, gestures)

Each layer can have one active animation at a time, with smooth transitions between them.

Contributing

Contributions are welcome! Feel free to:

  • Report bugs via Issues
  • Submit feature requests
  • Create pull requests

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the LICENSE file for details.

Credits

Created by oxydien for fun and personal projects.


Note: This is a math-based animation system, not magic. It requires understanding of basic trigonometry and Minecraft's entity rendering pipeline. Check out the documentation and examples to get started!

About

A Minecraft library for making animations with MATH.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published