Exemplo n.º 1
0
        /// <summary>
        /// Called when the throwable hits a block or entity.
        /// </summary>
        protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition)
        {
            if (par1MovingObjectPosition.EntityHit != null)
            {
                if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), 0))
                {
                    ;
                }
            }

            for (int i = 0; i < 32; i++)
            {
                WorldObj.SpawnParticle("portal", PosX, PosY + Rand.NextFloat() * 2, PosZ, Rand.NextGaussian(), 0.0F, Rand.NextGaussian());
            }

            if (!WorldObj.IsRemote)
            {
                if (Thrower != null)
                {
                    Thrower.SetPositionAndUpdate(PosX, PosY, PosZ);
                    Thrower.FallDistance = 0.0F;
                    Thrower.AttackEntityFrom(DamageSource.Fall, 5);
                }

                SetDead();
            }
        }
        /// <summary>
        /// Called when the throwable hits a block or entity.
        /// </summary>
        protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition)
        {
            if (par1MovingObjectPosition.EntityHit != null)
            {
                sbyte byte0 = 0;

                if (par1MovingObjectPosition.EntityHit is EntityBlaze)
                {
                    byte0 = 3;
                }

                if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), byte0))
                {
                    ;
                }
            }

            for (int i = 0; i < 8; i++)
            {
                WorldObj.SpawnParticle("snowballpoof", PosX, PosY, PosZ, 0.0F, 0.0F, 0.0F);
            }

            if (!WorldObj.IsRemote)
            {
                SetDead();
            }
        }
        /// <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)
        {
            MovingObjectPosition movingobjectposition = GetMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);

            if (movingobjectposition != null && movingobjectposition.TypeOfHit == EnumMovingObjectType.TILE)
            {
                int i = par2World.GetBlockId(movingobjectposition.BlockX, movingobjectposition.BlockY, movingobjectposition.BlockZ);

                if (i == Block.EndPortalFrame.BlockID)
                {
                    return(par1ItemStack);
                }
            }

            if (!par2World.IsRemote)
            {
                ChunkPosition chunkposition = par2World.FindClosestStructure("Stronghold", (int)par3EntityPlayer.PosX, (int)par3EntityPlayer.PosY, (int)par3EntityPlayer.PosZ);

                if (chunkposition != null)
                {
                    EntityEnderEye entityendereye = new EntityEnderEye(par2World, par3EntityPlayer.PosX, (par3EntityPlayer.PosY + 1.6200000000000001F) - par3EntityPlayer.YOffset, par3EntityPlayer.PosZ);
                    entityendereye.Func_40090_a(chunkposition.x, chunkposition.y, chunkposition.z);
                    par2World.SpawnEntityInWorld(entityendereye);
                    par2World.PlaySoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (ItemRand.NextFloat() * 0.4F + 0.8F));
                    par2World.PlayAuxSFXAtEntity(null, 1002, (int)par3EntityPlayer.PosX, (int)par3EntityPlayer.PosY, (int)par3EntityPlayer.PosZ, 0);

                    if (!par3EntityPlayer.Capabilities.IsCreativeMode)
                    {
                        par1ItemStack.StackSize--;
                    }
                }
            }

            return(par1ItemStack);
        }
Exemplo n.º 4
0
        protected override void Func_40071_a(MovingObjectPosition par1MovingObjectPosition)
        {
            if (!WorldObj.IsRemote)
            {
                if (par1MovingObjectPosition.EntityHit != null)
                {
                    if (!par1MovingObjectPosition.EntityHit.IsImmuneToFire() && par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseFireballDamage(this, ShootingEntity), 5))
                    {
                        par1MovingObjectPosition.EntityHit.SetFire(5);
                    }
                }
                else
                {
                    int i = par1MovingObjectPosition.BlockX;
                    int j = par1MovingObjectPosition.BlockY;
                    int k = par1MovingObjectPosition.BlockZ;

                    switch (par1MovingObjectPosition.SideHit)
                    {
                    case 1:
                        j++;
                        break;

                    case 0:
                        j--;
                        break;

                    case 2:
                        k--;
                        break;

                    case 3:
                        k++;
                        break;

                    case 5:
                        i++;
                        break;

                    case 4:
                        i--;
                        break;
                    }

                    if (WorldObj.IsAirBlock(i, j, k))
                    {
                        WorldObj.SetBlockWithNotify(i, j, k, Block.Fire.BlockID);
                    }
                }

                SetDead();
            }
        }
Exemplo n.º 5
0
        /// <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)
        {
            MovingObjectPosition movingobjectposition = GetMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

            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 (!par3EntityPlayer.CanPlayerEdit(i, j, k))
                {
                    return(par1ItemStack);
                }

                if (par2World.GetBlockMaterial(i, j, k) == Material.Water)
                {
                    par1ItemStack.StackSize--;

                    if (par1ItemStack.StackSize <= 0)
                    {
                        return(new ItemStack(Item.Potion));
                    }

                    if (!par3EntityPlayer.Inventory.AddItemStackToInventory(new ItemStack(Item.Potion)))
                    {
                        par3EntityPlayer.DropPlayerItem(new ItemStack(Item.Potion.ShiftedIndex, 1, 0));
                    }
                }
            }

            return(par1ItemStack);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Called when the throwable hits a block or entity.
        /// </summary>
        protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition)
        {
            if (par1MovingObjectPosition.EntityHit != null)
            {
                if (!par1MovingObjectPosition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Thrower), 0))
                {
                    ;
                }
            }

            if (!WorldObj.IsRemote && Rand.Next(8) == 0)
            {
                sbyte byte0 = 1;

                if (Rand.Next(32) == 0)
                {
                    byte0 = 4;
                }

                for (int j = 0; j < byte0; j++)
                {
                    EntityChicken entitychicken = new EntityChicken(WorldObj);
                    entitychicken.SetGrowingAge(-24000);
                    entitychicken.SetLocationAndAngles(PosX, PosY, PosZ, RotationYaw, 0.0F);
                    WorldObj.SpawnEntityInWorld(entitychicken);
                }
            }

            for (int i = 0; i < 8; i++)
            {
                WorldObj.SpawnParticle("snowballpoof", PosX, PosY, PosZ, 0.0F, 0.0F, 0.0F);
            }

            if (!WorldObj.IsRemote)
            {
                SetDead();
            }
        }
Exemplo n.º 7
0
        public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
        {
            float  f  = 1.0F;
            float  f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f;
            float  f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f;
            double d  = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * f +
                         1.6200000000000001D) - entityplayer.yOffset;
            double d2     = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * f;
            Vec3D  vec3d  = Vec3D.createVector(d, d1, d2);
            float  f3     = MathHelper.cos(-f2 * 0.01745329F - 3.141593F);
            float  f4     = MathHelper.sin(-f2 * 0.01745329F - 3.141593F);
            float  f5     = -MathHelper.cos(-f1 * 0.01745329F);
            float  f6     = MathHelper.sin(-f1 * 0.01745329F);
            float  f7     = f4 * f5;
            float  f8     = f6;
            float  f9     = f3 * f5;
            double d3     = 5D;
            Vec3D  vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
            MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, true);

            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.singleplayerWorld)
                {
                    world.entityJoinedWorld(new EntityBoat(world, i + 0.5F, j + 1.5F, k + 0.5F));
                }
                itemstack.stackSize--;
            }
            return(itemstack);
        }
Exemplo n.º 8
0
        /// <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)
        {
            MovingObjectPosition movingobjectposition = GetMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

            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 (!par3EntityPlayer.CanPlayerEdit(i, j, k))
                {
                    return(par1ItemStack);
                }

                if (par2World.GetBlockMaterial(i, j, k) == Material.Water && par2World.GetBlockMetadata(i, j, k) == 0 && par2World.IsAirBlock(i, j + 1, k))
                {
                    par2World.SetBlockWithNotify(i, j + 1, k, Block.Waterlily.BlockID);

                    if (!par3EntityPlayer.Capabilities.IsCreativeMode)
                    {
                        par1ItemStack.StackSize--;
                    }
                }
            }

            return(par1ItemStack);
        }