Jump to content

ItemFood.java


Sarmachus

Recommended Posts

Hello all,

          I done goofed.  I was trying to create my own custom food, and the course that I was learning eclipse from didn't give me all the code that i wanted for my food.  I wanted to create a kind of soup, and have it give you the bowl back.  I decided to take a look in the source code and after getting my food to act like mushroom soup, I decided that i wanted to add some potion effects and shorten the consumption of the food.  I didn't know exactly everything that i was doing, and accidentally altered some of the source code.  :P  yup.  big mistake.  I opened Minecraft to see if things were running smoothly, and i accidentally made it so that you can never finish eating your food.  I am modding in 1.6.4, and the tab i messed with was FoodItem.java.  Can someone post a rely with what the source code should look like, or do I have to post what FoodItem.java now looks like for me?  Thanks for your help...  :-\

Link to comment
Share on other sites

ItemFood:

 

package net.minecraft.item;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.potion.PotionEffect;

import net.minecraft.world.World;

 

public class ItemFood extends Item

{

    /** Number of ticks to run while 'EnumAction'ing until result. */

    public final int itemUseDuration;

 

    /** The amount this food item heals the player. */

    private final int healAmount;

    private final float saturationModifier;

 

    /** Whether wolves like this food (true for raw and cooked porkchop). */

    private final boolean isWolfsFavoriteMeat;

 

    /**

    * If this field is true, the food can be consumed even if the player don't need to eat.

    */

    private boolean alwaysEdible;

 

    /**

    * represents the potion effect that will occurr upon eating this food. Set by setPotionEffect

    */

    private int potionId;

 

    /** set by setPotionEffect */

    private int potionDuration;

 

    /** set by setPotionEffect */

    private int potionAmplifier;

 

    /** probably of the set potion effect occurring */

    private float potionEffectProbability;

 

    public ItemFood(int par1, int par2, float par3, boolean par4)

    {

        super(par1);

        this.itemUseDuration = 32;

        this.healAmount = par2;

        this.isWolfsFavoriteMeat = par4;

        this.saturationModifier = par3;

        this.setCreativeTab(CreativeTabs.tabFood);

    }

 

    public ItemFood(int par1, int par2, boolean par3)

    {

        this(par1, par2, 0.6F, par3);

    }

 

    public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        --par1ItemStack.stackSize;

        par3EntityPlayer.getFoodStats().addStats(this);

        par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F);

        this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);

        return par1ItemStack;

    }

 

    protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability)

        {

            par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));

        }

    }

 

    /**

    * How long it takes to use or consume an item

    */

    public int getMaxItemUseDuration(ItemStack par1ItemStack)

    {

        return 32;

    }

 

    /**

    * returns the action that specifies what animation to play when the items is being used

    */

    public EnumAction getItemUseAction(ItemStack par1ItemStack)

    {

        return EnumAction.eat;

    }

 

    /**

    * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer

    */

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        if (par3EntityPlayer.canEat(this.alwaysEdible))

        {

            par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));

        }

 

        return par1ItemStack;

    }

 

    public int getHealAmount()

    {

        return this.healAmount;

    }

 

    /**

    * gets the saturationModifier of the ItemFood

    */

    public float getSaturationModifier()

    {

        return this.saturationModifier;

    }

 

    /**

    * Whether wolves like this food (true for raw and cooked porkchop).

    */

    public boolean isWolfsFavoriteMeat()

    {

        return this.isWolfsFavoriteMeat;

    }

 

    /**

    * sets a potion effect on the item. Args: int potionId, int duration (will be multiplied by 20), int amplifier,

    * float probability of effect happening

    */

    public ItemFood setPotionEffect(int par1, int par2, int par3, float par4)

    {

        this.potionId = par1;

        this.potionDuration = par2;

        this.potionAmplifier = par3;

        this.potionEffectProbability = par4;

        return this;

    }

 

    /**

    * Set the field 'alwaysEdible' to true, and make the food edible even if the player don't need to eat.

    */

    public ItemFood setAlwaysEdible()

    {

        this.alwaysEdible = true;

        return this;

    }

}

 

Link to comment
Share on other sites

Where did you get this from?  I tried to open up a 1.7.9 version with eclipse, and i got a mess like this:

 

PK∏zéDMETA-INF/MANIFEST.MF§Ω…í£J∂.</≥Ûgé›B‚ò˝!D+ÅÄI}˜<˝UÊUGÏrÌ?"Ô 232¬Â‡æ|≠Ô[ùãNôÑA◊ˇ#hª§*ˇÁø—"ˇı—I ˇCÁN◊˝œóAˇœ")Øu¬˛ü^ûeˇœüø_ˇ¯ØHN¸œªMÛ˙¡Î∑ˇÎ˜Ö˛&â^ü˘?ˇ›´C/è5Ê%deT3tsÖ∫fU˝o£€8:wΩ°\ŒbdØÌeõ.\‡âUw⁄˚Ë≈6"¬3˜v–‹æ*ñvvJZüáß˙6ÿ‡hî£ëÖπUᢋó”\VÜ√É⁄JŸ€ËhñÁ›»≥É Ä5{¨Ñd

(this is just the beginning)  Are code files downloadable?

Link to comment
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.
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...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.