Ejemplo n.º 1
0
        public virtual int GetBlockId(int i, int j, int k)
        {
            if (j < 0)
            {
                return(0);
            }
            if (j >= 128)
            {
                return(0);
            }
            int l  = (i >> 4) - chunkX;
            int i1 = (k >> 4) - chunkZ;

            if (l < 0 || l >= chunkArray.Length || i1 < 0 || i1 >= chunkArray[l].Length)
            {
                return(0);
            }
            net.minecraft.src.Chunk chunk = chunkArray[l][i1];
            if (chunk == null)
            {
                return(0);
            }
            else
            {
                return(chunk.GetBlockID(i & 0xf, j, k & 0xf));
            }
        }
 public Packet52MultiBlockChange(int x, int z, short[] aword0, int arraySize, net.minecraft.src.World world)
 {
     isChunkDataPacket = true;
     xPosition         = x;
     zPosition         = z;
     size            = arraySize;
     coordinateArray = new short[arraySize];
     typeArray       = new byte[arraySize];
     metadataArray   = new byte[arraySize];
     net.minecraft.src.Chunk chunk = world.GetChunkFromChunkCoords(x, z);
     for (int l = 0; l < arraySize; l++)
     {
         int i1 = aword0[l] >> 12 & 0xf;
         int j1 = aword0[l] >> 8 & 0xf;
         int k1 = aword0[l] & 0xff;
         coordinateArray[l] = aword0[l];
         typeArray[l]       = unchecked ((byte)chunk.GetBlockID(i1, k1, j1));
         metadataArray[l]   = unchecked ((byte)chunk.GetBlockMetadata(i1, k1, j1));
     }
 }
Ejemplo n.º 3
0
        public virtual void Func_28024_a(net.minecraft.src.World world, net.minecraft.src.Entity
                                         entity, net.minecraft.src.MapData mapdata)
        {
            if (world.worldProvider.worldType != mapdata.field_28162_d)
            {
                return;
            }
            short c  = 128;           //'\200';
            short c1 = 128;           //'\200';
            int   i  = 1 << mapdata.field_28161_e;
            int   j  = mapdata.field_28164_b;
            int   k  = mapdata.field_28163_c;
            int   l  = net.minecraft.src.MathHelper.Floor_double(entity.posX - (double)j) / i +
                       c / 2;
            int i1 = net.minecraft.src.MathHelper.Floor_double(entity.posZ - (double)k) / i +
                     c1 / 2;
            int j1 = 128 / i;

            if (world.worldProvider.worldHasSky)
            {
                j1 /= 2;
            }
            mapdata.field_28159_g++;
            for (int k1 = (l - j1) + 1; k1 < l + j1; k1++)
            {
                if ((k1 & 0xf) != (mapdata.field_28159_g & 0xf))
                {
                    continue;
                }
                int    l1 = 255;
                int    i2 = 0;
                double d  = 0.0D;
                for (int j2 = i1 - j1 - 1; j2 < i1 + j1; j2++)
                {
                    if (k1 < 0 || j2 < -1 || k1 >= c || j2 >= c1)
                    {
                        continue;
                    }
                    int   k2   = k1 - l;
                    int   l2   = j2 - i1;
                    bool  flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2);
                    int   i3   = ((j / i + k1) - c / 2) * i;
                    int   j3   = ((k / i + j2) - c1 / 2) * i;
                    int   k3   = 0;
                    int   l3   = 0;
                    int   i4   = 0;
                    int[] ai   = new int[256];
                    net.minecraft.src.Chunk chunk = world.GetChunkFromBlockCoords(i3, j3);
                    int    j4 = i3 & 0xf;
                    int    k4 = j3 & 0xf;
                    int    l4 = 0;
                    double d1 = 0.0D;
                    if (world.worldProvider.worldHasSky)
                    {
                        int i5 = i3 + j3 * 0x389bf;
                        i5 = i5 * i5 * 0x1dd6751 + i5 * 11;
                        if ((i5 >> 20 & 1) == 0)
                        {
                            ai[net.minecraft.src.Block.DIRT.ID] += 10;
                        }
                        else
                        {
                            ai[net.minecraft.src.Block.STONE.ID] += 10;
                        }
                        d1 = 100D;
                    }
                    else
                    {
                        for (int j5 = 0; j5 < i; j5++)
                        {
                            for (int l5 = 0; l5 < i; l5++)
                            {
                                int j6 = chunk.GetHeightValue(j5 + j4, l5 + k4) + 1;
                                int l6 = 0;
                                if (j6 > 1)
                                {
                                    bool flag1 = false;
                                    do
                                    {
                                        flag1 = true;
                                        l6    = chunk.GetBlockID(j5 + j4, j6 - 1, l5 + k4);
                                        if (l6 == 0)
                                        {
                                            flag1 = false;
                                        }
                                        else
                                        {
                                            if (j6 > 0 && l6 > 0 && net.minecraft.src.Block.blocksList[l6].blockMaterial.field_28131_A
                                                == net.minecraft.src.MapColor.field_28199_b)
                                            {
                                                flag1 = false;
                                            }
                                        }
                                        if (!flag1)
                                        {
                                            j6--;
                                            l6 = chunk.GetBlockID(j5 + j4, j6 - 1, l5 + k4);
                                        }
                                    }while (!flag1);
                                    if (l6 != 0 && net.minecraft.src.Block.blocksList[l6].blockMaterial.GetIsLiquid())
                                    {
                                        int i7 = j6 - 1;
                                        int k7 = 0;
                                        do
                                        {
                                            k7 = chunk.GetBlockID(j5 + j4, i7--, l5 + k4);
                                            l4++;
                                        }while (i7 > 0 && k7 != 0 && net.minecraft.src.Block.blocksList[k7].blockMaterial.
                                                GetIsLiquid());
                                    }
                                }
                                d1 += (double)j6 / (double)(i * i);
                                ai[l6]++;
                            }
                        }
                    }
                    l4 /= i * i;
                    k3 /= i * i;
                    l3 /= i * i;
                    i4 /= i * i;
                    int k5 = 0;
                    int i6 = 0;
                    for (int k6 = 0; k6 < 256; k6++)
                    {
                        if (ai[k6] > k5)
                        {
                            i6 = k6;
                            k5 = ai[k6];
                        }
                    }
                    double d2 = ((d1 - d) * 4D) / (double)(i + 4) + ((double)(k1 + j2 & 1) - 0.5D) *
                                0.40000000000000002D;
                    byte byte0 = 1;
                    if (d2 > 0.59999999999999998D)
                    {
                        byte0 = 2;
                    }
                    if (d2 < -0.59999999999999998D)
                    {
                        byte0 = 0;
                    }
                    int j7 = 0;
                    if (i6 > 0)
                    {
                        net.minecraft.src.MapColor mapcolor = net.minecraft.src.Block.blocksList[i6].blockMaterial
                                                              .field_28131_A;
                        if (mapcolor == net.minecraft.src.MapColor.field_28187_n)
                        {
                            double d3 = (double)l4 * 0.10000000000000001D + (double)(k1 + j2 & 1) * 0.20000000000000001D;
                            byte0 = 1;
                            if (d3 < 0.5D)
                            {
                                byte0 = 2;
                            }
                            if (d3 > 0.90000000000000002D)
                            {
                                byte0 = 0;
                            }
                        }
                        j7 = mapcolor.field_28184_q;
                    }
                    d = d1;
                    if (j2 < 0 || k2 * k2 + l2 * l2 >= j1 * j1 || flag && (k1 + j2 & 1) == 0)
                    {
                        continue;
                    }
                    byte byte1 = mapdata.field_28160_f[k1 + j2 * c];
                    byte byte2 = unchecked ((byte)(j7 * 4 + byte0));
                    if (byte1 == byte2)
                    {
                        continue;
                    }
                    if (l1 > j2)
                    {
                        l1 = j2;
                    }
                    if (i2 < j2)
                    {
                        i2 = j2;
                    }
                    mapdata.field_28160_f[k1 + j2 * c] = byte2;
                }
                if (l1 <= i2)
                {
                    mapdata.Func_28153_a(k1, l1, i2);
                }
            }
        }