119 lines
3.9 KiB
Java
119 lines
3.9 KiB
Java
|
package tdwp_ftw.biomesop.blocks;
|
||
|
|
||
|
import java.util.Random;
|
||
|
|
||
|
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
|
||
|
|
||
|
import net.minecraft.block.Block;
|
||
|
import net.minecraft.block.material.Material;
|
||
|
import net.minecraft.util.AxisAlignedBB;
|
||
|
import net.minecraft.world.World;
|
||
|
|
||
|
public class BlockCattail extends Block
|
||
|
{
|
||
|
public BlockCattail(int par1, int par2)
|
||
|
{
|
||
|
super(par1, Material.plants);
|
||
|
this.blockIndexInTexture = par2;
|
||
|
float var3 = 0.375F;
|
||
|
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 1.0F, 0.5F + var3);
|
||
|
this.setTickRandomly(true);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Ticks the block if it's been scheduled
|
||
|
*/
|
||
|
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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 var5 = par1World.getBlockId(par2, par3 - 1, par4);
|
||
|
return var5 != Block.grass.blockID ? false : (par1World.getBlockMaterial(par2 - 1, par3 - 1, par4) == Material.water ? true : (par1World.getBlockMaterial(par2 + 1, par3 - 1, par4) == Material.water ? true : (par1World.getBlockMaterial(par2, par3 - 1, par4 - 1) == Material.water ? true : par1World.getBlockMaterial(par2, par3 - 1, par4 + 1) == Material.water)));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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)
|
||
|
{
|
||
|
this.checkBlockCoordValid(par1World, par2, par3, par4);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Checks if current block pos is valid, if not, breaks the block as dropable item. Used for reed and cactus.
|
||
|
*/
|
||
|
protected final void checkBlockCoordValid(World par1World, int par2, int par3, int par4)
|
||
|
{
|
||
|
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||
|
{
|
||
|
this.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 this.canPlaceBlockAt(par1World, par2, par3, par4);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||
|
* cleared to be reused)
|
||
|
*/
|
||
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||
|
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||
|
*/
|
||
|
public boolean isOpaqueCube()
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||
|
*/
|
||
|
public boolean renderAsNormalBlock()
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* The type of render function that is called for this block
|
||
|
*/
|
||
|
public int getRenderType()
|
||
|
{
|
||
|
return 6;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Returns the ID of the items to drop on destruction.
|
||
|
*/
|
||
|
public int idDropped(int par1, Random par2Random, int par3)
|
||
|
{
|
||
|
return mod_BiomesOPlenty.cattailItem.itemID;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||
|
*/
|
||
|
public int idPicked(World par1World, int par2, int par3, int par4)
|
||
|
{
|
||
|
return mod_BiomesOPlenty.cattailItem.itemID;
|
||
|
}
|
||
|
}
|