2013-03-28 19:03:53 +00:00
|
|
|
package tdwp_ftw.biomesop.blocks;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockFlower;
|
|
|
|
import net.minecraft.block.material.Material;
|
2013-03-30 17:14:03 +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.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.stats.StatList;
|
|
|
|
import net.minecraft.world.ColorizerFoliage;
|
|
|
|
import net.minecraft.world.ColorizerGrass;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class BlockShortGrass extends BlockFlower
|
|
|
|
{
|
|
|
|
public BlockShortGrass(int par1)
|
|
|
|
{
|
|
|
|
super(par1, Material.vine);
|
|
|
|
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-03-30 17:14:03 +00:00
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister par1IconRegister)
|
|
|
|
{
|
|
|
|
this.blockIcon = par1IconRegister.registerIcon("BiomesOPlenty:shortgrass");
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return par1 == Block.grass.blockID || par1 == Block.dirt.blockID || par1 == Block.tilledField.blockID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getBlockColor()
|
|
|
|
{
|
|
|
|
double var1 = 0.5D;
|
|
|
|
double var3 = 1.0D;
|
|
|
|
return ColorizerGrass.getGrassColor(var1, var3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the color this block should be rendered. Used by leaves.
|
|
|
|
*/
|
|
|
|
public int getRenderColor(int par1)
|
|
|
|
{
|
|
|
|
return par1 == 0 ? 16777215 : ColorizerFoliage.getFoliageColorBasic();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
|
|
|
|
* when first determining what to render.
|
|
|
|
*/
|
|
|
|
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
|
|
|
return var5 == 0 ? 16777215 : par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID)
|
|
|
|
{
|
|
|
|
par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
|
|
|
|
this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(mod_BiomesOPlenty.shortGrassItem, 1, par6));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.shortGrassItem.itemID;
|
|
|
|
}
|
|
|
|
}
|