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

Basicly like mushroom stew. When it's used (eaten) to give the bowl back. I saw online to use "return new ItemStack(Items.BOWL);" but it says "Unreachable code". Here is the hole thing:

 

package com.martiblq.stew_mod.objects.items;

import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.world.World;

public class BabyYodaStew extends Item
{

    public BabyYodaStew(Properties properties) 
    {
        super(properties);
    }
    @Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) 
    {
        return super.onItemUseFinish(stack, worldIn, entityLiving);
        return new ItemStack(Items.BOWL);
    }
}

You're already returning super#onItemUseFinish, you cannot return twice.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

  • Author

so it returns the bowl but now it doesn't feed you.

here is item init

Spoiler

event.getRegistry().register(new BabyYodaStew(new Item.Properties().group(stew_modItemGroup.instance).food(new Food.Builder().hunger(20).saturation(20f).build())).setRegistryName("baby_yoda_stew"));

and here is the class

Spoiler

package com.martiblq.stew_mod.objects.items;

import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.world.World;

public class BabyYodaStew extends Item
{

    public BabyYodaStew(Properties properties) 
    {
        super(properties);
    }
    @Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) 
    {
        return super.onItemUseFinish(new ItemStack(Items.BOWL), worldIn, entityLiving);
    }
}
 

 

You're misusing onItemUseFinish, the ItemStack is whatever item they're currently eating. By putting a stack of bowls in there, you're telling the game that the player is eating (or more accurately "using") a bowl.

Look at how SoupItem does it.

Edited by imacatlolol

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

That's not how it works here. We are averse to copy-paste code

 I will make fun of you if you are not able to look into the (vanilla-) code.

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.