mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
134 lines
3.8 KiB
Java
134 lines
3.8 KiB
Java
package tconstruct.blocks.slime;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockBush;
|
|
import net.minecraft.block.BlockFlower;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.common.ForgeHooks;
|
|
import net.minecraftforge.common.IShearable;
|
|
import tconstruct.library.TConstructRegistry;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class SlimeTallGrass extends BlockBush implements IShearable
|
|
{
|
|
private static final String[] grassTypes = new String[] { "slimegrass_blue_tall" };
|
|
@SideOnly(Side.CLIENT)
|
|
private IIcon[] iconArray;
|
|
|
|
public SlimeTallGrass()
|
|
{
|
|
super(Material.field_151582_l);
|
|
float f = 0.4F;
|
|
this.func_149676_a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
|
|
func_149647_a(TConstructRegistry.blockTab);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
/**
|
|
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
|
*/
|
|
public IIcon getIcon (int side, int meta)
|
|
{
|
|
/*if (meta >= this.iconArray.length)
|
|
{
|
|
meta = 0;
|
|
}*/
|
|
|
|
return this.iconArray[meta];
|
|
}
|
|
|
|
/**
|
|
* Returns the ID of the items to drop on destruction.
|
|
*/
|
|
public int idDropped (int par1, Random par2Random, int par3)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
|
|
*/
|
|
public int quantityDroppedWithBonus (int par1, Random par2Random)
|
|
{
|
|
return 1 + par2Random.nextInt(par1 * 2 + 1);
|
|
}
|
|
|
|
/**
|
|
* Get the block's damage value (for use with pick block).
|
|
*/
|
|
public int getDamageValue (World par1World, int par2, int par3, int par4)
|
|
{
|
|
return par1World.getBlockMetadata(par2, par3, par4);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
/**
|
|
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
|
*/
|
|
public void getSubBlocks (Block b, CreativeTabs par2CreativeTabs, List par3List)
|
|
{
|
|
for (int j = 0; j < 1; ++j)
|
|
{
|
|
par3List.add(new ItemStack(b, 1, j));
|
|
}
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
/**
|
|
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
|
* is the only chance you get to register icons.
|
|
*/
|
|
public void registerIcons (IIconRegister par1IconRegister)
|
|
{
|
|
this.iconArray = new IIcon[grassTypes.length];
|
|
|
|
for (int i = 0; i < this.iconArray.length; ++i)
|
|
{
|
|
this.iconArray[i] = par1IconRegister.registerIcon("tinker:" + grassTypes[i]);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<ItemStack> getDrops (World world, int x, int y, int z, int meta, int fortune)
|
|
{
|
|
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
|
if (world.rand.nextInt(8) != 0)
|
|
{
|
|
return ret;
|
|
}
|
|
|
|
ItemStack item = ForgeHooks.getGrassSeed(world);
|
|
if (item != null)
|
|
{
|
|
ret.add(item);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean isShearable (ItemStack item, IBlockAccess world, int x, int y, int z)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<ItemStack> onSheared (ItemStack item, IBlockAccess 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;
|
|
}
|
|
}
|