Food nutrition not working

Started by Foot on

Topic category: Help with modding (Java Edition)

Last seen on 05:19, 26. Nov 2019
Joined Apr 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Food nutrition not working

I am new to all this so be kind...  or at least have flare.

I have made my first mod and its simple.   Add a clown fish sandwich.  Nothing hard.

I made it.  It works. but....  nutritional value is set to 6.  when I eat the sandwich it only gives me 3.  No matter what number I set nuritional value to, all I get is 3 hunger back.

why is this happening.

Here is the code Mcreator gives me:

package net.mcreator.vanillastylefishrecipes1122;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.event.ModelRegistryEvent;

import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemFood;
import net.minecraft.item.Item;
import net.minecraft.item.EnumAction;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;

@Elementsvanillastylefishrecipes1122.ModElement.Tag
public class MCreatorFishclownsandwich extends Elementsvanillastylefishrecipes1122.ModElement {
    @GameRegistry.ObjectHolder("vanillastylefishrecipes1122:fishclownsandwich")
    public static final Item block = null;

    public MCreatorFishclownsandwich(Elementsvanillastylefishrecipes1122 instance) {
        super(instance, 1);
    }

    @Override
    public void initElements() {
        elements.items.add(() -> new ItemFoodCustom());
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerModels(ModelRegistryEvent event) {
        ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation("vanillastylefishrecipes1122:fishclownsandwich", "inventory"));
    }

    public static class ItemFoodCustom extends ItemFood {
        public ItemFoodCustom() {
            super(6, 0.3F, false);                                          <====== FROM MY UNDERSTANDING THE 6 IS THE NUTRITIONAL VALUE IT IS SUPPOSE TO RETURN.. ITS NOT. ====
            setUnlocalizedName("fishclownsandwich");
            setRegistryName("fishclownsandwich");
            setAlwaysEdible();
            setCreativeTab(CreativeTabs.FOOD);
            setMaxStackSize(64);
        }

        @Override
        public EnumAction getItemUseAction(ItemStack par1ItemStack) {
            return EnumAction.EAT;
        }
    }
}

 

Any help on this subject would be appreciated.  I have looked up java code online for this but being new, I really have no idea what Im looking at.  I can logically see some of it but most is just gibberish and does not fit with mcreator code.

Thanks.

 

Last seen on 14:12, 3. Jun 2023
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It works as intended. 1…
Sat, 11/16/2019 - 15:40

It works as intended. 1 hunger point is half a chopstick, so the entire hunger bar is 20 hunger points, not 10! It's the same for the health bar: 1 health point = half a heart. If you want to fill 6 chopsticks, set the nutritional value to 12.

Last seen on 16:01, 1. Jul 2021
Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
^
Sat, 11/16/2019 - 16:00

^

Last seen on 05:19, 26. Nov 2019
Joined Apr 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh man..  I swear I tried…
Sat, 11/16/2019 - 21:56

oh man..  I swear I tried that and it still did only 3.  But I resaved it with 12 as value, made SURE I resaved it and yep.. it worked. So I guess this is my one boggie.  Thanks for the response.