Jump to content

[1.7.2][SOLVED]Custom crop drops wheat seeds and wheat(Not what I want it to)


Recommended Posts

Posted

It is supposed to be dropping Quartz Seeds and a Quartz Block. Instead, it drops Wheat and Seeds. Also, if anyone knows how, I would like to set the percentage of the time each thing drops. I am updating from 1.6.4.

 

Here is my code:

 

 

  Reveal hidden contents

 

 

And the Mod Base:

 

 

  Reveal hidden contents

 

 

If any code you need to see is missing, tell me and I'll add it.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

  • 2 months later...
Posted

You need to use the functions of the extended class

 

 

protected Item func_149866_i()

    {

        return Items.wheat_seeds;

    }

 

    protected Item func_149865_P()

    {

        return Items.wheat;

    }

Posted

package yourpackage;

 

import java.util.Random;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.material.Material;

import net.minecraft.block.Block;

import net.minecraft.block.BlockCrops;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.IIcon;

import net.minecraft.world.World;

 

 

public class yourcrop extends BlockCrops{

 

public yourcrop() {

super();

 

 

 

}

@SideOnly(Side.CLIENT)

    private IIcon[] field_149869_a;

    private static final String __OBFID = "CL_00000286";

 

    /**

    * Gets the block's texture. Args: side, meta

    */

    @SideOnly(Side.CLIENT)

    public IIcon getIcon(int p_149691_1_, int p_149691_2_)

    {

        if (p_149691_2_ < 7)

        {

            if (p_149691_2_ == 6)

            {

                p_149691_2_ = 5;

            }

 

            return this.field_149869_a[p_149691_2_ >> 1];

        }

        else

        {

            return this.field_149869_a[3];

        }

    }

 

   

    protected Item func_149866_i()

    {

    return **DROP always**

   

   

       

       

       

    }

   

   

   

    protected Item func_149865_P()

    {

    return **DROP if full grown**

   

    }

 

   

 

/**

    * Drops the block items with a specified chance of dropping the specified items

    */

    public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)

    {

        super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_);

 

        if (!p_149690_1_.isRemote)

        {

            if (p_149690_5_ >= 7 && p_149690_1_.rand.nextInt(50) == 0)

            {

                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(Items.string));

            }

        }

    }

 

    @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister p_149651_1_)

   

    {

        this.field_149869_a = new IIcon[4];

 

        for (int i = 0; i < this.field_149869_a.length; ++i)

        {

       

        int stage = 0;

if(i==0)

{

stage = 0;

}

if(i==1)

{

stage = 1;

}

if(i==2)

{

stage = 2;

}

if(i==3)

{

stage = 3;

}

            }

            this.field_149869_a = p_149651_1_.registerIcon("yourtexturefile" + "_" + stage);

        }

     

       

       

    }

 

 

   

 

}

  • 4 weeks later...
Posted

(sorry for bad english, i'm from venezuela)

Override this methods on your crop

@Override
    public Item getItemDropped(int meta, Random random, int fortune) //get drop item based on meta
    {
        return meta == 7 ? this.getCropItem() : this.getSeedItem();
    }

    @SideOnly(Side.CLIENT)
    public Item getItem(World world, int x, int y, int z) //get item with mouse wheel
    {
        return this.getSeedItem();
    }

   @Override
    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) //get drops array
    {
        ArrayList<ItemStack> drops = new ArrayList<ItemStack>();

        int count = quantityDropped(metadata, fortune, world.rand);
        for(int i = 0; i < count; i++)
        {
            Item item = getItemDropped(metadata, world.rand, fortune);
            if (item != null)
            {
                drops.add(new ItemStack(item, 1, damageDropped(metadata)));
            }
        }
        
        if (metadata >= 7)
        {
            for (int i = 0; i < 3 + fortune; ++i)
            {
                if (world.rand.nextInt(15) <= metadata)
                {
                    drops.add(new ItemStack(this.getSeedItem(), 1, 0)); //<-- here
                }
            }
        }
        
        return drops;
    }

Making mods is fun!!!

(sorry bad english, i'm from venezuela)

Guest
This topic is now closed to further replies.

Announcements



  • Create New...

Important Information

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