apace100 / apoli

MIT License
40 stars 46 forks source link

Add a `loading_condition` field to power loading logic. #90

Closed MerchantPug closed 1 year ago

MerchantPug commented 1 year ago

This adds a loading_condition field to the power JSON. Currently it supports the 3 meta conditions and apoli:mod_loaded with an id field and apoli:datapack_loaded with a namespace field.

The loading condition field is checked before attempting to load the power, with a null result being returned if a loading_condition is present and false. If a null result is returned for a multiple or subpower, it will ignore the extra logic attached.

In the case of loading priorities, it will only delete an old power if the loading priority is higher than the currently registered one but will not update the loading priority upon doing so, mainly so any non dependent or dependency correct powers can load.

I'm unsure on if I should be showing a warning message with this system but it's probably fine to not have that as it's supposed to be a non intrusive way of having dependencies with powers.

If this is merged, I'd hope that such a thing could also be on Origins.


For testing purposes, a test datapack with a higher loading priority and a loading condition that will always return false is provided here.

MerchantPug commented 1 year ago

Accidentally had a goof while trying to change the name of the branch.

apace100 commented 1 year ago

I think I will probably reject this in favour of using Fabric's own resource conditions API, unless you see reasons for sticking with a custom implementation here which I'm not seeing. https://github.com/FabricMC/fabric/tree/1.19.4/fabric-resource-conditions-api-v1

MerchantPug commented 1 year ago

I ultimately agree to that, I'm unfortunately not really in a mood to change things right now so I'll be closing this PR.