Beispiel #1
0
 public override bool IsItemValid(net.minecraft.src.ItemStack itemstack)
 {
     if (itemstack.GetItem() is net.minecraft.src.ItemArmor)
     {
         return(((net.minecraft.src.ItemArmor)itemstack.GetItem()).armorType == field_20102_a);
     }
     if (itemstack.GetItem().ID == net.minecraft.src.Block.PUMPKIN.ID)
     {
         return(field_20102_a == 0);
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
0
        private int GetItemBurnTime(net.minecraft.src.ItemStack itemstack)
        {
            if (itemstack == null)
            {
                return(0);
            }
            int i = itemstack.GetItem().ID;

            if (i < 256 && net.minecraft.src.Block.blocksList[i].blockMaterial == net.minecraft.src.Material
                .wood)
            {
                return(300);
            }
            if (i == net.minecraft.src.Item.STICK.ID)
            {
                return(100);
            }
            if (i == net.minecraft.src.Item.COAL.ID)
            {
                return(1600);
            }
            if (i == net.minecraft.src.Item.LAVA_BUCKET.ID)
            {
                return(20000);
            }
            return(i != net.minecraft.src.Block.SAPLING.ID ? 0 : 100);
        }
 public virtual void ReadFromNBT(net.minecraft.src.NBTTagList nbttaglist)
 {
     mainInventory  = new net.minecraft.src.ItemStack[36];
     armorInventory = new net.minecraft.src.ItemStack[4];
     for (int i = 0; i < nbttaglist.TagCount(); i++)
     {
         net.minecraft.src.NBTTagCompound nbttagcompound = (net.minecraft.src.NBTTagCompound
                                                            )nbttaglist.TagAt(i);
         int j = nbttagcompound.GetByte("Slot");
         net.minecraft.src.ItemStack itemstack = new net.minecraft.src.ItemStack(nbttagcompound
                                                                                 );
         if (itemstack.GetItem() == null)
         {
             continue;
         }
         if (j >= 0 && j < mainInventory.Length)
         {
             mainInventory[j] = itemstack;
         }
         if (j >= 100 && j < armorInventory.Length + 100)
         {
             armorInventory[j - 100] = itemstack;
         }
     }
 }
Beispiel #4
0
        /// <exception cref="System.IO.IOException"/>
        private static void WriteWatchableObject(java.io.DataOutputStream dataoutputstream, net.minecraft.src.WatchableObject watchableobject)
        {
            int i = (watchableobject.GetObjectType() << 5 | watchableobject.GetDataValueId()
                     & 0x1f) & 0xff;

            dataoutputstream.WriteByte(i);
            switch (watchableobject.GetObjectType())
            {
            case 0:
            {
                // '\0'
                dataoutputstream.WriteByte(((byte)watchableobject.GetObject()));
                break;
            }

            case 1:
            {
                // '\001'
                dataoutputstream.WriteShort(((short)watchableobject.GetObject()));
                break;
            }

            case 2:
            {
                // '\002'
                dataoutputstream.WriteInt(((int)watchableobject.GetObject()));
                break;
            }

            case 3:
            {
                // '\003'
                dataoutputstream.WriteFloat(((float)watchableobject.GetObject()));
                break;
            }

            case 4:
            {
                // '\004'
                net.minecraft.src.Packet.WriteString((string)watchableobject.GetObject(), dataoutputstream
                                                     );
                break;
            }

            case 5:
            {
                // '\005'
                net.minecraft.src.ItemStack itemstack = (net.minecraft.src.ItemStack)watchableobject
                                                        .GetObject();
                dataoutputstream.WriteShort(itemstack.GetItem().ID);
                dataoutputstream.WriteByte(itemstack.stackSize);
                dataoutputstream.WriteShort(itemstack.GetItemDamage());
                break;
            }

            case 6:
            {
                // '\006'
                net.minecraft.src.ChunkCoordinates chunkcoordinates = (net.minecraft.src.ChunkCoordinates
                                                                       )watchableobject.GetObject();
                dataoutputstream.WriteInt(chunkcoordinates.posX);
                dataoutputstream.WriteInt(chunkcoordinates.posY);
                dataoutputstream.WriteInt(chunkcoordinates.posZ);
                break;
            }
            }
        }
Beispiel #5
0
 public override void OnPickupFromSlot(net.minecraft.src.ItemStack itemstack)
 {
     itemstack.AddCraftStatistic(field_25004_e.worldObj, field_25004_e);
     if (itemstack.itemID == net.minecraft.src.Block.WORKBENCH.ID)
     {
         field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildWorkBench, 1);
     }
     else
     {
         if (itemstack.itemID == net.minecraft.src.Item.WOOD_PICKAXE.ID)
         {
             field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildPickaxe, 1);
         }
         else
         {
             if (itemstack.itemID == net.minecraft.src.Block.FURNACE.ID)
             {
                 field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildFurnace, 1);
             }
             else
             {
                 if (itemstack.itemID == net.minecraft.src.Item.WOOD_HOE.ID)
                 {
                     field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildHoe, 1);
                 }
                 else
                 {
                     if (itemstack.itemID == net.minecraft.src.Item.BREAD.ID)
                     {
                         field_25004_e.AddStat(net.minecraft.src.AchievementList.aMakeBreak, 1);
                     }
                     else
                     {
                         if (itemstack.itemID == net.minecraft.src.Item.CAKE.ID)
                         {
                             field_25004_e.AddStat(net.minecraft.src.AchievementList.aBakeCake, 1);
                         }
                         else
                         {
                             if (itemstack.itemID == net.minecraft.src.Item.STONE_PICKAXE.ID)
                             {
                                 field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildBetterPickaxe, 1);
                             }
                             else
                             {
                                 if (itemstack.itemID == net.minecraft.src.Item.WOOD_SWORD.ID)
                                 {
                                     field_25004_e.AddStat(net.minecraft.src.AchievementList.aBuildSword, 1);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     for (int i = 0; i < craftMatrix.GetSizeInventory(); i++)
     {
         net.minecraft.src.ItemStack itemstack1 = craftMatrix.GetStackInSlot(i);
         if (itemstack1 == null)
         {
             continue;
         }
         craftMatrix.DecrStackSize(i, 1);
         if (itemstack1.GetItem().HasContainerItem())
         {
             craftMatrix.SetInventorySlotContents(i, new net.minecraft.src.ItemStack(itemstack1
                                                                                     .GetItem().GetContainerItem()));
         }
     }
 }
Beispiel #6
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (field_6149_an > 0)
            {
                double d  = posX + (field_6148_ao - posX) / (double)field_6149_an;
                double d1 = posY + (field_6147_ap - posY) / (double)field_6149_an;
                double d2 = posZ + (field_6146_aq - posZ) / (double)field_6149_an;
                double d4;
                for (d4 = field_6145_ar - (double)rotationYaw; d4 < -180D; d4 += 360D)
                {
                }
                for (; d4 >= 180D; d4 -= 360D)
                {
                }
                rotationYaw   += (float)(d4 / (double)field_6149_an);
                rotationPitch += (float)((field_6144_as - (double)rotationPitch) / (double)field_6149_an);
                field_6149_an--;
                SetPosition(d, d1, d2);
                SetRotation(rotationYaw, rotationPitch);
                return;
            }
            if (!worldObj.singleplayerWorld)
            {
                net.minecraft.src.ItemStack itemstack = angler.GetCurrentEquippedItem();
                if (angler.isDead || !angler.IsEntityAlive() || itemstack == null || itemstack.GetItem
                        () != net.minecraft.src.Item.FISHING_ROD || GetDistanceSqToEntity(angler) > 1024D)
                {
                    SetEntityDead();
                    angler.fishEntity = null;
                    return;
                }
                if (bobber != null)
                {
                    if (bobber.isDead)
                    {
                        bobber = null;
                    }
                    else
                    {
                        posX = bobber.posX;
                        posY = bobber.boundingBox.minY + (double)bobber.height * 0.80000000000000004D;
                        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)
                    {
                        SetEntityDead();
                    }
                    return;
                }
            }
            else
            {
                ticksInAir++;
            }
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY,
                                                                                 posZ);
            net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX
                                                                                  , posY + motionY, posZ + motionZ);
            net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.RayTraceBlocks
                                                                              (vec3d, vec3d1);
            vec3d  = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ);
            vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ
                                                          + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord,
                                                              movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
            }
            net.minecraft.src.Entity entity = null;
            System.Collections.Generic.List <Entity> list = worldObj.GetEntitiesWithinAABBExcludingEntity(this
                                                                                                          , boundingBox.AddCoord(motionX, motionY, motionZ).Expand(1.0D, 1.0D, 1.0D));
            double d3 = 0.0D;

            for (int j = 0; j < list.Count; j++)
            {
                net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[j];
                if (!entity1.CanBeCollidedWith() || entity1 == angler && ticksInAir < 5)
                {
                    continue;
                }
                float f2 = 0.3F;
                net.minecraft.src.AxisAlignedBB axisalignedbb = entity1.boundingBox.Expand(f2, f2
                                                                                           , f2);
                net.minecraft.src.MovingObjectPosition movingobjectposition1 = axisalignedbb.Func_706_a
                                                                                   (vec3d, vec3d1);
                if (movingobjectposition1 == null)
                {
                    continue;
                }
                double d6 = vec3d.DistanceTo(movingobjectposition1.hitVec);
                if (d6 < d3 || d3 == 0.0D)
                {
                    entity = entity1;
                    d3     = d6;
                }
            }
            if (entity != null)
            {
                movingobjectposition = new net.minecraft.src.MovingObjectPosition(entity);
            }
            if (movingobjectposition != null)
            {
                if (movingobjectposition.entityHit != null)
                {
                    if (movingobjectposition.entityHit.AttackEntityFrom(angler, 0))
                    {
                        bobber = movingobjectposition.entityHit;
                    }
                }
                else
                {
                    inGround = true;
                }
            }
            if (inGround)
            {
                return;
            }
            MoveEntity(motionX, motionY, motionZ);
            float f = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ *
                                                               motionZ);

            rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D
                                  );
            for (rotationPitch = (float)((System.Math.Atan2(motionY, f) * 180D) / 3.1415927410125732D
                                         ); 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;
            double d5 = 0.0D;

            for (int l = 0; l < k; l++)
            {
                double d8 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double
                                                                                           )(l + 0)) / (double)k) - 0.125D) + 0.125D;
                double d9 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double
                                                                                           )(l + 1)) / (double)k) - 0.125D) + 0.125D;
                net.minecraft.src.AxisAlignedBB axisalignedbb1 = net.minecraft.src.AxisAlignedBB.
                                                                 GetBoundingBoxFromPool(boundingBox.minX, d8, boundingBox.minZ, boundingBox.maxX,
                                                                                        d9, boundingBox.maxZ);
                if (worldObj.IsAABBInMaterial(axisalignedbb1, net.minecraft.src.Material.water))
                {
                    d5 += 1.0D / (double)k;
                }
            }
            if (d5 > 0.0D)
            {
                if (ticksCatchable > 0)
                {
                    ticksCatchable--;
                }
                else
                {
                    char c = '\u01F4';
                    if (worldObj.CanLightningStrikeAt(net.minecraft.src.MathHelper.Floor_double(posX)
                                                      , net.minecraft.src.MathHelper.Floor_double(posY) + 1, net.minecraft.src.MathHelper
                                                      .Floor_double(posZ)))
                    {
                        c = '\u012C';
                    }
                    if (rand.Next(c) == 0)
                    {
                        ticksCatchable = rand.Next(30) + 10;
                        motionY       -= 0.20000000298023224D;
                        worldObj.PlaySoundAtEntity(this, "random.splash", 0.25F, 1.0F + (rand.NextFloat()
                                                                                         - rand.NextFloat()) * 0.4F);
                        float f3 = net.minecraft.src.MathHelper.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 + (double)f4, f3 + 1.0F, posZ + (double)f6,
                                                   motionX, motionY - (double)(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 + (double)f5, f3 + 1.0F, posZ + (double)f7,
                                                   motionX, motionY, motionZ);
                        }
                    }
                }
            }
            if (ticksCatchable > 0)
            {
                motionY -= (double)(rand.NextFloat() * rand.NextFloat() * rand.NextFloat()) * 0.20000000000000001D;
            }
            double d7 = d5 * 2D - 1.0D;

            motionY += 0.039999999105930328D * d7;
            if (d5 > 0.0D)
            {
                f1       = (float)((double)f1 * 0.90000000000000002D);
                motionY *= 0.80000000000000004D;
            }
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            SetPosition(posX, posY, posZ);
        }