Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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. 

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.

  • 9 months later...

game changed the way you create foods.
for example minecraft 1.21.8 code for the golden apple is

Foods.java
public static final FoodProperties GOLDEN_APPLE = new FoodProperties.Builder().nutrition(4).saturationModifier(1.2F).alwaysEdible().build();

Items.java
public static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE));

Consumables.java
public static final Consumable GOLDEN_APPLE = defaultFood() .onConsume( new ApplyStatusEffectsConsumeEffect( List.of(new MobEffectInstance(MobEffects.REGENERATION, 100, 1), new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0)) ) )

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.