Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BunnyNabbit/celaria-formats/llms.txt

Use this file to discover all available pages before exploring further.

UV maps store texture coordinate data for the faces of blocks in a Celaria map. Each entry in a .cuvdata file describes how a texture is mapped onto one face of one block, using a pair of 2D coordinates that define the start and end of the texture region. CelariaUvMap provides a static parse method to read this data.

Parsing a .cuvdata file

Pass a Buffer to CelariaUvMap.parse(buffer). The method reads the file signature, validates the version, and returns an array of UvData objects — one per block face entry.
import fs from "node:fs"
import { CelariaUvMap } from "celaria-formats"

const buffer = fs.readFileSync("./myMap.cuvdata")
const uvData = CelariaUvMap.parse(buffer)

for (const entry of uvData) {
  console.log(entry.blockId)  // which block
  console.log(entry.faceId)   // which face of that block
  console.log(entry.startX, entry.startY) // UV start
  console.log(entry.endX, entry.endY)     // UV end
}

UvData structure

Each object in the returned array has the following fields:
FieldTypeDescription
blockIdnumberIndex of the block this UV entry belongs to
faceIdnumberWhich face of the block (0–5 for a rectangular prism)
startXnumberHorizontal start coordinate of the texture region (float)
startYnumberVertical start coordinate of the texture region (float)
endXnumberHorizontal end coordinate of the texture region (float)
endYnumberVertical end coordinate of the texture region (float)
startX/startY and endX/endY define a rectangle in UV space that maps onto the block face. These are stored as 32-bit floats in the binary format.

File format details

.cuvdata files must begin with the ASCII signature "cuvdata". If the file does not start with this string, parse throws Error("Magic mismatch."). Only version 0 is currently supported. If the version byte in the file does not equal 0, parse throws Error("Unsupported version <n>.").
// CelariaUvMap.fileSignature is the expected header string
console.log(CelariaUvMap.fileSignature) // "cuvdata"
CelariaUvMap only supports parsing — there is no serialize method. UV map files cannot be written back to disk using this library.

Build docs developers (and LLMs) love