public Vector3i GetLight(int index) { return(new Vector3i( (int)bitBuffer.GetBits(index * INDEX_SIZE, LIGHTING_BITS).Data, (int)bitBuffer.GetBits(index * INDEX_SIZE + LIGHTING_BITS, LIGHTING_BITS).Data, (int)bitBuffer.GetBits(index * INDEX_SIZE + (2 * LIGHTING_BITS), LIGHTING_BITS).Data )); }
// Setting the wrong bit :eyesBlur: public void SetBlock(int index, int blockType) { // Get the type of block at that position int paletteIndex = (int)_data.GetBits(index * indicesLength, indicesLength).Data; PaletteEntry current = palette[paletteIndex]; // That block at the position no longer exists, so one less reference of the block in the palette current.refcount -= 1; // Is the block type already in the palette int replace = -1; for (int i = 0; i < palette.Length; i++) { if (palette[i] != null && palette[i].type == blockType) { replace = i; break; } } if (replace != -1) { _data.SetBits(index * indicesLength, indicesLength, new BitArray32((uint)replace)); palette[replace].refcount += 1; return; } // Otherwise if we can overwrite the current palette entry if (current.refcount == 0) { current.type = blockType; current.refcount = 1; return; } // A new palette entry is needed! int newEntry = NewPaletteEntry(); palette[newEntry] = new PaletteEntry(1, blockType); _data.SetBits(index * indicesLength, indicesLength, new BitArray32((uint)newEntry)); paletteCount += 1; }