2013-04-16 08:19:59 +00:00
|
|
|
package biomesoplenty.blocks;
|
2013-03-28 19:03:53 +00:00
|
|
|
|
2013-04-13 01:58:30 +00:00
|
|
|
import java.util.ArrayList;
|
2013-03-28 19:03:53 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2013-04-19 09:35:26 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-04-20 01:26:09 +00:00
|
|
|
import biomesoplenty.api.Blocks;
|
2013-04-16 08:19:59 +00:00
|
|
|
import biomesoplenty.configuration.BOPBlocks;
|
2013-04-16 06:43:45 +00:00
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-03-31 07:44:08 +00:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-03-28 19:03:53 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.world.World;
|
2013-04-13 01:58:30 +00:00
|
|
|
import net.minecraftforge.common.IShearable;
|
2013-03-28 19:03:53 +00:00
|
|
|
|
2013-04-15 23:55:45 +00:00
|
|
|
@Deprecated
|
2013-04-13 01:58:30 +00:00
|
|
|
public class BlockDesertGrass extends Block implements IShearable
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
2013-03-30 17:14:03 +00:00
|
|
|
protected BlockDesertGrass(int par1, Material par3Material)
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
|
|
|
super(par1, par3Material);
|
|
|
|
this.setTickRandomly(true);
|
|
|
|
float var3 = 0.4F;
|
|
|
|
this.setBurnProperties(this.blockID, 60, 100);
|
|
|
|
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.8F, 0.5F + var3);
|
2013-04-19 09:35:26 +00:00
|
|
|
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
2013-03-31 07:44:08 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister par1IconRegister)
|
|
|
|
{
|
|
|
|
this.blockIcon = par1IconRegister.registerIcon("BiomesOPlenty:desertgrass");
|
|
|
|
}
|
2013-03-28 19:03:53 +00:00
|
|
|
|
2013-03-30 17:14:03 +00:00
|
|
|
public BlockDesertGrass(int par1)
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
2013-03-30 17:14:03 +00:00
|
|
|
this(par1, Material.plants);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
return super.canPlaceBlockAt(par1World, par2, par3, par4) && this.canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
|
|
|
|
* blockID passed in. Args: blockID
|
|
|
|
*/
|
|
|
|
protected boolean canThisPlantGrowOnThisBlockID(int par1)
|
|
|
|
{
|
2013-04-20 01:26:09 +00:00
|
|
|
return par1 == Blocks.redRock.get().blockID;
|
2013-03-28 19:03:53 +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
|
|
|
|
*/
|
|
|
|
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
|
|
|
{
|
|
|
|
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
|
|
|
|
this.checkFlowerChange(par1World, par2, par3, par4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ticks the block if it's been scheduled
|
|
|
|
*/
|
|
|
|
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
|
|
|
{
|
|
|
|
this.checkFlowerChange(par1World, par2, par3, par4);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected final void checkFlowerChange(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);
|
2013-03-30 17:14:03 +00:00
|
|
|
par1World.setBlock(par2, par3, par4, 0);
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && this.canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, 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 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the ID of the items to drop on destruction.
|
|
|
|
*/
|
|
|
|
public int idDropped(int par1, Random par2Random, int par3)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
|
|
|
|
* block and l is the block's subtype/damage.
|
|
|
|
*/
|
|
|
|
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
|
|
|
|
{
|
2013-04-13 01:58:30 +00:00
|
|
|
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isShearable(ItemStack item, World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
|
|
|
|
{
|
|
|
|
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
|
|
|
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
|
|
|
|
return ret;
|
2013-03-28 19:03:53 +00:00
|
|
|
}
|
|
|
|
}
|