@Override
protected Chunk readChunkFromNBT(World world, NBTTagCompound nbtTagCompound) {
int i = nbtTagCompound.getInteger("xPos");
int j = nbtTagCompound.getInteger("zPos");
Chunk chunk = new Chunk(world, i, j);
chunk.heightMap = nbtTagCompound.getIntArray("HeightMap");
chunk.isTerrainPopulated = nbtTagCompound.getBoolean("TerrainPopulated");
NBTTagList nbttaglist = nbtTagCompound.getTagList("Sections");
byte b0 = 16;
ExtendedBlockStorage[] aextendedblockstorage = new ExtendedBlockStorage[b0];
boolean flag = !world.provider.hasNoSky;
for (int k = 0; k < nbttaglist.tagCount(); ++k) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(k);
byte b1 = nbttagcompound1.getByte("Y");
ExtendedBlockStorage extendedblockstorage = new ExtendedBlockStorage(b1 << 4, flag);
extendedblockstorage.setBlockLSBArray(nbttagcompound1.getByteArray("Blocks"));
if (nbttagcompound1.hasKey("Add")) {
extendedblockstorage.setBlockMSBArray(new NibbleArray(nbttagcompound1.getByteArray("Add"), 4));
}
extendedblockstorage.setBlockMetadataArray(new NibbleArray(nbttagcompound1.getByteArray("Data"), 4));
extendedblockstorage.setBlocklightArray(new NibbleArray(nbttagcompound1.getByteArray("BlockLight"), 4));
if (flag) {
extendedblockstorage.setSkylightArray(new NibbleArray(nbttagcompound1.getByteArray("SkyLight"), 4));
}
extendedblockstorage.removeInvalidBlocks();
aextendedblockstorage[b1] = extendedblockstorage;
}
chunk.setStorageArrays(aextendedblockstorage);
if (nbtTagCompound.hasKey("Biomes")) {
chunk.setBiomeArray(nbtTagCompound.getByteArray("Biomes"));
}
NBTTagList nbttaglist1 = nbtTagCompound.getTagList("Entities");
if (nbttaglist1 != null) {
for (int l = 0; l < nbttaglist1.tagCount(); ++l) {
NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
Entity entity = EntityList.createEntityFromNBT(nbttagcompound2, world);
chunk.hasEntities = true;
if (entity != null) {
chunk.addEntity(entity);
for (NBTTagCompound nbttagcompound3 = nbttagcompound2; nbttagcompound3.hasKey("Riding"); nbttagcompound3 = nbttagcompound3.getCompoundTag("Riding")) {
Entity entity2 = EntityList.createEntityFromNBT(nbttagcompound3.getCompoundTag("Riding"), world);
if (entity2 != null) {
chunk.addEntity(entity2);
entity.mountEntity(entity2);
}
}
}
}
}
NBTTagList nbttaglist2 = nbtTagCompound.getTagList("TileEntities");
if (nbttaglist2 != null) {
for (int i1 = 0; i1 < nbttaglist2.tagCount(); ++i1) {
NBTTagCompound nbttagcompound4 = (NBTTagCompound) nbttaglist2.tagAt(i1);
TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound4);
if (tileentity != null) {
chunk.addTileEntity(tileentity);
}
}
}
if (nbtTagCompound.hasKey("TileTicks")) {