Jump to content

[1.6.2]Problem with Custom Crop


Neo2k

Recommended Posts

Hello together,

 

i have a problem with my custom crop.

 

Here is the code:

 

package xooth.core.blocks;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockCrops;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.network.packet.Packet3Chat;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import xooth.core.CoreItems;
import xooth.core.blocks.*;

public class PlantTomato extends BlockCrops {

@SideOnly(Side.CLIENT)
private Icon[] iconArray;

public PlantTomato(int par1) {
	super(par1);
}

    @SideOnly(Side.CLIENT)
    public Icon getIcon(int par1, int par2)
    {
        if (par2 < 7)
        {
            if (par2 == 6)
            {
                par2 = 5;
            }

            return this.iconArray[par2 >> 1];
        }
        else
        {
            return this.iconArray[4];
        }
    }

protected int getSeedItem() {
	return CoreItems.tomatoSeed.itemID;
}

protected int getCropItem() {
	return CoreItems.tomatoFood.itemID;
}

public int idDropped(int par1, Random par2Random, int par2)
{
	return par1 == 7 ? this.getCropItem() : this.getSeedItem();
}

public int quantityDropped(Random par1Random)
{
	return 1;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg)
{
	this.iconArray = new Icon[5];

	for (int i = 0; i < this.iconArray.length; i++)
	{
		this.iconArray[i] = reg.registerIcon("Core:tomatoCrop_" + i);
	}
}

}

 

The Problem is: my tomato plant has 5 images but the fourth image is skipped. If i use Bonemeal on the plant I must use it one time longer that means if i see the correct last image from the tomato plant i must use one more bonemeal to complete the plant.

 

Can someone help me with my problem?

Sorry for not so good english ;)

 

Link to comment
Share on other sites

Can someone tell me what is wrong?

 

     if (par2 < 7)
        {
            if (par2 == 6)
            {
                par2 = 5;
            }

 

Do you see what is wrong with this code here?  par2 is the metadata which means everytime the crop gets to the stage that represents metadata 6, you've set it so anytime the crop gets to that stage is is automatically set to metadata 5 the previous crop state.

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.