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    7

Luis_ST

Luis_ST    7

  • Diamond Finder
  • Luis_ST
  • Members
  • 7
  • 392 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    119

poopoodice

poopoodice    119

  • Dragon Slayer
  • poopoodice
  • Members
  • 119
  • 931 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    7

Luis_ST

Luis_ST    7

  • Diamond Finder
  • Luis_ST
  • Members
  • 7
  • 392 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    7711

diesieben07

diesieben07    7711

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7711
  • 56563 posts
Posted November 21, 2020

Food.Builder#setAlwaysEdible

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    7

Luis_ST

Luis_ST    7

  • Diamond Finder
  • Luis_ST
  • Members
  • 7
  • 392 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    7711

diesieben07

diesieben07    7711

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7711
  • 56563 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    7

Luis_ST

Luis_ST    7

  • Diamond Finder
  • Luis_ST
  • Members
  • 7
  • 392 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

    • diesieben07
      When I generate a world it stays at 100%

      By diesieben07 · Posted 9 minutes ago

      Try without the "rats" mod please.
    • diesieben07
      [1.16] InputEvent.KeyInputEvent never fired

      By diesieben07 · Posted 15 minutes ago

      The correct event for this check is ClientTickEvent. Make sure to check TickEvent#phase.
    • diesieben07
      Question about itemstack capabilities of crafting results

      By diesieben07 · Posted 15 minutes ago

      Yeah, it would be better to just lazily initialize the values in the capability. However AttachCapabilitiesEvent is triggered directly from the ItemStack constructor. So it is impossible to have an ItemStack object and not have AttackCapabilitiesEvent fire for it.
    • Beethoven92
      [1.16] InputEvent.KeyInputEvent never fired

      By Beethoven92 · Posted 20 minutes ago

      They are basically the same. With the annotation method you can also specify the Dist where this event handler will be loaded on. What is wrong with your code is that your method is not declared as static. Take a look here for more info on events: https://mcforge.readthedocs.io/en/latest/events/intro/
    • DARKHAWX
      [1.16] InputEvent.KeyInputEvent never fired

      By DARKHAWX · Posted 33 minutes ago

      Hey there,   I'm trying to setup a basic keybinding, but I can't seem to get the event to fire. Here's my code for subscribing to the event:   @Mod.EventBusSubscriber public class ModKeyInputs { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if (ModKeyBindings.OPEN_DIVINE_FAVOUR_RELATIONSHIP.isPressed()) { Minecraft.getInstance().displayGuiScreen(new DivineFavourRelationshipsScreen(Minecraft.getInstance().player)); } } }   Now I've put a breakpoint in the method there at the start, and I can never get it to fire. Am I subscribing to this event incorrectly?   As a side note, is there much difference between using @Mod.EventBusSubscriber on a class versus MOD_EVENT_BUS.register(ModKeyInputs.class); in the constructor of the main mod class?
  • Topics

    • StormyRiley1
      5
      When I generate a world it stays at 100%

      By StormyRiley1
      Started 12 hours ago

    • DARKHAWX
      2
      [1.16] InputEvent.KeyInputEvent never fired

      By DARKHAWX
      Started 33 minutes ago

    • Tavi007
      3
      Question about itemstack capabilities of crafting results

      By Tavi007
      Started 1 hour ago

    • Fizedi
      0
      Loot table change for chest in plains house

      By Fizedi
      Started 1 hour ago

    • diseasedworm
      1
      A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException

      By diseasedworm
      Started 5 hours ago

  • Who's Online (See full list)

    • Fizedi
    • matezz
    • Mightydanp
    • Luis_ST
    • diesieben07
    • NindyBun
    • EnderiumSmith
    • Tavi007
    • StormyRiley1
    • troublemaker_47
    • samjviana
  • 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