/// <summary> /// 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 ! /// </summary> public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (par1ItemStack.StackSize == 0) { return(false); } if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6)) { return(false); } int i = par3World.GetBlockId(par4, par5, par6); int j = par3World.GetBlockMetadata(par4, par5, par6); int k = j & 7; bool flag = (j & 8) != 0; if ((par7 == 1 && !flag || par7 == 0 && flag) && i == Block.StairSingle.BlockID && k == par1ItemStack.GetItemDamage()) { if (par3World.CheckIfAABBIsClear(Block.StairDouble.GetCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, Block.StairDouble.BlockID, k)) { par3World.PlaySoundEffect((float)par4 + 0.5F, (float)par5 + 0.5F, (float)par6 + 0.5F, Block.StairDouble.StepSound.GetStepSound(), (Block.StairDouble.StepSound.GetVolume() + 1.0F) / 2.0F, Block.StairDouble.StepSound.GetPitch() * 0.8F); par1ItemStack.StackSize--; } return(true); } if (Func_50087_b(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7)) { return(true); } else { return(base.OnItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7)); } }
/// <summary> /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer /// </summary> public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { float f = 1.0F; double d = par3EntityPlayer.PrevPosX + (par3EntityPlayer.PosX - par3EntityPlayer.PrevPosX) * (double)f; double d1 = (par3EntityPlayer.PrevPosY + (par3EntityPlayer.PosY - par3EntityPlayer.PrevPosY) * (double)f + 1.6200000000000001D) - (double)par3EntityPlayer.YOffset; double d2 = par3EntityPlayer.PrevPosZ + (par3EntityPlayer.PosZ - par3EntityPlayer.PrevPosZ) * (double)f; bool flag = IsFull == 0; MovingObjectPosition movingobjectposition = GetMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, flag); if (movingobjectposition == null) { return(par1ItemStack); } if (movingobjectposition.TypeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.BlockX; int j = movingobjectposition.BlockY; int k = movingobjectposition.BlockZ; if (!par2World.CanMineBlock(par3EntityPlayer, i, j, k)) { return(par1ItemStack); } if (IsFull == 0) { if (!par3EntityPlayer.CanPlayerEdit(i, j, k)) { return(par1ItemStack); } if (par2World.GetBlockMaterial(i, j, k) == Material.Water && par2World.GetBlockMetadata(i, j, k) == 0) { par2World.SetBlockWithNotify(i, j, k, 0); if (par3EntityPlayer.Capabilities.IsCreativeMode) { return(par1ItemStack); } else { return(new ItemStack(Item.BucketWater)); } } if (par2World.GetBlockMaterial(i, j, k) == Material.Lava && par2World.GetBlockMetadata(i, j, k) == 0) { par2World.SetBlockWithNotify(i, j, k, 0); if (par3EntityPlayer.Capabilities.IsCreativeMode) { return(par1ItemStack); } else { return(new ItemStack(Item.BucketLava)); } } } else { if (IsFull < 0) { return(new ItemStack(Item.BucketEmpty)); } if (movingobjectposition.SideHit == 0) { j--; } if (movingobjectposition.SideHit == 1) { j++; } if (movingobjectposition.SideHit == 2) { k--; } if (movingobjectposition.SideHit == 3) { k++; } if (movingobjectposition.SideHit == 4) { i--; } if (movingobjectposition.SideHit == 5) { i++; } if (!par3EntityPlayer.CanPlayerEdit(i, j, k)) { return(par1ItemStack); } if (par2World.IsAirBlock(i, j, k) || !par2World.GetBlockMaterial(i, j, k).IsSolid()) { if (par2World.WorldProvider.IsHellWorld && IsFull == Block.WaterMoving.BlockID) { par2World.PlaySoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (par2World.Rand.NextFloat() - par2World.Rand.NextFloat()) * 0.8F); for (int l = 0; l < 8; l++) { par2World.SpawnParticle("largesmoke", (double)i + (new Random(1)).NextDouble(), (double)j + new Random(2).NextDouble(), (double)k + new Random(3).NextDouble(), 0.0F, 0.0F, 0.0F); } } else { par2World.SetBlockAndMetadataWithNotify(i, j, k, IsFull, 0); } if (par3EntityPlayer.Capabilities.IsCreativeMode) { return(par1ItemStack); } else { return(new ItemStack(Item.BucketEmpty)); } } } } else if (IsFull == 0 && (movingobjectposition.EntityHit is EntityCow)) { return(new ItemStack(Item.BucketMilk)); } return(par1ItemStack); }
/// <summary> /// 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 ! /// </summary> public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6)) { return(false); } if (par1ItemStack.GetItemDamage() == 15) { int i = par3World.GetBlockId(par4, par5, par6); if (i == Block.Sapling.BlockID) { if (!par3World.IsRemote) { ((BlockSapling)Block.Sapling).GrowTree(par3World, par4, par5, par6, par3World.Rand); par1ItemStack.StackSize--; } return(true); } if (i == Block.MushroomBrown.BlockID || i == Block.MushroomRed.BlockID) { if (!par3World.IsRemote && ((BlockMushroom)Block.BlocksList[i]).FertilizeMushroom(par3World, par4, par5, par6, par3World.Rand)) { par1ItemStack.StackSize--; } return(true); } if (i == Block.MelonStem.BlockID || i == Block.PumpkinStem.BlockID) { if (!par3World.IsRemote) { ((BlockStem)Block.BlocksList[i]).FertilizeStem(par3World, par4, par5, par6); par1ItemStack.StackSize--; } return(true); } if (i == Block.Crops.BlockID) { if (!par3World.IsRemote) { ((BlockCrops)Block.Crops).Fertilize(par3World, par4, par5, par6); par1ItemStack.StackSize--; } return(true); } if (i == Block.Grass.BlockID) { if (!par3World.IsRemote) { par1ItemStack.StackSize--; label0: for (int j = 0; j < 128; j++) { int k = par4; int l = par5 + 1; int i1 = par6; for (int j1 = 0; j1 < j / 16; j1++) { k += ItemRand.Next(3) - 1; l += ((ItemRand.Next(3) - 1) * ItemRand.Next(3)) / 2; i1 += ItemRand.Next(3) - 1; if (par3World.GetBlockId(k, l - 1, i1) != Block.Grass.BlockID || par3World.IsBlockNormalCube(k, l, i1)) { goto label0; } } if (par3World.GetBlockId(k, l, i1) != 0) { continue; } if (ItemRand.Next(10) != 0) { par3World.SetBlockAndMetadataWithNotify(k, l, i1, Block.TallGrass.BlockID, 1); continue; } if (ItemRand.Next(3) != 0) { par3World.SetBlockWithNotify(k, l, i1, Block.PlantYellow.BlockID); } else { par3World.SetBlockWithNotify(k, l, i1, Block.PlantRed.BlockID); } } } return(true); } } return(false); }