/// <summary>
        /// Sets the extended block ID for a location in a chunk, splitting bits 11..8 into a NibbleArray and bits 7..0 into
        /// a byte array. Also performs reference counting to determine whether or not to broadly cull this Chunk from the
        /// random-update tick list.
        /// </summary>
        public virtual void SetExtBlockID(int par1, int par2, int par3, int par4)
        {
            int i = BlockLSBArray[par2 << 8 | par3 << 4 | par1] & 0xff;

            if (BlockMSBArray != null)
            {
                i = BlockMSBArray.Get(par1, par2, par3) << 8 | i;
            }

            if (i == 0 && par4 != 0)
            {
                BlockRefCount++;

                if (Block.BlocksList[par4] != null && Block.BlocksList[par4].GetTickRandomly())
                {
                    TickRefCount++;
                }
            }
            else if (i != 0 && par4 == 0)
            {
                BlockRefCount--;

                if (Block.BlocksList[i] != null && Block.BlocksList[i].GetTickRandomly())
                {
                    TickRefCount--;
                }
            }
            else if (Block.BlocksList[i] != null && Block.BlocksList[i].GetTickRandomly() && (Block.BlocksList[par4] == null || !Block.BlocksList[par4].GetTickRandomly()))
            {
                TickRefCount--;
            }
            else if ((Block.BlocksList[i] == null || !Block.BlocksList[i].GetTickRandomly()) && Block.BlocksList[par4] != null && Block.BlocksList[par4].GetTickRandomly())
            {
                TickRefCount++;
            }

            BlockLSBArray[par2 << 8 | par3 << 4 | par1] = (byte)(par4 & 0xff);

            if (par4 > 255)
            {
                if (BlockMSBArray == null)
                {
                    BlockMSBArray = new NibbleArray(BlockLSBArray.Length, 4);
                }

                BlockMSBArray.Set(par1, par2, par3, (par4 & 0xf00) >> 8);
            }
            else if (BlockMSBArray != null)
            {
                BlockMSBArray.Set(par1, par2, par3, 0);
            }
        }
示例#2
0
        public static void ConvertToAnvilFormat(AnvilConverterData par0AnvilConverterData, NBTTagCompound par1NBTTagCompound, WorldChunkManager par2WorldChunkManager)
        {
            par1NBTTagCompound.SetInteger("xPos", par0AnvilConverterData.x);
            par1NBTTagCompound.SetInteger("zPos", par0AnvilConverterData.z);
            par1NBTTagCompound.SetLong("LastUpdate", par0AnvilConverterData.LastUpdated);
            int[] ai = new int[par0AnvilConverterData.Heightmap.Length];

            for (int i = 0; i < par0AnvilConverterData.Heightmap.Length; i++)
            {
                ai[i] = par0AnvilConverterData.Heightmap[i];
            }

            par1NBTTagCompound.Func_48183_a("HeightMap", ai);
            par1NBTTagCompound.Setbool("TerrainPopulated", par0AnvilConverterData.TerrainPopulated);
            NBTTagList nbttaglist = new NBTTagList("Sections");

            for (int j = 0; j < 8; j++)
            {
                bool flag = true;

                for (int l = 0; l < 16 && flag; l++)
                {
label0:

                    for (int j1 = 0; j1 < 16 && flag; j1++)
                    {
                        int k1 = 0;

                        do
                        {
                            if (k1 >= 16)
                            {
                                goto label0;
                            }

                            int  l1    = l << 11 | k1 << 7 | j1 + (j << 4);
                            byte byte0 = par0AnvilConverterData.Blocks[l1];

                            if (byte0 != 0)
                            {
                                flag = false;
                                goto label0;
                            }

                            k1++;
                        }while (true);
                    }
                }

                if (flag)
                {
                    continue;
                }

                byte[]      abyte1       = new byte[4096];
                NibbleArray nibblearray  = new NibbleArray(abyte1.Length, 4);
                NibbleArray nibblearray1 = new NibbleArray(abyte1.Length, 4);
                NibbleArray nibblearray2 = new NibbleArray(abyte1.Length, 4);

                for (int i2 = 0; i2 < 16; i2++)
                {
                    for (int j2 = 0; j2 < 16; j2++)
                    {
                        for (int k2 = 0; k2 < 16; k2++)
                        {
                            int  l2    = i2 << 11 | k2 << 7 | j2 + (j << 4);
                            byte byte1 = par0AnvilConverterData.Blocks[l2];
                            abyte1[j2 << 8 | k2 << 4 | i2] = (byte)(byte1 & 0xff);
                            nibblearray.Set(i2, j2, k2, par0AnvilConverterData.Data.Get(i2, j2 + (j << 4), k2));
                            nibblearray1.Set(i2, j2, k2, par0AnvilConverterData.SkyLight.Get(i2, j2 + (j << 4), k2));
                            nibblearray2.Set(i2, j2, k2, par0AnvilConverterData.BlockLight.Get(i2, j2 + (j << 4), k2));
                        }
                    }
                }

                NBTTagCompound nbttagcompound = new NBTTagCompound();
                nbttagcompound.SetByte("Y", (byte)(j & 0xff));
                nbttagcompound.SetByteArray("Blocks", abyte1);
                nbttagcompound.SetByteArray("Data", nibblearray.Data);
                nbttagcompound.SetByteArray("SkyLight", nibblearray1.Data);
                nbttagcompound.SetByteArray("BlockLight", nibblearray2.Data);
                nbttaglist.AppendTag(nbttagcompound);
            }

            par1NBTTagCompound.SetTag("Sections", nbttaglist);
            byte[] abyte0 = new byte[256];

            for (int k = 0; k < 16; k++)
            {
                for (int i1 = 0; i1 < 16; i1++)
                {
                    abyte0[i1 << 4 | k] = (byte)(par2WorldChunkManager.GetBiomeGenAt(par0AnvilConverterData.x << 4 | k, par0AnvilConverterData.z << 4 | i1).BiomeID & 0xff);
                }
            }

            par1NBTTagCompound.SetByteArray("Biomes", abyte0);
            par1NBTTagCompound.SetTag("Entities", par0AnvilConverterData.Entities);
            par1NBTTagCompound.SetTag("TileEntities", par0AnvilConverterData.TileEntities);

            if (par0AnvilConverterData.TileTicks != null)
            {
                par1NBTTagCompound.SetTag("TileTicks", par0AnvilConverterData.TileTicks);
            }
        }
 /// <summary>
 /// Sets the saved Block-light value in the extended block storage structure.
 /// </summary>
 public virtual void SetExtBlocklightValue(int par1, int par2, int par3, int par4)
 {
     BlocklightArray.Set(par1, par2, par3, par4);
 }
 /// <summary>
 /// Sets the metadata of the Block at the given coordinates in this ExtendedBlockStorage to the given metadata.
 /// </summary>
 public virtual void SetExtBlockMetadata(int par1, int par2, int par3, int par4)
 {
     BlockMetadataArray.Set(par1, par2, par3, par4);
 }