Esempio n. 1
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. 2
0
        // Referenced classes of package net.minecraft.src:
        //            WorldGenerator, World, Material, Block,
        //            TileEntityChest, TileEntityMobSpawner, ItemStack, Item
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            byte byte0 = 3;
            int  l     = random.Next(2) + 2;
            int  i1    = random.Next(2) + 2;
            int  j1    = 0;

            for (int k1 = i - l - 1; k1 <= i + l + 1; k1++)
            {
                for (int j2 = j - 1; j2 <= j + byte0 + 1; j2++)
                {
                    for (int i3 = k - i1 - 1; i3 <= k + i1 + 1; i3++)
                    {
                        net.minecraft.src.Material material = world.GetBlockMaterial(k1, j2, i3);
                        if (j2 == j - 1 && !material.IsSolid())
                        {
                            return(false);
                        }
                        if (j2 == j + byte0 + 1 && !material.IsSolid())
                        {
                            return(false);
                        }
                        if ((k1 == i - l - 1 || k1 == i + l + 1 || i3 == k - i1 - 1 || i3 == k + i1 + 1) &&
                            j2 == j && world.IsAirBlock(k1, j2, i3) && world.IsAirBlock(k1, j2 + 1, i3))
                        {
                            j1++;
                        }
                    }
                }
            }
            if (j1 < 1 || j1 > 5)
            {
                return(false);
            }
            for (int l1 = i - l - 1; l1 <= i + l + 1; l1++)
            {
                for (int k2 = j + byte0; k2 >= j - 1; k2--)
                {
                    for (int j3 = k - i1 - 1; j3 <= k + i1 + 1; j3++)
                    {
                        if (l1 == i - l - 1 || k2 == j - 1 || j3 == k - i1 - 1 || l1 == i + l + 1 || k2 ==
                            j + byte0 + 1 || j3 == k + i1 + 1)
                        {
                            if (k2 >= 0 && !world.GetBlockMaterial(l1, k2 - 1, j3).IsSolid())
                            {
                                world.SetBlockWithNotify(l1, k2, j3, 0);
                                continue;
                            }
                            if (!world.GetBlockMaterial(l1, k2, j3).IsSolid())
                            {
                                continue;
                            }
                            if (k2 == j - 1 && random.Next(4) != 0)
                            {
                                world.SetBlockWithNotify(l1, k2, j3, net.minecraft.src.Block.MOSSY_COBBLESTONE.ID
                                                         );
                            }
                            else
                            {
                                world.SetBlockWithNotify(l1, k2, j3, net.minecraft.src.Block.COBBLESTONE.ID);
                            }
                        }
                        else
                        {
                            world.SetBlockWithNotify(l1, k2, j3, 0);
                        }
                    }
                }
            }
            for (int i2 = 0; i2 < 2; i2++)
            {
                for (int l2 = 0; l2 < 3; l2++)
                {
                    int k3 = (i + random.Next(l * 2 + 1)) - l;
                    int l3 = j;
                    int i4 = (k + random.Next(i1 * 2 + 1)) - i1;
                    if (!world.IsAirBlock(k3, l3, i4))
                    {
                        continue;
                    }
                    int j4 = 0;
                    if (world.GetBlockMaterial(k3 - 1, l3, i4).IsSolid())
                    {
                        j4++;
                    }
                    if (world.GetBlockMaterial(k3 + 1, l3, i4).IsSolid())
                    {
                        j4++;
                    }
                    if (world.GetBlockMaterial(k3, l3, i4 - 1).IsSolid())
                    {
                        j4++;
                    }
                    if (world.GetBlockMaterial(k3, l3, i4 + 1).IsSolid())
                    {
                        j4++;
                    }
                    if (j4 != 1)
                    {
                        continue;
                    }
                    world.SetBlockWithNotify(k3, l3, i4, net.minecraft.src.Block.CHEST.ID);
                    net.minecraft.src.TileEntityChest tileentitychest = (net.minecraft.src.TileEntityChest
                                                                         )world.GetBlockTileEntity(k3, l3, i4);
                    int k4 = 0;
                    do
                    {
                        if (k4 >= 8)
                        {
                            goto label0_break;
                        }
                        net.minecraft.src.ItemStack itemstack = PickCheckLootItem(random);
                        if (itemstack != null)
                        {
                            tileentitychest.SetInventorySlotContents(random.Next(tileentitychest.GetSizeInventory
                                                                                     ()), itemstack);
                        }
                        k4++;
                    }while (true);
                    label0_continue :;
                }
                label0_break :;
            }
            world.SetBlockWithNotify(i, j, k, net.minecraft.src.Block.MOB_SPAWNER.ID);
            net.minecraft.src.TileEntityMobSpawner tileentitymobspawner = (net.minecraft.src.TileEntityMobSpawner
                                                                           )world.GetBlockTileEntity(i, j, k);
            tileentitymobspawner.SetMobID(PickMobSpawner(random));
            return(true);
        }