Bewitchment

Bewitchment

7M Downloads

Events for a more useful API

williambl opened this issue ยท 9 comments

commented

For integration with other mods and bewitchment add-ons, some events could be useful.

Currently, if an add-on wants to, for example, do something when an entity gains blood, the only option is to mixin to every place where BloodAccessor#fillBlood is called individually (as interface default methods cannot be mixed into).

If an addon wants to run its own code when a player's transformation is set to Vampire or Werewolf, it cannot do this, as the code is run in a mixin and is therefore unmodifiable.

A set of events, easily made with the fabric-provided EventFactory, would make Bewitchment more extensible.

commented

HAHAH @MoriyaShiine I FUCKING TOLD YOU

ok that aside, I second this; Callbacks are a good, reliable and functional approach to affect especially mixin driven content and a handful of them should definitely be included in the API

commented

ok so starting with this, it'd probably best to define some rules for what should get events and what shouldn't, user input would be greatly appreciated

commented

Generally speaking we can probably reduce this to events relating to mixins, as said (tho non mixin events would be nice too sometimes but that may just be out of the scope)

commented

I'd say anywhere a significant behaviour occurs entirely through a mixin (as they cannot be mixed into), default interface method (as they cannot be mixed into), or through a lambda (as it's not guaranteed lambda synthetic method names will not be stable over mod updates, potentially breaking mixins), it's a candidate for an event.

The definition of 'significant' is vague, but that's not really an issue IMO - the way I see it is 'if an addon needs it or an addon would be likely to need it'

commented

I honestly feel like it'd be fair patching in events only by demand via PR, so the rule is simply if there's demand for it, and if it can't be reasonably done with mixin

commented

(also can we please have a ReviveEvent or something since you can't get the positive return value from the death protection revival without completely copying the code in needless ways)

commented

a ReviveEvent or something since you can't get the positive return value from the death protection revival
@Aelpecyem this bit?
image

If so, where in it?

(btw, pending merge of FabricMC/fabric#1394, this code can be moved out of mixin)

commented

this bit, probably at the start before the damage check so it can be cancelled
re: FabricMC/fabric#1394 looks good, but would probably not erase the need for a callback regarding this

commented

would probably not erase the need for a callback regarding this

Yeah, I know, I was just mentioning it here mostly so that I don't forget about the fact that I can move all that out of the mixin.