Jump to content

Crop Help?


yanksrock1019

Recommended Posts

I have just created a crop(strawberry plant) but the only way to get the drops from the fully grown crop is to destroy the dirt under it.  How can I fix this?

 

Crop class:

package com.puplet.blocks;

import java.util.Random;

import com.puplet.items.PupletItems;

import net.minecraft.block.BlockCrops;
import net.minecraft.init.Items;
import net.minecraft.item.Item;

public class PupletCrop extends BlockCrops{

/**
 * seeds
 */
@Override
protected Item func_149866_i()
    {
        return PupletItems.pupletSeeds;
    }

/**
 * crop
 */
@Override
    protected Item func_149865_P()
    {
        return PupletItems.Strawberry;
    }


}

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

Hi

 

Do you mean - you can't destroy the crop by clicking on it?  Or do you mean- if you destroy the block by clicking on it, it gives you nothing? 

You have to use the appropriate tool to harvest a crop...

The code from 1.6.4 has a couple of relevant functions in it, you could perhaps find the corresponding ones in 1.7.2, place a breakpoint in them, and see why you're not getting strawberries.

 

Alternatively a breakpoint in Block.harvestBlock and/or ItemInWorldManager.tryHarvestBlock will also narrow things down a lot.

 

-TGG

 

    @Override

    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)

    {

        ArrayList<ItemStack> ret = super.getBlockDropped(world, x, y, z, metadata, fortune);

 

        if (metadata >= 7)

        {

            for (int n = 0; n < 3 + fortune; n++)

            {

                if (world.rand.nextInt(15) <= metadata)

                {

                    ret.add(new ItemStack(this.getSeedItem(), 1, 0));

                }

            }

        }

 

        return ret;

    }

 

    /**

    * Returns the ID of the items to drop on destruction.

    */

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return par1 == 7 ? this.getCropItem() : this.getSeedItem();

    }

 

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



×
×
  • Create New...

Important Information

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