BiomesOPlenty/src/minecraft/biomesoplenty/blocks/BlockBamboo.java

161 lines
4 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
2013-05-03 13:00:44 +00:00
public class BlockBamboo extends Block
{
public BlockBamboo(int par1)
2013-05-31 10:34:02 +00:00
{
super(par1, Material.plants);
float var3 = 0.15F;
setBurnProperties(blockID, 5, 5);
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 1.0F, 0.5F + var3);
this.setTickRandomly(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
2013-05-03 13:00:44 +00:00
@Override
public void registerIcons(IconRegister par1IconRegister)
{
2013-05-31 10:34:02 +00:00
blockIcon = par1IconRegister.registerIcon("BiomesOPlenty:bamboo");
2013-05-03 13:00:44 +00:00
}
2013-05-31 10:34:02 +00:00
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (par1World.isAirBlock(par2, par3 + 1, par4))
2013-05-03 13:00:44 +00:00
{
2013-05-31 10:34:02 +00:00
int var6;
for (var6 = 1; par1World.getBlockId(par2, par3 - var6, par4) == blockID; ++var6)
{
;
}
if (var6 < 3)
{
int var7 = par1World.getBlockMetadata(par2, par3, par4);
if (var7 == 15)
{
par1World.setBlock(par2, par3 + 1, par4, blockID);
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 + 1, 4);
}
}
2013-05-03 13:00:44 +00:00
}
2013-05-31 10:34:02 +00:00
}
@Override
public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
{
return false;
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
@Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
if (var5 == blockID)
return true;
2013-05-03 13:00:44 +00:00
else if (var5 == Block.grass.blockID)
return true;
else
return false;
2013-05-31 10:34:02 +00:00
}
/**
* 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
*/
@Override
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.setBlock(par2, par3, par4, 0);
2013-05-03 13:00:44 +00:00
}
2013-05-31 10:34:02 +00:00
}
/**
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
*/
@Override
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
return this.canPlaceBlockAt(par1World, par2, par3, par4);
}
/**
* Returns the ID of the items to drop on destruction.
*/
// public int idDropped(int par1, Random par2Random, int par3)
// {
// return BOPItems.bambooItem.itemID;
// }
/**
* 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.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return 1;
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
// public int idPicked(World par1World, int par2, int par3, int par4)
// {
// return BOPItems.bambooItem.itemID;
// }
@Override
public boolean canSustainLeaves(World world, int x, int y, int z)
{
return true;
}
2013-05-03 13:00:44 +00:00
}