2013-05-03 13:00:44 +00:00
|
|
|
package biomesoplenty.blocks;
|
|
|
|
|
2013-09-24 07:53:43 +00:00
|
|
|
import java.util.List;
|
2013-05-03 13:00:44 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-09-24 07:53:43 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.Icon;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
2013-05-03 13:00:44 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-05-29 01:05:27 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-09-24 07:53:43 +00:00
|
|
|
import biomesoplenty.blocks.renderers.RenderUtils;
|
2013-05-03 13:00:44 +00:00
|
|
|
|
|
|
|
public class BlockBamboo extends Block
|
|
|
|
{
|
2013-09-24 07:53:43 +00:00
|
|
|
private Icon bambooTop;
|
|
|
|
|
2013-05-03 13:00:44 +00:00
|
|
|
public BlockBamboo(int par1)
|
2013-05-31 10:34:02 +00:00
|
|
|
{
|
|
|
|
super(par1, Material.plants);
|
|
|
|
setBurnProperties(blockID, 5, 5);
|
|
|
|
this.setTickRandomly(true);
|
|
|
|
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
}
|
2013-05-03 13:00:44 +00:00
|
|
|
|
|
|
|
@Override
|
2013-09-24 07:53:43 +00:00
|
|
|
public void registerIcons(IconRegister iconRegister)
|
2013-05-03 13:00:44 +00:00
|
|
|
{
|
2013-09-24 07:53:43 +00:00
|
|
|
blockIcon = iconRegister.registerIcon("biomesoplenty:bamboo");
|
|
|
|
bambooTop = iconRegister.registerIcon("biomesoplenty:bambootop");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Icon getIcon(int side, int meta)
|
|
|
|
{
|
|
|
|
if (side > 1)
|
|
|
|
return blockIcon;
|
|
|
|
else
|
|
|
|
return bambooTop;
|
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);
|
2013-06-04 07:45:20 +00:00
|
|
|
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 2);
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-04 07:45:20 +00:00
|
|
|
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 + 1, 2);
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-03 13:00:44 +00:00
|
|
|
}
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
2013-09-24 07:53:43 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
float pixel = 0.0625F;
|
|
|
|
|
|
|
|
return AxisAlignedBB.getAABBPool().getAABB((double)x + (1.0F - (pixel * 4)), (double)y, (double)z + (1.0F - (pixel * 4)), (double)x + (pixel * 4), (double)y + 1.0F, (double)z + (pixel * 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
|
|
|
|
{
|
|
|
|
float pixel = 0.0625F;
|
|
|
|
this.setBlockBounds((pixel * 4), 0.0F, (pixel * 4), 1.0F - (pixel * 4), 1.0F, 1.0F - (pixel * 4));
|
|
|
|
super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity);
|
|
|
|
this.setBlockBoundsForItemRender();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setBlockBoundsForItemRender()
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
|
|
|
{
|
|
|
|
this.checkBlockCoordValid(par1World, par2, par3, par4);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
return this.canPlaceBlockAt(par1World, par2, par3, par4);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
2013-09-24 07:53:43 +00:00
|
|
|
return RenderUtils.bambooModel;
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canSustainLeaves(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-03 13:00:44 +00:00
|
|
|
|
|
|
|
}
|