Esempio n. 1
0
        private void TryToFall(net.minecraft.src.World world, int i, int j, int k)
        {
            int l  = i;
            int i1 = j;
            int j1 = k;

            if (CanFallBelow(world, l, i1 - 1, j1) && i1 >= 0)
            {
                byte byte0 = 32;
                if (fallInstantly || !world.CheckChunksExist(i - byte0, j - byte0, k - byte0, i +
                                                             byte0, j + byte0, k + byte0))
                {
                    world.SetBlockWithNotify(i, j, k, 0);
                    for (; CanFallBelow(world, i, j - 1, k) && j > 0; j--)
                    {
                    }
                    if (j > 0)
                    {
                        world.SetBlockWithNotify(i, j, k, ID);
                    }
                }
                else
                {
                    net.minecraft.src.EntityFallingSand entityfallingsand = new net.minecraft.src.EntityFallingSand
                                                                                (world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, ID);
                    world.AddEntity(entityfallingsand);
                }
            }
        }
Esempio n. 2
0
 public override void OnBlockDestroyedByExplosion(net.minecraft.src.World world, int
                                                  i, int j, int k)
 {
     net.minecraft.src.EntityTNTPrimed entitytntprimed = new net.minecraft.src.EntityTNTPrimed
                                                             (world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
     entitytntprimed.fuse = world.rand.Next(entitytntprimed.fuse / 4) + entitytntprimed
                            .fuse / 8;
     world.AddEntity(entitytntprimed);
 }
Esempio n. 3
0
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.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) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, true);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.singleplayerWorld)
                {
                    if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
                    {
                        j--;
                    }
                    world.AddEntity(new net.minecraft.src.EntityBoat(world, (float)i + 0.5F,
                                                                     (float)j + 1.0F, (float)k + 0.5F));
                }
                itemstack.stackSize--;
            }
            return(itemstack);
        }
Esempio n. 4
0
 public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                              )
 {
     itemstack.stackSize--;
     world.PlaySoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.NextFloat
                                                                           () * 0.4F + 0.8F));
     if (!world.singleplayerWorld)
     {
         world.AddEntity(new net.minecraft.src.EntityEgg(world, entityplayer));
     }
     return(itemstack);
 }
Esempio n. 5
0
 public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                              )
 {
     if (entityplayer.inventory.ConsumeInventoryItem(net.minecraft.src.Item.ARROW.ID
                                                     ))
     {
         world.PlaySoundAtEntity(entityplayer, "random.bow", 1.0F, 1.0F / (itemRand.NextFloat
                                                                               () * 0.4F + 0.8F));
         if (!world.singleplayerWorld)
         {
             world.AddEntity(new net.minecraft.src.EntityArrow(world, entityplayer));
         }
     }
     return(itemstack);
 }
Esempio n. 6
0
 public override void OnBlockRemoval(net.minecraft.src.World world, int i, int j,
                                     int k)
 {
     if (!field_28034_c)
     {
         net.minecraft.src.TileEntityFurnace tileentityfurnace = (net.minecraft.src.TileEntityFurnace)world.GetBlockTileEntity(i, j, k);
         if (tileentityfurnace == null)
         {
             return;                                            // CRAFTBUKKIT
         }
         for (int l = 0; l < tileentityfurnace.GetSizeInventory(); l++)
         {
             net.minecraft.src.ItemStack itemstack = tileentityfurnace.GetStackInSlot(l);
             if (itemstack == null)
             {
                 continue;
             }
             float f  = field_28033_a.NextFloat() * 0.8F + 0.1F;
             float f1 = field_28033_a.NextFloat() * 0.8F + 0.1F;
             float f2 = field_28033_a.NextFloat() * 0.8F + 0.1F;
             do
             {
                 if (itemstack.stackSize <= 0)
                 {
                     goto label0_continue;
                 }
                 int i1 = field_28033_a.Next(21) + 10;
                 if (i1 > itemstack.stackSize)
                 {
                     i1 = itemstack.stackSize;
                 }
                 itemstack.stackSize -= i1;
                 net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                            (float)i + f, (float)j + f1, (float)k + f2, new net.minecraft.src.ItemStack(itemstack
                                                                                                                                                                        .itemID, i1, itemstack.GetItemDamage()));
                 float f3 = 0.05F;
                 entityitem.motionX = (float)field_28033_a.NextGaussian() * f3;
                 entityitem.motionY = (float)field_28033_a.NextGaussian() * f3 + 0.2F;
                 entityitem.motionZ = (float)field_28033_a.NextGaussian() * f3;
                 world.AddEntity(entityitem);
             }while (true);
             label0_continue :;
         }
         label0_break :;
     }
     base.OnBlockRemoval(world, i, j, k);
 }
Esempio n. 7
0
        public override void HarvestBlock(net.minecraft.src.World world, net.minecraft.src.EntityPlayer
                                          entityplayer, int i, int j, int k, int l)
        {
            int    i1 = net.minecraft.src.Item.SNOW_BALL.ID;
            float  f  = 0.7F;
            double d  = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;

            net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                       (double)i + d, (double)j + d1, (double)k + d2, new net.minecraft.src.ItemStack(i1
                                                                                                                                                                      , 1, 0));
            entityitem.delayBeforeCanPickup = 10;
            world.AddEntity(entityitem);
            world.SetBlockWithNotify(i, j, k, 0);
            entityplayer.AddStat(net.minecraft.src.StatList.StatMinedBlocks[ID], 1);
        }
Esempio n. 8
0
 public override void OnBlockDestroyedByPlayer(net.minecraft.src.World world, int
                                               i, int j, int k, int l)
 {
     if (world.singleplayerWorld)
     {
         return;
     }
     if ((l & 1) == 0)
     {
         DropBlockAsItem_do(world, i, j, k, new net.minecraft.src.ItemStack(net.minecraft.src.Block
                                                                            .TNT.ID, 1, 0));
     }
     else
     {
         net.minecraft.src.EntityTNTPrimed entitytntprimed = new net.minecraft.src.EntityTNTPrimed
                                                                 (world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
         world.AddEntity(entitytntprimed);
         world.PlaySoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
     }
 }
Esempio n. 9
0
 protected internal virtual void DropBlockAsItem_do(net.minecraft.src.World world,
                                                    int i, int j, int k, net.minecraft.src.ItemStack itemstack)
 {
     if (world.singleplayerWorld)
     {
         return;
     }
     else
     {
         float  f  = 0.7F;
         double d  = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
         double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
         double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
         net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                    (double)i + d, (double)j + d1, (double)k + d2, itemstack);
         entityitem.delayBeforeCanPickup = 10;
         world.AddEntity(entityitem);
         return;
     }
 }
Esempio n. 10
0
        public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                       entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
        {
            int i1 = world.GetBlockId(i, j, k);

            if (net.minecraft.src.BlockRail.Func_27030_c(i1))
            {
                if (!world.singleplayerWorld)
                {
                    world.AddEntity(new net.minecraft.src.EntityMinecart(world, (float)i + 0.5F
                                                                         , (float)j + 0.5F, (float)k + 0.5F, minecartType));
                }
                itemstack.stackSize--;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
 public override void OnBlockRemoval(net.minecraft.src.World world, int i, int j,
                                     int k)
 {
     net.minecraft.src.TileEntityChest tileentitychest = (net.minecraft.src.TileEntityChest
                                                          )world.GetBlockTileEntity(i, j, k);
     for (int l = 0; l < tileentitychest.GetSizeInventory(); l++)
     {
         net.minecraft.src.ItemStack itemstack = tileentitychest.GetStackInSlot(l);
         if (itemstack == null)
         {
             continue;
         }
         float f  = ((float)random.NextDouble()) * 0.8F + 0.1F;
         float f1 = ((float)random.NextDouble()) * 0.8F + 0.1F;
         float f2 = ((float)random.NextDouble()) * 0.8F + 0.1F;
         do
         {
             if (itemstack.stackSize <= 0)
             {
                 goto label0_continue;
             }
             int i1 = random.Next(21) + 10;
             if (i1 > itemstack.stackSize)
             {
                 i1 = itemstack.stackSize;
             }
             itemstack.stackSize -= i1;
             net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                        (float)i + f, (float)j + f1, (float)k + f2, new net.minecraft.src.ItemStack(itemstack
                                                                                                                                                                    .itemID, i1, itemstack.GetItemDamage()));
             float f3 = 0.05F;
             entityitem.motionX = (float)random.NextGaussian() * f3;
             entityitem.motionY = (float)random.NextGaussian() * f3 + 0.2F;
             entityitem.motionZ = (float)random.NextGaussian() * f3;
             world.AddEntity(entityitem);
         }while (true);
         label0_continue :;
     }
     label0_break :;
     base.OnBlockRemoval(world, i, j, k);
 }
Esempio n. 12
0
 private static void Func_21166_a(net.minecraft.src.EntityLiving entityliving, net.minecraft.src.World
                                  world, float f, float f1, float f2)
 {
     if ((entityliving is net.minecraft.src.EntitySpider) && world.rand.Next(100) ==
         0)
     {
         net.minecraft.src.EntitySkeleton entityskeleton = new net.minecraft.src.EntitySkeleton
                                                               (world);
         entityskeleton.SetLocationAndAngles(f, f1, f2, entityliving.rotationYaw, 0.0F);
         world.AddEntity(entityskeleton);
         entityskeleton.MountEntity(entityliving);
     }
     else
     {
         if (entityliving is net.minecraft.src.EntitySheep)
         {
             ((net.minecraft.src.EntitySheep)entityliving).SetFleeceColor(net.minecraft.src.EntitySheep
                                                                          .Func_21066_a(world.rand));
         }
     }
 }
Esempio n. 13
0
 public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                              itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                              )
 {
     if (entityplayer.fishEntity != null)
     {
         int i = entityplayer.fishEntity.CatchFish();
         itemstack.DamageItem(i, entityplayer);
         entityplayer.SwingItem();
     }
     else
     {
         world.PlaySoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.NextFloat
                                                                               () * 0.4F + 0.8F));
         if (!world.singleplayerWorld)
         {
             world.AddEntity(new net.minecraft.src.EntityFish(world, entityplayer));
         }
         entityplayer.SwingItem();
     }
     return(itemstack);
 }
Esempio n. 14
0
        public virtual void Func_28035_b_(net.minecraft.src.World world, int i, int j, int
                                          k)
        {
            if (world.singleplayerWorld)
            {
                return;
            }
            net.minecraft.src.TileEntityRecordPlayer tileentityrecordplayer = (net.minecraft.src.TileEntityRecordPlayer)world.GetBlockTileEntity(i, j, k);
            if (tileentityrecordplayer == null)
            {
                return;                                             // CRAFTBUKKIT
            }
            int l = tileentityrecordplayer.field_28009_a;

            if (l == 0)
            {
                return;
            }
            else
            {
                world.SendSoundEffectToAllPlayersWithin64(1005, i, j, k, 0);
                world.PlayRecord(null, i, j, k);
                tileentityrecordplayer.field_28009_a = 0;
                tileentityrecordplayer.OnInventoryChanged();
                world.SetBlockMetadataWithNotify(i, j, k, 0);
                int    i1 = l;
                float  f  = 0.7F;
                double d  = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.20000000000000001D
                            + 0.59999999999999998D;
                double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D;
                net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                           (double)i + d, (double)j + d1, (double)k + d2, new net.minecraft.src.ItemStack(i1
                                                                                                                                                                          , 1, 0));
                entityitem.delayBeforeCanPickup = 10;
                world.AddEntity(entityitem);
                return;
            }
        }
Esempio n. 15
0
        // Referenced classes of package net.minecraft.src:
        //            Item, EntityPainting, World, ItemStack,
        //            EntityPlayer
        public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                       entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
        {
            if (l == 0)
            {
                return(false);
            }
            if (l == 1)
            {
                return(false);
            }
            byte byte0 = 0;

            if (l == 4)
            {
                byte0 = 1;
            }
            if (l == 3)
            {
                byte0 = 2;
            }
            if (l == 5)
            {
                byte0 = 3;
            }
            net.minecraft.src.EntityPainting entitypainting = new net.minecraft.src.EntityPainting
                                                                  (world, i, j, k, byte0);
            if (entitypainting.OnValidSurface())
            {
                if (!world.singleplayerWorld)
                {
                    world.AddEntity(entitypainting);
                }
                itemstack.stackSize--;
            }
            return(true);
        }
Esempio n. 16
0
 public override void DropBlockAsItemWithChance(net.minecraft.src.World world, int
                                                i, int j, int k, int l, float f)
 {
     base.DropBlockAsItemWithChance(world, i, j, k, l, f);
     if (world.singleplayerWorld)
     {
         return;
     }
     for (int i1 = 0; i1 < 3; i1++)
     {
         if (world.rand.Next(15) <= l)
         {
             float f1 = 0.7F;
             float f2 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F;
             float f3 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F;
             float f4 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F;
             net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world,
                                                                                        (float)i + f2, (float)j + f3, (float)k + f4, new net.minecraft.src.ItemStack(net.minecraft.src.Item
                                                                                                                                                                     .SEEDS));
             entityitem.delayBeforeCanPickup = 10;
             world.AddEntity(entityitem);
         }
     }
 }
Esempio n. 17
0
        public static bool PerformSleepSpawning(net.minecraft.src.World world, List <EntityPlayer> list)
        {
            bool flag = false;

            net.minecraft.src.Pathfinder   pathfinder = new net.minecraft.src.Pathfinder(world);
            System.Collections.IEnumerator iterator   = list.GetEnumerator();
            do
            {
                if (!iterator.MoveNext())
                {
                    break;
                }
                net.minecraft.src.EntityPlayer entityplayer = (net.minecraft.src.EntityPlayer)iterator
                                                              .Current;
                System.Type[] aclass = field_22213_a;
                if (aclass != null && aclass.Length != 0)
                {
                    bool flag1 = false;
                    int  i     = 0;
                    while (i < 20 && !flag1)
                    {
                        int j = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posX) + world.rand
                                 .NextInt(32)) - world.rand.Next(32);
                        int k = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posZ) + world.rand
                                 .NextInt(32)) - world.rand.Next(32);
                        int l = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posY) + world.rand
                                 .NextInt(16)) - world.rand.Next(16);
                        if (l < 1)
                        {
                            l = 1;
                        }
                        else
                        {
                            if (l > 128)
                            {
                                l = 128;
                            }
                        }
                        int i1 = world.rand.Next(aclass.Length);
                        int j1;
                        for (j1 = l; j1 > 2 && !world.IsBlockNormalCube(j, j1 - 1, k); j1--)
                        {
                        }
                        for (; !Func_21167_a(net.minecraft.src.EnumCreatureType.monster, world, j, j1, k) &&
                             j1 < l + 16 && j1 < 128; j1++)
                        {
                        }
                        if (j1 >= l + 16 || j1 >= 128)
                        {
                            j1 = l;
                        }
                        else
                        {
                            float f  = (float)j + 0.5F;
                            float f1 = j1;
                            float f2 = (float)k + 0.5F;
                            net.minecraft.src.EntityLiving entityliving;
                            try
                            {
                                entityliving = (net.minecraft.src.EntityLiving)(aclass[i1].GetConstructor(new System.Type[] { Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.World)) }).Invoke(new object[] { world }));
                            }
                            catch (System.Exception exception)
                            {
                                Sharpen.Runtime.PrintStackTrace(exception);
                                return(flag);
                            }
                            entityliving.SetLocationAndAngles(f, f1, f2, world.rand.NextFloat() * 360F, 0.0F);
                            if (entityliving.GetCanSpawnHere())
                            {
                                net.minecraft.src.PathEntity pathentity = pathfinder.CreateEntityPathTo(entityliving
                                                                                                        , entityplayer, 32F);
                                if (pathentity != null && pathentity.pathLength > 1)
                                {
                                    net.minecraft.src.PathPoint pathpoint = pathentity.Func_22211_c();
                                    if (System.Math.Abs((double)pathpoint.xCoord - entityplayer.posX) < 1.5D && System.Math
                                        .Abs((double)pathpoint.zCoord - entityplayer.posZ) < 1.5D && System.Math.Abs((double
                                                                                                                      )pathpoint.yCoord - entityplayer.posY) < 1.5D)
                                    {
                                        net.minecraft.src.ChunkCoordinates chunkcoordinates = net.minecraft.src.BlockBed.
                                                                                              Func_22021_g(world, net.minecraft.src.MathHelper.Floor_double(entityplayer.posX)
                                                                                                           , net.minecraft.src.MathHelper.Floor_double(entityplayer.posY), net.minecraft.src.MathHelper
                                                                                                           .Floor_double(entityplayer.posZ), 1);
                                        if (chunkcoordinates == null)
                                        {
                                            chunkcoordinates = new net.minecraft.src.ChunkCoordinates(j, j1 + 1, k);
                                        }
                                        entityliving.SetLocationAndAngles((float)chunkcoordinates.posX + 0.5F, chunkcoordinates
                                                                          .posY, (float)chunkcoordinates.posZ + 0.5F, 0.0F, 0.0F);
                                        world.AddEntity(entityliving);
                                        Func_21166_a(entityliving, world, (float)chunkcoordinates.posX + 0.5F, chunkcoordinates
                                                     .posY, (float)chunkcoordinates.posZ + 0.5F);
                                        entityplayer.WakeUpPlayer(true, false, false);
                                        entityliving.PlayLivingSound();
                                        flag  = true;
                                        flag1 = true;
                                    }
                                }
                            }
                        }
                        i++;
                    }
                }
            }while (true);
            return(flag);
        }
Esempio n. 18
0
        public void DispenseItem(net.minecraft.src.World world, int i, int j, int k, SharpBukkitLive.SharpBukkit.SharpRandom random)
        {
            //TODO: Implement dispenser fixes
            return;

            int l  = world.GetBlockMetadata(i, j, k);
            int i1 = 0;
            int j1 = 0;

            if (l == 3)
            {
                j1 = 1;
            }
            else if (l == 2)
            {
                j1 = -1;
            }
            else if (l == 5)
            {
                i1 = 1;
            }
            else
            {
                i1 = -1;
            }

            net.minecraft.src.TileEntityDispenser tileentitydispenser = (net.minecraft.src.TileEntityDispenser)world.GetBlockTileEntity(i, j, k);
            net.minecraft.src.ItemStack           itemstack           = tileentitydispenser.GetRandomStackFromInventory();
            double d  = (double)i + (double)i1 * 0.59999999999999998D + 0.5D;
            double d1 = (double)j + 0.5D;
            double d2 = (double)k + (double)j1 * 0.59999999999999998D + 0.5D;

            if (itemstack == null)
            {
                world.SendSoundEffectToAllPlayersWithin64(1001, i, j, k, 0);
            }
            else
            {
                if (itemstack.itemID == net.minecraft.src.Item.ARROW.ID)
                {
                    net.minecraft.src.EntityArrow entityarrow = new net.minecraft.src.EntityArrow(world, d, d1, d2);
                    entityarrow.SetArrowHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F);
                    entityarrow.field_28012_a = true;
                    world.AddEntity(entityarrow);
                    world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0);
                }
                else if (itemstack.itemID == net.minecraft.src.Item.EGG.ID)
                {
                    net.minecraft.src.EntityEgg entityegg = new net.minecraft.src.EntityEgg(world, d, d1, d2);
                    entityegg.SetEggHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F);
                    world.AddEntity(entityegg);
                    world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0);
                }
                else if (itemstack.itemID == net.minecraft.src.Item.SNOW_BALL.ID)
                {
                    net.minecraft.src.EntitySnowball entitysnowball = new net.minecraft.src.EntitySnowball(world, d, d1, d2);
                    entitysnowball.SetSnowballHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F);
                    world.AddEntity(entitysnowball);
                    world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0);
                }
                else
                {
                    net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, d, d1 - 0.29999999999999999D, d2, itemstack);
                    double d3 = random.NextDouble() * 0.10000000000000001D + 0.20000000000000001D;
                    entityitem.motionX  = (double)i1 * d3;
                    entityitem.motionY  = 0.20000000298023224D;
                    entityitem.motionZ  = (double)j1 * d3;
                    entityitem.motionX += random.NextGaussian() * 0.0074999998323619366D * 6D;
                    entityitem.motionY += random.NextGaussian() * 0.0074999998323619366D * 6D;
                    entityitem.motionZ += random.NextGaussian() * 0.0074999998323619366D * 6D;
                    world.AddEntity(entityitem);
                    world.SendSoundEffectToAllPlayersWithin64(1000, i, j, k, 0);
                }

                world.SendSoundEffectToAllPlayersWithin64(2000, i, j, k, i1 + 1 + (j1 + 1) * 3);
            }
        }
Esempio n. 19
0
 public static int PerformSpawning(net.minecraft.src.World var0, bool var1, bool var2
                                   )
 {
     if (!var1 && !var2)
     {
         return(0);
     }
     else
     {
         eligibleChunksForSpawning.Clear();
         int var3;
         int var6;
         for (var3 = 0; var3 < var0.playerEntities.Count; ++var3)
         {
             net.minecraft.src.EntityPlayer var4 = (net.minecraft.src.EntityPlayer)var0.playerEntities
                                                   [var3];
             int var5 = net.minecraft.src.MathHelper.Floor_double(var4.posX / 16.0D);
             var6 = net.minecraft.src.MathHelper.Floor_double(var4.posZ / 16.0D);
             byte var7 = 8;
             for (int var8 = -var7; var8 <= var7; ++var8)
             {
                 for (int var9 = -var7; var9 <= var7; ++var9)
                 {
                     eligibleChunksForSpawning.Add(new net.minecraft.src.ChunkCoordIntPair(var8 + var5, var9 + var6));
                 }
             }
         }
         var3 = 0;
         net.minecraft.src.ChunkCoordinates   var35 = var0.GetSpawnPoint();
         net.minecraft.src.EnumCreatureType[] var36 = net.minecraft.src.EnumCreatureType.Values();
         var6 = var36.Length;
         for (int var37 = 0; var37 < var6; ++var37)
         {
             net.minecraft.src.EnumCreatureType var38 = var36[var37];
             if ((!var38.Func_21103_d() || var2) && (var38.Func_21103_d() || var1) && var0.CountEntities
                     (var38.GetCreatureClass()) <= var38.GetMaxNumberOfCreature() * eligibleChunksForSpawning
                 .Count / 256)
             {
                 System.Collections.IEnumerator var39 = eligibleChunksForSpawning.GetEnumerator();
                 while (var39.MoveNext())
                 {
                     net.minecraft.src.ChunkCoordIntPair var10 = (net.minecraft.src.ChunkCoordIntPair)
                                                                 var39.Current;
                     net.minecraft.src.BiomeGenBase var11 = var0.GetWorldChunkManager().Func_4066_a(var10
                                                                                                    );
                     System.Collections.IList var12 = var11.GetSpawnableList(var38);
                     if (var12 != null && var12.Count > 0)
                     {
                         int var13 = 0;
                         net.minecraft.src.SpawnListEntry var15;
                         for (System.Collections.IEnumerator var14 = var12.GetEnumerator(); var14.MoveNext
                                  (); var13 += var15.spawnRarityRate)
                         {
                             var15 = (net.minecraft.src.SpawnListEntry)var14.Current;
                         }
                         int var40 = var0.rand.Next(var13);
                         var15 = (net.minecraft.src.SpawnListEntry)var12[0];
                         System.Collections.IEnumerator var16 = var12.GetEnumerator();
                         while (var16.MoveNext())
                         {
                             net.minecraft.src.SpawnListEntry var17 = (net.minecraft.src.SpawnListEntry)var16.
                                                                      Current;
                             var40 -= var17.spawnRarityRate;
                             if (var40 < 0)
                             {
                                 var15 = var17;
                                 break;
                             }
                         }
                         net.minecraft.src.ChunkPosition var41 = GetRandomSpawningPointInChunk(var0, var10
                                                                                               .X * 16, var10.Z * 16);
                         int var42 = var41.x;
                         int var18 = var41.y;
                         int var19 = var41.z;
                         if (!var0.IsBlockNormalCube(var42, var18, var19) && var0.GetBlockMaterial(var42,
                                                                                                   var18, var19) == var38.GetCreatureMaterial())
                         {
                             int var20 = 0;
                             for (int var21 = 0; var21 < 3; ++var21)
                             {
                                 int  var22 = var42;
                                 int  var23 = var18;
                                 int  var24 = var19;
                                 byte var25 = 6;
                                 for (int var26 = 0; var26 < 4; ++var26)
                                 {
                                     var22 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     var23 += var0.rand.Next(1) - var0.rand.Next(1);
                                     var24 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     if (Func_21167_a(var38, var0, var22, var23, var24))
                                     {
                                         float var27 = (float)var22 + 0.5F;
                                         float var28 = (float)var23;
                                         float var29 = (float)var24 + 0.5F;
                                         if (var0.GetClosestPlayer((double)var27, (double)var28, (double)var29, 24.0D) ==
                                             null)
                                         {
                                             float var30 = var27 - (float)var35.posX;
                                             float var31 = var28 - (float)var35.posY;
                                             float var32 = var29 - (float)var35.posZ;
                                             float var33 = var30 * var30 + var31 * var31 + var32 * var32;
                                             if (var33 >= 576.0F)
                                             {
                                                 net.minecraft.src.EntityLiving var43;
                                                 try
                                                 {
                                                     var43 = (net.minecraft.src.EntityLiving)(var15.entityClass.GetConstructor(new System.Type[] { typeof(net.minecraft.src.World) }).Invoke(new object[] { var0 }));
                                                 }
                                                 catch (System.Exception var34)
                                                 {
                                                     Sharpen.Runtime.PrintStackTrace(var34);
                                                     return(var3);
                                                 }
                                                 var43.SetLocationAndAngles((double)var27, (double)var28, (double)var29, var0.rand
                                                                            .NextFloat() * 360.0F, 0.0F);
                                                 if (var43.GetCanSpawnHere())
                                                 {
                                                     ++var20;
                                                     var0.AddEntity(var43);
                                                     Func_21166_a(var43, var0, var27, var28, var29);
                                                     if (var20 >= var43.GetMaxSpawnedInChunk())
                                                     {
                                                         goto label113_continue;
                                                     }
                                                 }
                                                 var3 += var20;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     label113_continue :;
                 }
                 label113_break :;
             }
         }
         return(var3);
     }
 }