Jump to content

How making pretty much a copy of cocoa beans in minecraft?


Mecblader

Recommended Posts

Hello, I am making a mod and I want to add grapes to it and I though adding them by way of the way that cocoa beans work might be neat, but I have tried many times, but I can't even figure out how to make them work.

 

Me rambling about what happened:

 

I know where the cocoa block class is and I just copied it, but I can't find Item cocoa.

I think it may be under the dye, but the code in the class doesn't spawn the cocoa beans, but instead makes the beans that I place down by using the block grow and now I'm going to stop before I confuse everyone, but pretty much it's not exactly going my way, so I am going to start over with help of this support section.

 

 

I have an intermediate knowledge about Java, but I'm no professional modder. I would really appreciate it if someone could help me figure out how to make pretty much a simple copy of the cocoa beans in minecraft because I obviously can't do this myself. :(

 

 

Don't be afraid to ask question when modding, there are no stupid question! Unless you don't know java then all your questions are stupid!

Link to comment
Share on other sites

IF you want to create the item, you'll need to make an item class like normal and then override the onItemUse method in Item and use the following code in the overridden method.

 

You will need to change Block.cocoaPlant.blockID to the ID of your grape block and Block.wood.blockID to the ID of the block you want to plant the grape on.

 

int i1 = par3World.getBlockId(par4, par5, par6);

                int j1 = par3World.getBlockMetadata(par4, par5, par6);

 

                if (i1 == Block.wood.blockID && BlockLog.limitToValidMetadata(j1) == 3)

                {

                    if (par7 == 0)

                    {

                        return false;

                    }

 

                    if (par7 == 1)

                    {

                        return false;

                    }

 

                    if (par7 == 2)

                    {

                        --par6;

                    }

 

                    if (par7 == 3)

                    {

                        ++par6;

                    }

 

                    if (par7 == 4)

                    {

                        --par4;

                    }

 

                    if (par7 == 5)

                    {

                        ++par4;

                    }

 

                    if (par3World.isAirBlock(par4, par5, par6))

                    {

                        int k1 = Block.blocksList[block.cocoaPlant.blockID].onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0);

                        par3World.setBlock(par4, par5, par6, Block.cocoaPlant.blockID, k1, 2);

 

                        if (!par2EntityPlayer.capabilities.isCreativeMode)

                        {

                            --par1ItemStack.stackSize;

                        }

                    }

 

                    return true;

                }

"Thinking that coding is the nerdy IT guy at work rebooting your computer is like thinking that music is what happens when the piano tuner comes round." - Ed Rex

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.