Jump to content

Recommended Posts

Posted

So, I am following the 1.21 forge tutorials by Kaupenjoe on youtube, and I have run into a problem. In tutorial #8, which is the one about adding foods, he creates a food with effects by using .effect() on the FoodProperties, and he also shows a few other methods, .fast() and .usingConvertsTo(). None of the mentioned methods actually exist when I try to use them. They just aren't there. .saturationModifier, .nutrition(), .alwaysEdible(), and .build() are the only relevant methods that actually exist. What is going on here? Did something change between 1.21 and 1.21.3? I can't find any documentation anywhere. 

Posted

Hi! I just started learning forge yesterday and ran into the same issue. I couldn’t find any documentation about these changes, but I found a way to add effects to food like this:
 

public class ChakChakItem extends Item {
    private static final FoodComponent FOOD_COMPONENT = new FoodComponent.Builder()
            .nutrition(16)
            .saturationModifier(0.4f)
            .build();
    private static final ConsumableComponent CONSUMABLE_COMPONENT = ConsumableComponents.food()
            .consumeEffect(new ApplyEffectsConsumeEffect(
                    new StatusEffectInstance(StatusEffects.SPEED, 15 * 20, 1), 1.0f))
            .build();

    public ChakChakItem() {
        super(new Item.Settings()
                .food(FOOD_COMPONENT, CONSUMABLE_COMPONENT)
                .registryKey(RegistryKey.of(
                        RegistryKeys.ITEM,
                        Identifier.of(ChakChakMod.MOD_ID, "chak_chak")
                )));
    }
}

If the code isn’t perfect, I apologize.
Hopefully, others here can help us find a better solution.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.