Example #1
0
        public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound)
        {
            int i     = nbttagcompound.getInteger("xPos");
            int j     = nbttagcompound.getInteger("zPos");
            var chunk = new Chunk(world, i, j);

            chunk.blocks             = nbttagcompound.getByteArray("Blocks");
            chunk.data               = new NibbleArray(nbttagcompound.getByteArray("Data"));
            chunk.skylightMap        = new NibbleArray(nbttagcompound.getByteArray("SkyLight"));
            chunk.blocklightMap      = new NibbleArray(nbttagcompound.getByteArray("BlockLight"));
            chunk.heightMap          = nbttagcompound.getByteArray("HeightMap");
            chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated");
            if (!chunk.data.isValid())
            {
                chunk.data = new NibbleArray(chunk.blocks.Length);
            }
            if (chunk.heightMap == null || !chunk.skylightMap.isValid())
            {
                chunk.heightMap   = new byte[256];
                chunk.skylightMap = new NibbleArray(chunk.blocks.Length);
                chunk.func_353_b();
            }
            if (!chunk.blocklightMap.isValid())
            {
                chunk.blocklightMap = new NibbleArray(chunk.blocks.Length);
                chunk.func_348_a();
            }
            NBTTagList nbttaglist = nbttagcompound.getTagList("Entities");

            if (nbttaglist != null)
            {
                for (int k = 0; k < nbttaglist.tagCount(); k++)
                {
                    var    nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(k);
                    Entity entity          = EntityList.createEntityFromNBT(nbttagcompound1, world);
                    chunk.hasEntities = true;
                    if (entity != null)
                    {
                        chunk.addEntity(entity);
                    }
                }
            }
            NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");

            if (nbttaglist1 != null)
            {
                for (int l = 0; l < nbttaglist1.tagCount(); l++)
                {
                    var        nbttagcompound2 = (NBTTagCompound)nbttaglist1.tagAt(l);
                    TileEntity tileentity      = TileEntity.createAndLoadEntity(nbttagcompound2);
                    if (tileentity != null)
                    {
                        chunk.func_349_a(tileentity);
                    }
                }
            }
            return(chunk);
        }
Example #2
0
 public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound)
 {
     int i = nbttagcompound.getInteger("xPos");
     int j = nbttagcompound.getInteger("zPos");
     var chunk = new Chunk(world, i, j);
     chunk.blocks = nbttagcompound.getByteArray("Blocks");
     chunk.data = new NibbleArray(nbttagcompound.getByteArray("Data"));
     chunk.skylightMap = new NibbleArray(nbttagcompound.getByteArray("SkyLight"));
     chunk.blocklightMap = new NibbleArray(nbttagcompound.getByteArray("BlockLight"));
     chunk.heightMap = nbttagcompound.getByteArray("HeightMap");
     chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated");
     if (!chunk.data.isValid())
     {
         chunk.data = new NibbleArray(chunk.blocks.Length);
     }
     if (chunk.heightMap == null || !chunk.skylightMap.isValid())
     {
         chunk.heightMap = new byte[256];
         chunk.skylightMap = new NibbleArray(chunk.blocks.Length);
         chunk.func_353_b();
     }
     if (!chunk.blocklightMap.isValid())
     {
         chunk.blocklightMap = new NibbleArray(chunk.blocks.Length);
         chunk.func_348_a();
     }
     NBTTagList nbttaglist = nbttagcompound.getTagList("Entities");
     if (nbttaglist != null)
     {
         for (int k = 0; k < nbttaglist.tagCount(); k++)
         {
             var nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(k);
             Entity entity = EntityList.createEntityFromNBT(nbttagcompound1, world);
             chunk.hasEntities = true;
             if (entity != null)
             {
                 chunk.addEntity(entity);
             }
         }
     }
     NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");
     if (nbttaglist1 != null)
     {
         for (int l = 0; l < nbttaglist1.tagCount(); l++)
         {
             var nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
             TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound2);
             if (tileentity != null)
             {
                 chunk.func_349_a(tileentity);
             }
         }
     }
     return chunk;
 }