Skip to content

Conversation

@PssbleTrngle
Copy link

Currently in the MobEffectInstanceMixin when populating the list of cures, you are accessing the value of the passed effect holder too soon for some use cases.
Specifically the following, where a mod creates an effect and also an item with this effect in it's food properties.
The deffered holder of the effect is passed to the MobEffectInstance constructor, but du to porting lib is accessed there directly to create the list of cures.

This PR changes this behaviour by moving the cure population to a lazy supplier, therefore only loading once it's accessed the first time and the underlying effect holder has actually been registered.

Mentioned example:

public static final RegistryEntry<MobEffect, ModdedEffect> FOOD_EFFECT = REGISTRATE
            .generic("food_effect", Registries.MOB_EFFECT, ModdedEffect::new)
            .register();

 public static final ItemEntry<Item> FOOD_ITEM = REGISTRATE
            .item("food_item", Item::new)
            .properties(it -> it.food(
                        new FoodProperties.Builder()
                                .effect(new MobEffectInstance(FOOD_EFFECT, 20 * 40, 0), 1.0F)
                                .nutrition(2)
                                .saturationModifier(0.1F)
                .build()
            ))
            .register();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant