Code:
package net.minecraft.src;
import java.util.Random;
//import net.minecraft.src.forge.*;
public class BlockFruit extends Block /*implements ITextureProvider*/
{
public Item dropped;
public Block block;
public BlockFruit(int par1, int par2, Item par3Item, Block par4Block)
{
super(par1, par2, Material.unused);
setRequiresSelfNotify();
setHardness(0.1F);
setStepSound(soundGrassFootstep);
dropped = par3Item;
float var4 = 0.4F;
setBlockBounds(0.2F, 0.3F, 0.2F, 0.8F, 0.9F, 0.8F);
block = par4Block;
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int i = par1World.getBlockId(par2, par3 + 1, par4);
if (i != block.blockID)
{
return false;
}
return true;
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
checkBlockCoordValid(par1World, par2, par3, par4);
}
/**
* Checks if current block pos is valid, if not, breaks the block as dropable item.
*/
protected final void checkBlockCoordValid(World par1World, int par2, int par3, int par4)
{
if (!canBlockStay(par1World, par2, par3, par4))
{
dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
/**
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
*/
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
return canPlaceBlockAt(par1World, par2, par3, par4);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/*public String getTextureFile()
{
return "/stuuupiiid/fruits.png";
}*/
public boolean isOpaqueCube()
{
return false;
}
public int getRenderType()
{
return 1;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return dropped.shiftedIndex;
}
}