Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] Cant Eat Food Item
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Luis_ST

[1.16.1] Cant Eat Food Item

By Luis_ST, November 20, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Luis_ST    0

Luis_ST

Luis_ST    0

  • Creeper Killer
  • Luis_ST
  • Members
  • 0
  • 150 posts
Posted November 20, 2020

I creat a costum soup called fungus soup i can eat the soup i the creativ mod but i can't eat the soup in survival

 

this is the code of the item/soup

package net.luis.cave.items;

import net.luis.cave.Cave;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.UseAction;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.world.World;

public class FungusSoup extends Item {

	public FungusSoup() {
		
		super(new Item.Properties()
					.group(Cave.FOOD)
					.food(new Food.Builder()
							.hunger(10)
							.saturation(8.2f)
							.effect(new EffectInstance(Effects.RESISTANCE, 1200, 4), 1)
							.effect(new EffectInstance(Effects.MINING_FATIGUE, 1200, 4), 0.5f)
							.build()));
		
	}
	
	@Override
	public UseAction getUseAction(ItemStack stack) {
		
		return UseAction.EAT;
		
	}
	
	@Override
	public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
		
			ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
			return entityLiving instanceof PlayerEntity && ((PlayerEntity)entityLiving).abilities.isCreativeMode ? itemstack : new ItemStack(Items.BOWL);

	}
	
}

 

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    114

poopoodice

poopoodice    114

  • Dragon Slayer
  • poopoodice
  • Members
  • 114
  • 900 posts
Posted November 20, 2020

Players can't eat food when they are full, but you should be able to change it through the food builder.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    0

Luis_ST

Luis_ST    0

  • Creeper Killer
  • Luis_ST
  • Members
  • 0
  • 150 posts
Posted November 21, 2020

yes i know but i cant eat the food without a full foodbar

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7613

diesieben07

diesieben07    7613

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7613
  • 55180 posts
Posted November 21, 2020

Food.Builder#setAlwaysEdible

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    0

Luis_ST

Luis_ST    0

  • Creeper Killer
  • Luis_ST
  • Members
  • 0
  • 150 posts
Posted November 21, 2020
4 hours ago, diesieben07 said:

Food.Builder#setAlwaysEdible

yes i know i can eat the food in creativ and in survival even when the foodbar is empty

and when i add this

.setAlwaysEdible()

 

then i cant eat the food in creativ mod

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7613

diesieben07

diesieben07    7613

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7613
  • 55180 posts
Posted November 21, 2020

Looking at the code, that is not correct.

When in creative, a player should be able to eat, always.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    0

Luis_ST

Luis_ST    0

  • Creeper Killer
  • Luis_ST
  • Members
  • 0
  • 150 posts
Posted November 22, 2020 (edited)

i fixed it i creat a new item with the same properties and now it works

Edited November 22, 2020 by Luis_ST
spelling mistake
  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • fckurshitsite
      "shaderpacks" folder does not appear in Minecraft folder!

      By fckurshitsite · Posted 16 minutes ago

      so rude and useless :^)
    • Silivek
      Mod won't load when in dev environment

      By Silivek · Posted 34 minutes ago

      I ran it using the runClient configuration generated by  gradlew genEclipseRuns in the command line.
    • kiou.23
      Mod won't load when in dev environment

      By kiou.23 · Posted 38 minutes ago

      That's odd, I couldn't find anything wrong with the code. could you describe exactly what steps you are taking to run the mod?   also: your group in build.gradle and your main path doesn't follow the convention, seeing that you have a github, you could use that http://maven.apache.org/guides/mini/guide-naming-conventions.html   EDIT: Ideally I would pull the repo to my machine and try running the mod myself, but my weak computer takes 4 hours to decompile mc, So... sorry I can't do that
    • cadbane86140
      The Dream Skin Invasion!

      By cadbane86140 · Posted 39 minutes ago

      Hello There! This is a very weird but something worth documenting video on my channel, so late last night I see the usual stuff trending on twitter but decide to go into the server and well this happened... Our reactions are hilarious and I know you guys are gonna love it! I hope you all enjoy this video and if you did don't forget to like and sub for more!  
    • kiou.23
      Crafting Damage (1.16)

      By kiou.23 · Posted 43 minutes ago

      you don't need the existing damage, you can call ItemStack#damage() on the stack
  • Topics

    • DenizAri
      6
      "shaderpacks" folder does not appear in Minecraft folder!

      By DenizAri
      Started January 24, 2020

    • Silivek
      6
      Mod won't load when in dev environment

      By Silivek
      Started Thursday at 05:46 PM

    • cadbane86140
      0
      The Dream Skin Invasion!

      By cadbane86140
      Started 40 minutes ago

    • DeadZone
      4
      Crafting Damage (1.16)

      By DeadZone
      Started 3 hours ago

    • GermanBucket
      1
      IntelliJ doesn't include resources folder while debugging

      By GermanBucket
      Started 55 minutes ago

  • Who's Online (See full list)

    • jbredwards
    • Alloy1981
    • Godis_apan
    • Initifi
    • Draco18s
    • fckurshitsite
    • Silivek
    • LUCy2021
    • LeiteDesnatado
    • Extrodonary
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] Cant Eat Food Item
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community