ModificationStation / StationAPI

A general use API for Fabric Loader mods on legacy Minecraft versions.
85 stars 19 forks source link

Effects API #117

Open paulevsGitch opened 4 months ago

paulevsGitch commented 4 months ago

An API for creating effects that works for all entities (including not-living ones like items and minecarts).

Effect can stay for specified amount of ticks or it can last infinity:

public TestPlayerInfEffect(Identifier id, PlayerEntity entity) {
    super(id, entity);
    ticks = INFINITY_TICKS;
}

Effects applied to the player will be visible in the top left corner: image

In player inventory effects will display their name and description (compatible with HMI): image

Effect names have support for minecraft color codes: image

Effects have onStart, process, onEnd methods for large behaviour customisation, same as writeCustomData and readCustomData for storing custom values

To register effects you need to listen a specific event (common side):

@EventListener
public void registerEffects(EffectRegistryEvent event) {
    // Effect ID (Identifier), Effect class
    EffectRegistry.register(SLTest.NAMESPACE.id("test_effect"), TestPlayerEffect.class);
}

You can set affect on entity like this: player.addEffect(effectID); where effectID is Identifier. There are also other helper functions that you can directly call from entity to operate with effects. Effects works on both client and server.

PR is ready for review

mineLdiver commented 4 months ago

Change the base to 2.0-alpha.3 branch. Master is for minor updates only.

paulevsGitch commented 4 months ago

Done

calmilamsy commented 4 months ago

Unfucked your branch for you.

calmilamsy commented 4 months ago

No, don't merge your old changes. Reset to my changes.

matthewperiut commented 3 months ago

Personally I think that the effect texture should match the modern effect texture, it sticks out too much looking so different from other minecraft gui stuff effect_back_modern ^ this being the modern looking one that i made with a screenshot of modern mc effects and the texture file from this fork. I think this is the texture that should be used.

Additionally it would be nice if consistently the effect is consistent e.g.

+-----------------------------------+
|                     effect name   |
|  icon                             |
|            duration  (light grey) |
+-----------------------------------+

Similar to modern image

paulevsGitch commented 3 months ago

Personally I think that the effect texture should match the modern effect texture, it sticks out too much looking so different from other minecraft gui stuff

Current effect frame texture is very simple, but like any other texture it can be altered with texturepack. I'm not sure about official modern texture, current one looks fine

Additionally it would be nice if consistently the effect is consistent e.g.

There is an infinity effect in example above

calmilamsy commented 3 months ago

I'd possibly say just use the achievement toast background directly for this. Saves adding a StAPI-specific texture.