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
  • 138 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    110

poopoodice

poopoodice    110

  • Dragon Slayer
  • poopoodice
  • Members
  • 110
  • 890 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
  • 138 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55024 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
  • 138 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55024 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
  • 138 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

    • smmmadden
      *universal.jar files no longer on minecraftforge.net?

      By smmmadden · Posted 6 minutes ago

      Thanks - I think at some point, Technic Launcher required both files and copying the installer to modpack.jar (total 3 jars) in the bin folder for client modpack.  So I just continued that process. 🙂
    • diesieben07
      Some Obj models not working

      By diesieben07 · Posted 6 minutes ago

      Now your repository contains way too much unnecessary stuff. Please use the .gitignore file that comes with the MDK. It is properly configured.   Your OBJ models contain invalid VT (texture) definitions. Example: https://github.com/AlexFinchy/ModularMissiles/blob/d31b76067eb777fa99c5c4478f5f998ed455e3c8/src/main/resources/assets/modularmissiles/models/lowpoly.obj#L811-L813
    • diesieben07
      Why I meet 404 in downloading

      By diesieben07 · Posted 12 minutes ago

      Post the full log.
    • diesieben07
      *universal.jar files no longer on minecraftforge.net?

      By diesieben07 · Posted 15 minutes ago

      You should never have downloaded them. Use the installer. The universal jars are for download by the installer, you should not be downloading them as a user. They were confusing to people and people downloaded the wrong thing, thats why they are no longer listed.
    • Huntpor
      Loot Tables / Data Generator

      By Huntpor · Posted 39 minutes ago

      @Luis_ST thanks for the information. I’ll check it out.   
  • Topics

    • smmmadden
      2
      *universal.jar files no longer on minecraftforge.net?

      By smmmadden
      Started 57 minutes ago

    • Alexalien
      6
      Some Obj models not working

      By Alexalien
      Started 2 hours ago

    • xutongxin
      1
      Why I meet 404 in downloading

      By xutongxin
      Started 55 minutes ago

    • Huntpor
      2
      Loot Tables / Data Generator

      By Huntpor
      Started 9 hours ago

    • MLampe09
      0
      für den server versuch1

      By MLampe09
      Started 46 minutes ago

  • Who's Online (See full list)

    • Witherking25
    • diesieben07
    • Klarks
    • CookieLukas
    • smmmadden
    • Alexalien
    • Heinzchen
    • MLampe09
    • Peyang
  • 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