public byte GetLightByte(int xInChunk, int yInChunk, int zInChunk, bool extends = false) { if (xInChunk < 0 || xInChunk > 15 || zInChunk < 0 || zInChunk > 15) { if (extends) { int xOffset = 0; int zOffset = 0; if (xInChunk < 0) { xOffset = -1; } else if (xInChunk > 15) { xOffset = 1; } if (zInChunk < 0) { zOffset = -1; } else if (zInChunk > 15) { zOffset = 1; } NBTChunk chunk = NBTHelper.GetChunk(x + xOffset, z + zOffset); if (chunk != null) { return(chunk.GetLightByte(xInChunk - xOffset * 16, yInChunk, zInChunk - zOffset * 16)); } else { return(15); } } else { return(15); } } int sectionIndex = yInChunk / 16; if (sectionIndex >= Sections.Count || yInChunk < 0 || yInChunk > 255) { return(15); } int yInSection = yInChunk % 16; int blockPos = yInSection * 16 * 16 + zInChunk * 16 + xInChunk; TagNodeCompound Section = Sections[sectionIndex] as TagNodeCompound; TagNodeByteArray SkyLight = Section["SkyLight"] as TagNodeByteArray; byte skyLight = NBTHelper.GetNibble(SkyLight.Data, blockPos); TagNodeByteArray BlockLight = Section["BlockLight"] as TagNodeByteArray; byte blockLight = NBTHelper.GetNibble(BlockLight.Data, blockPos); //Debug.Log("y=" + x + "," + z + ",section=" + sectionIndex); return(skyLight > blockLight ? skyLight : blockLight); }