Posted November 26, 2024Nov 26 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.
November 30, 2024Nov 30 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.
1 hour ago1 hr game changed the way you create foods. for example minecraft 1.21.8 code for the golden apple is Foods.javapublic static final FoodProperties GOLDEN_APPLE = new FoodProperties.Builder().nutrition(4).saturationModifier(1.2F).alwaysEdible().build();Items.javapublic static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE));Consumables.javapublic 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.