static EntityPigZombie()
 {
     DefaultHeldItem = new ItemStack(Item.SwordGold, 1);
 }
Ejemplo n.º 2
0
        public override string GetItemNameIS(ItemStack par1ItemStack)
        {
            int i = MathHelper2.Clamp_int(par1ItemStack.GetItemDamage(), 0, 15);

            return((new StringBuilder()).Append(base.GetItemName()).Append(".").Append(DyeColorNames[i]).ToString());
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Abstract. Reads the raw packet data from the data stream.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void readPacketData(BinaryReader par1NetworkStream) throws IOException
        public override void ReadPacketData(BinaryReader par1NetworkStream)
        {
            Slot      = par1NetworkStream.ReadInt16();
            ItemStack = ReadItemStack(par1NetworkStream);
        }
Ejemplo n.º 5
0
 public Packet107CreativeSetSlot(int par1, ItemStack par2ItemStack)
 {
     Slot      = par1;
     ItemStack = par2ItemStack;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (FishPosRotationIncrements > 0)
            {
                float  d  = PosX + (FishX - PosX) / FishPosRotationIncrements;
                float  d1 = PosY + (FishY - PosY) / FishPosRotationIncrements;
                float  d2 = PosZ + (FishZ - PosZ) / FishPosRotationIncrements;
                double d4;

                for (d4 = FishYaw - RotationYaw; d4 < -180D; d4 += 360D)
                {
                }

                for (; d4 >= 180D; d4 -= 360D)
                {
                }

                RotationYaw   += (float)d4 / FishPosRotationIncrements;
                RotationPitch += (float)(FishPitch - RotationPitch) / FishPosRotationIncrements;
                FishPosRotationIncrements--;
                SetPosition(d, d1, d2);
                SetRotation(RotationYaw, RotationPitch);
                return;
            }

            if (!WorldObj.IsRemote)
            {
                ItemStack itemstack = Angler.GetCurrentEquippedItem();

                if (Angler.IsDead || !Angler.IsEntityAlive() || itemstack == null || itemstack.GetItem() != Item.FishingRod || GetDistanceSqToEntity(Angler) > 1024D)
                {
                    SetDead();
                    Angler.FishEntity = null;
                    return;
                }

                if (Bobber != null)
                {
                    if (Bobber.IsDead)
                    {
                        Bobber = null;
                    }
                    else
                    {
                        PosX = Bobber.PosX;
                        PosY = Bobber.BoundingBox.MinY + Bobber.Height * 0.80000000000000004F;
                        PosZ = Bobber.PosZ;
                        return;
                    }
                }
            }

            if (Shake > 0)
            {
                Shake--;
            }

            if (InGround)
            {
                int i = WorldObj.GetBlockId(XTile, YTile, ZTile);

                if (i != InTile)
                {
                    InGround      = false;
                    MotionX      *= Rand.NextFloat() * 0.2F;
                    MotionY      *= Rand.NextFloat() * 0.2F;
                    MotionZ      *= Rand.NextFloat() * 0.2F;
                    TicksInGround = 0;
                    TicksInAir    = 0;
                }
                else
                {
                    TicksInGround++;

                    if (TicksInGround == 1200)
                    {
                        SetDead();
                    }

                    return;
                }
            }
            else
            {
                TicksInAir++;
            }

            Vec3D vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);
            MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);

            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.CreateVector(movingobjectposition.HitVec.XCoord, movingobjectposition.HitVec.YCoord, movingobjectposition.HitVec.ZCoord);
            }

            Entity        entity = null;
            List <Entity> list   = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F));
            double        d3     = 0.0F;

            for (int j = 0; j < list.Count; j++)
            {
                Entity entity1 = list[j];

                if (!entity1.CanBeCollidedWith() || entity1 == Angler && TicksInAir < 5)
                {
                    continue;
                }

                float                f2                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.BoundingBox.Expand(f2, f2, f2);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.CalculateIntercept(vec3d, vec3d1);

                if (movingobjectposition1 == null)
                {
                    continue;
                }

                double d6 = vec3d.DistanceTo(movingobjectposition1.HitVec);

                if (d6 < d3 || d3 == 0.0F)
                {
                    entity = entity1;
                    d3     = d6;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }

            if (movingobjectposition != null)
            {
                if (movingobjectposition.EntityHit != null)
                {
                    if (movingobjectposition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Angler), 0))
                    {
                        Bobber = movingobjectposition.EntityHit;
                    }
                }
                else
                {
                    InGround = true;
                }
            }

            if (InGround)
            {
                return;
            }

            MoveEntity(MotionX, MotionY, MotionZ);
            float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

            RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);

            for (RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI); RotationPitch - PrevRotationPitch < -180F; PrevRotationPitch -= 360F)
            {
            }

            for (; RotationPitch - PrevRotationPitch >= 180F; PrevRotationPitch += 360F)
            {
            }

            for (; RotationYaw - PrevRotationYaw < -180F; PrevRotationYaw -= 360F)
            {
            }

            for (; RotationYaw - PrevRotationYaw >= 180F; PrevRotationYaw += 360F)
            {
            }

            RotationPitch = PrevRotationPitch + (RotationPitch - PrevRotationPitch) * 0.2F;
            RotationYaw   = PrevRotationYaw + (RotationYaw - PrevRotationYaw) * 0.2F;
            float f1 = 0.92F;

            if (OnGround || IsCollidedHorizontally)
            {
                f1 = 0.5F;
            }

            int   k  = 5;
            float d5 = 0.0F;

            for (int l = 0; l < k; l++)
            {
                float         d8             = ((BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (l + 0)) / k) - 0.125F) + 0.125F;
                float         d9             = ((BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (l + 1)) / k) - 0.125F) + 0.125F;
                AxisAlignedBB axisalignedbb1 = AxisAlignedBB.GetBoundingBoxFromPool(BoundingBox.MinX, d8, BoundingBox.MinZ, BoundingBox.MaxX, d9, BoundingBox.MaxZ);

                if (WorldObj.IsAABBInMaterial(axisalignedbb1, Material.Water))
                {
                    d5 += 1.0F / k;
                }
            }

            if (d5 > 0.0F)
            {
                if (TicksCatchable > 0)
                {
                    TicksCatchable--;
                }
                else
                {
                    int c = 500;

                    if (WorldObj.CanLightningStrikeAt(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY) + 1, MathHelper2.Floor_double(PosZ)))
                    {
                        c = 300;
                    }

                    if (Rand.Next(c) == 0)
                    {
                        TicksCatchable = Rand.Next(30) + 10;
                        MotionY       -= 0.20000000298023224F;
                        WorldObj.PlaySoundAtEntity(this, "random.splash", 0.25F, 1.0F + (Rand.NextFloat() - Rand.NextFloat()) * 0.4F);
                        float f3 = MathHelper2.Floor_double(BoundingBox.MinY);

                        for (int i1 = 0; (float)i1 < 1.0F + Width * 20F; i1++)
                        {
                            float f4 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            float f6 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            WorldObj.SpawnParticle("bubble", PosX + f4, f3 + 1.0F, PosZ + f6, MotionX, MotionY - (Rand.NextFloat() * 0.2F), MotionZ);
                        }

                        for (int j1 = 0; (float)j1 < 1.0F + Width * 20F; j1++)
                        {
                            float f5 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            float f7 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            WorldObj.SpawnParticle("splash", PosX + f5, f3 + 1.0F, PosZ + f7, MotionX, MotionY, MotionZ);
                        }
                    }
                }
            }

            if (TicksCatchable > 0)
            {
                MotionY -= (Rand.NextFloat() * Rand.NextFloat() * Rand.NextFloat()) * 0.20000000000000001F;
            }

            float d7 = d5 * 2F - 1.0F;

            MotionY += 0.039999999105930328F * d7;

            if (d5 > 0.0F)
            {
                f1       = (float)((double)f1 * 0.90000000000000002D);
                MotionY *= 0.80000000000000004F;
            }

            MotionX *= f1;
            MotionY *= f1;
            MotionZ *= f1;
            SetPosition(PosX, PosY, PosZ);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
        /// </summary>
        public override bool Interact(EntityPlayer par1EntityPlayer)
        {
            ItemStack itemstack = par1EntityPlayer.Inventory.GetCurrentItem();

            if (!IsTamed())
            {
                if (itemstack != null && itemstack.ItemID == Item.Bone.ShiftedIndex && !IsAngry())
                {
                    if (!par1EntityPlayer.Capabilities.IsCreativeMode)
                    {
                        itemstack.StackSize--;
                    }

                    if (itemstack.StackSize <= 0)
                    {
                        par1EntityPlayer.Inventory.SetInventorySlotContents(par1EntityPlayer.Inventory.CurrentItem, null);
                    }

                    if (!WorldObj.IsRemote)
                    {
                        if (Rand.Next(3) == 0)
                        {
                            SetTamed(true);
                            SetPathToEntity(null);
                            SetAttackTarget(null);
                            AiSit.Func_48407_a(true);
                            SetEntityHealth(20);
                            SetOwner(par1EntityPlayer.Username);
                            Func_48142_a(true);
                            WorldObj.SetEntityState(this, (sbyte)7);
                        }
                        else
                        {
                            Func_48142_a(false);
                            WorldObj.SetEntityState(this, (sbyte)6);
                        }
                    }

                    return(true);
                }
            }
            else
            {
                if (itemstack != null && (Item.ItemsList[itemstack.ItemID] is ItemFood))
                {
                    ItemFood itemfood = (ItemFood)Item.ItemsList[itemstack.ItemID];

                    if (itemfood.IsWolfsFavoriteMeat() && DataWatcher.GetWatchableObjectInt(18) < 20)
                    {
                        if (!par1EntityPlayer.Capabilities.IsCreativeMode)
                        {
                            itemstack.StackSize--;
                        }

                        Heal(itemfood.GetHealAmount());

                        if (itemstack.StackSize <= 0)
                        {
                            par1EntityPlayer.Inventory.SetInventorySlotContents(par1EntityPlayer.Inventory.CurrentItem, null);
                        }

                        return(true);
                    }
                }

                if (par1EntityPlayer.Username.ToUpper() == GetOwnerName().ToUpper() && !WorldObj.IsRemote && !IsWheat(itemstack))
                {
                    AiSit.Func_48407_a(!IsSitting());
                    IsJumping = false;
                    SetPathToEntity(null);
                }
            }

            return(base.Interact(par1EntityPlayer));
        }
        /// <summary>
        /// Draws the screen and all the components in it.
        /// </summary>
        public override void DrawScreen(int par1, int par2, float par3)
        {
            DrawDefaultBackground();
            int i = GuiLeft;
            int j = GuiTop;

            DrawGuiContainerBackgroundLayer(par3, par1, par2);
            RenderHelper.EnableGUIStandardItemLighting();
            //GL.PushMatrix();
            //GL.Translate(i, j, 0.0F);
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            //GL.Enable(EnableCap.RescaleNormal);
            Slot slot = null;
            int  k    = 240;
            int  i1   = 240;

            OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, (float)k / 1.0F, (float)i1 / 1.0F);
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);

            for (int l = 0; l < InventorySlots.InventorySlots.Count; l++)
            {
                Slot slot1 = (Slot)InventorySlots.InventorySlots[l];
                DrawSlotInventory(slot1);

                if (IsMouseOverSlot(slot1, par1, par2))
                {
                    slot = slot1;
                    //GL.Disable(EnableCap.Lighting);
                    //GL.Disable(EnableCap.DepthTest);
                    int j1 = slot1.XDisplayPosition;
                    int k1 = slot1.YDisplayPosition;
                    DrawGradientRect(j1, k1, j1 + 16, k1 + 16, 0x80fffff, 0x80fffff);
                    //GL.Enable(EnableCap.Lighting);
                    //GL.Enable(EnableCap.DepthTest);
                }
            }

            DrawGuiContainerForegroundLayer();
            InventoryPlayer inventoryplayer = Mc.ThePlayer.Inventory;

            if (inventoryplayer.GetItemStack() != null)
            {
                //GL.Translate(0.0F, 0.0F, 32F);
                ZLevel = 200F;
                ItemRenderer.ZLevel = 200F;
                ItemRenderer.RenderItemIntoGUI(FontRenderer, Mc.RenderEngineOld, inventoryplayer.GetItemStack(), par1 - i - 8, par2 - j - 8);
                ItemRenderer.RenderItemOverlayIntoGUI(FontRenderer, Mc.RenderEngineOld, inventoryplayer.GetItemStack(), par1 - i - 8, par2 - j - 8);
                ZLevel = 0.0F;
                ItemRenderer.ZLevel = 0.0F;
            }

            //GL.Disable(EnableCap.RescaleNormal);
            RenderHelper.DisableStandardItemLighting();
            //GL.Disable(EnableCap.Lighting);
            //GL.Disable(EnableCap.DepthTest);

            if (inventoryplayer.GetItemStack() == null && slot != null && slot.GetHasStack())
            {
                ItemStack     itemstack = slot.GetStack();
                List <string> list      = itemstack.GetItemNameandInformation();

                if (list.Count > 0)
                {
                    int l1 = 0;

                    for (int i2 = 0; i2 < list.Count; i2++)
                    {
                        int k2 = FontRenderer.GetStringWidth(list[i2]);

                        if (k2 > l1)
                        {
                            l1 = k2;
                        }
                    }

                    int j2 = (par1 - i) + 12;
                    int l2 = par2 - j - 12;
                    int i3 = l1;
                    int j3 = 8;

                    if (list.Count > 1)
                    {
                        j3 += 2 + (list.Count - 1) * 10;
                    }

                    ZLevel = 300F;
                    ItemRenderer.ZLevel = 300F;
                    int k3 = 0xf010001;
                    DrawGradientRect(j2 - 3, l2 - 4, j2 + i3 + 3, l2 - 3, k3, k3);
                    DrawGradientRect(j2 - 3, l2 + j3 + 3, j2 + i3 + 3, l2 + j3 + 4, k3, k3);
                    DrawGradientRect(j2 - 3, l2 - 3, j2 + i3 + 3, l2 + j3 + 3, k3, k3);
                    DrawGradientRect(j2 - 4, l2 - 3, j2 - 3, l2 + j3 + 3, k3, k3);
                    DrawGradientRect(j2 + i3 + 3, l2 - 3, j2 + i3 + 4, l2 + j3 + 3, k3, k3);
                    int l3 = 0x505000ff;
                    int i4 = (l3 & 0xfefefe) >> 1 | l3 & 0xff00000;
                    DrawGradientRect(j2 - 3, (l2 - 3) + 1, (j2 - 3) + 1, (l2 + j3 + 3) - 1, l3, i4);
                    DrawGradientRect(j2 + i3 + 2, (l2 - 3) + 1, j2 + i3 + 3, (l2 + j3 + 3) - 1, l3, i4);
                    DrawGradientRect(j2 - 3, l2 - 3, j2 + i3 + 3, (l2 - 3) + 1, l3, l3);
                    DrawGradientRect(j2 - 3, l2 + j3 + 2, j2 + i3 + 3, l2 + j3 + 3, i4, i4);

                    for (int j4 = 0; j4 < list.Count; j4++)
                    {
                        string s = list[j4];

                        if (j4 == 0)
                        {
                            //s = (new StringBuilder()).Append((char)0xa7).Append(int.ToHexString(itemstack.GetRarity().NameColor)).Append(s).ToString();
                        }
                        else
                        {
                            s = (new StringBuilder()).Append((char)0xa7).Append(s).ToString();
                        }

                        FontRenderer.DrawStringWithShadow(s, j2, l2, -1);

                        if (j4 == 0)
                        {
                            l2 += 2;
                        }

                        l2 += 10;
                    }

                    ZLevel = 0.0F;
                    ItemRenderer.ZLevel = 0.0F;
                }
            }

            //GL.PopMatrix();
            base.DrawScreen(par1, par2, par3);
            //GL.Enable(EnableCap.Lighting);
            //GL.Enable(EnableCap.DepthTest);
        }