Timed Modifiers API: Temporary Buffs for Minecraft

Discover the Timed Modifiers API for Minecraft, a developer tool for temporary attribute modifiers with decay, growth, and easing. Learn how to install and use it.

Download timed modifiers api for Minecraft 1.21.8

Original name: timed modifiers api

Minecraft: 1.21.8

Loaders: Fabric

FileVersionLoaderSize
timed_modifiers_api-1.2.2+1.21.7.jar1.21.8Fabric143 КБDownload

Timed Modifiers API

Minecraft modding has always been about pushing the boundaries of what's possible inside the blocky universe. For developers, creating dynamic gameplay often means juggling complex systems, especially when it comes to temporary effects like speed boosts, strength buffs, or debuffs that wear off over time. The Timed Modifiers API is a specialized library designed to solve this exact problem, offering a clean and efficient way to add attribute modifiers that automatically expire after a set duration. Whether you're a seasoned modder or a player looking to enhance their game, this API is a powerful addition to your toolkit.

What is the Timed Modifiers API?

At its core, the Timed Modifiers API is a dependency, not a standalone gameplay mod. It doesn't add new items, blocks, or creatures. Instead, it provides a robust framework that other mods can use to manage temporary attribute changes. Think of it as a backend service for buffs and debuffs. For players, this means you might encounter mods that rely on this API to deliver smoother, more balanced temporary effects. For developers, it's a time-saver that eliminates the need to write complex tick-based logic from scratch.

The API is built for modern Minecraft versions, with the latest builds supporting the 1.21.x series, including 1.21.7. It is primarily designed for the Fabric loader, making it a lightweight and fast option for your modding setup. If you're using a launcher that supports Fabric, integrating this API is straightforward.

Why Use the Timed Modifiers API?

Managing temporary modifiers in vanilla Minecraft is a headache. You have to track tick counters, manually remove attributes, and handle edge cases where entities die or change dimensions. The Timed Modifiers API handles all of this for you. It offers a simple, fluent interface that lets you add, remove, and even animate modifier values over their lifetime. This opens up creative possibilities, such as potions that gradually increase in strength or debuffs that fade out smoothly.

For players, the benefit is a more polished experience. Mods that use this API tend to have fewer bugs related to lingering effects. If you are looking to add such mods to your game, you will first need to download Timed Modifiers API and place it in your mods folder. It's a simple process that ensures everything runs smoothly.

Key Features for Developers

The API is packed with features that streamline development. Here are some of the highlights you can use in your own projects:

  • Simple Addition: Add a temporary modifier with a single line of code, specifying the entity, attribute, modifier, and duration in ticks.
  • Growth and Decay: Make a modifier's value increase or decrease over its lifetime. You can even specify a separate duration for the change to occur.
  • Easing Functions: Apply smooth transitions using easing types like Sine, Quadratic, Cubic, Quartic, Quintic, and Circle. This prevents jarring, instant changes.
  • Manual Removal: Remove a specific modifier before its timer expires, or clear all modifiers at once.
  • Override System: Prevent errors by overriding an existing modifier with the same ID.
  • Utility Methods: Query remaining duration, set or unset base values, and check if a value is currently set.

How to Install the API

If you are a player, the installation is a breeze. First, ensure you have the Fabric Loader installed for your Minecraft version. Then, navigate to a trusted mod repository and download Timed Modifiers API. The file will be a standard .jar file. Simply drag and drop it into your mods folder, which is located in your Minecraft directory. Restart the game, and you're ready to go. If you are using the foxygame.net launcher, you can find the Timed Modifiers API directly in its add-on catalog, which allows for a one-click install and automatically handles the correct version for your game instance, saving you from manual file management.

For developers, how to install the API into your development environment is slightly different. You will need to add the Modrinth Maven repository to your build.gradle file. Then, you can declare a dependency on the API. The version string follows a specific format, such as 1.0.0+1.21.7, which includes the Minecraft version it supports. This ensures you are always compiling against the correct API build.

Getting Started with the Code

Once the API is set up, using it is intuitive. The main entry point is the TimedModifierAPI class. Here’s a quick example of how to add a temporary speed boost:

EntityAttributeModifier modifier = new EntityAttributeModifier(
    Identifier.of("example", "speed"),
    0.6,
    EntityAttributeModifier.Operation.ADD_MULTIPLIED_TOTAL
);
TimedModifierAPI.addModifier(player, EntityAttributes.MOVEMENT_SPEED, modifier, 60);

This code adds a modifier that increases the player's movement speed by 60% for 60 ticks, which is exactly 3 seconds. The API takes care of the rest, automatically removing the modifier when the time is up.

Advanced: Growth, Decay, and Easing

The real power of the API shines when you start using its chaining methods. For instance, you can make a buff decay over time:

TimedModifierAPI.addModifier(player, EntityAttributes.MOVEMENT_SPEED, modifier, 100).decay();

This will gradually decrease the speed boost from +60% down to 0% over the 100-tick duration. You can also combine this with easing functions for a more natural feel:

TimedModifierAPI.addModifier(player, EntityAttributes.MOVEMENT_SPEED, modifier, 100).decay().ease(EaseHelper.EasingTypes.SINE_OUT);

This applies a sine ease-out, making the speed decrease slowly at first and then more rapidly towards the end. For growth, you can specify a target limit and an optional duration for the growth phase. This level of control allows you to create truly unique and responsive gameplay mechanics.

Alternatives and Best Practices

While the static methods are convenient, the API also provides an interface-based approach. You can cast a living entity to ITimedModifier to access the same methods directly, which can be cleaner if you are calling them multiple times. There is also a container-based system for grouping operations on a single attribute. This is particularly useful when you have complex modifiers that need to be managed together. It is important to note that container methods do not include the set/unset value functions, so you must cast to the API interface for those specific operations.

For developers, it is crucial to remember that this is an API. It will not do anything on its own in-game. It is purely a dependency for other mods. When you are ready to release your mod, you should declare this as a dependency so that players know they need to install it. The foxygame.net launcher also supports auto-updates for dependencies, meaning if a new version of the Timed Modifiers API is released that fixes a bug or adds features, the launcher can automatically update it for you, ensuring your modded setup remains stable and compatible without manual intervention.

Conclusion

The Timed Modifiers API for Minecraft is an essential tool for any developer looking to implement temporary attribute effects without the boilerplate code. Its feature-rich design, including growth, decay, and easing, provides a level of polish that is hard to achieve with vanilla methods. For players, it's a silent but vital component that makes many modern mods work flawlessly. By simplifying the complex logic of timed modifiers, this API allows creators to focus on what matters most: making the game more fun. Whether you are a developer integrating it into your next project or a player ensuring your mods run smoothly, the Timed Modifiers API is a robust and reliable choice.