2013-04-16 08:19:59 +00:00
|
|
|
package biomesoplenty.items;
|
2013-03-28 19:03:53 +00:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2013-03-30 10:54:53 +00:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-03-28 19:03:53 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class ItemCattail extends Item
|
|
|
|
{
|
|
|
|
/** The ID of the block the reed will spawn when used from inventory bar. */
|
|
|
|
private int spawnID;
|
|
|
|
|
|
|
|
public ItemCattail(int par1, Block par2Block)
|
|
|
|
{
|
|
|
|
super(par1);
|
|
|
|
this.spawnID = par2Block.blockID;
|
|
|
|
}
|
2013-03-30 10:54:53 +00:00
|
|
|
|
2013-04-16 23:34:18 +00:00
|
|
|
public void registerIcons(IconRegister iconRegister)
|
2013-03-30 10:54:53 +00:00
|
|
|
{
|
2013-04-16 23:34:18 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("BiomesOPlenty:cattail");
|
2013-03-30 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:03:53 +00:00
|
|
|
/**
|
|
|
|
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
|
|
|
|
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
|
|
|
|
*/
|
|
|
|
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
|
|
|
{
|
|
|
|
int var11 = par3World.getBlockId(par4, par5, par6);
|
|
|
|
|
|
|
|
if (var11 == Block.snow.blockID)
|
|
|
|
{
|
|
|
|
par7 = 1;
|
|
|
|
}
|
|
|
|
else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID)
|
|
|
|
{
|
|
|
|
if (par7 == 0)
|
|
|
|
{
|
|
|
|
--par5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par7 == 1)
|
|
|
|
{
|
|
|
|
++par5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par7 == 2)
|
|
|
|
{
|
|
|
|
--par6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par7 == 3)
|
|
|
|
{
|
|
|
|
++par6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par7 == 4)
|
|
|
|
{
|
|
|
|
--par4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par7 == 5)
|
|
|
|
{
|
|
|
|
++par4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (par1ItemStack.stackSize == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-30 10:54:53 +00:00
|
|
|
if (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity)null, par1ItemStack))
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
|
|
|
Block var12 = Block.blocksList[this.spawnID];
|
|
|
|
int var13 = var12.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0);
|
|
|
|
|
2013-03-30 10:54:53 +00:00
|
|
|
if (par3World.setBlock(par4, par5, par6, this.spawnID, var13, 2))
|
2013-03-28 19:03:53 +00:00
|
|
|
{
|
|
|
|
if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
|
|
|
|
{
|
2013-03-30 10:54:53 +00:00
|
|
|
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack);
|
2013-03-28 19:03:53 +00:00
|
|
|
Block.blocksList[this.spawnID].onPostBlockPlaced(par3World, par4, par5, par6, var13);
|
|
|
|
}
|
|
|
|
|
|
|
|
par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var12.stepSound.getPlaceSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F);
|
|
|
|
--par1ItemStack.stackSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|