Overview
TheUtilities class provides a comprehensive collection of static utility methods for common operations in Minecraft Creator Tools, including string processing, JSON manipulation, UUID generation, encoding/decoding, and Minecraft-specific name formatting.
String Manipulation
humanifyMinecraftName
Converts a Minecraft technical name to a human-readable format.The technical name to convert
If true, preserves the original order (doesn’t reverse namespace.name to “name namespace”)
Human-readable name
dehumanifyMinecraftName
Converts a human-readable name to a Minecraft technical name.The human-readable name
Technical name with minecraft: namespace
javascriptifyName
Converts a string to a valid JavaScript identifier.String to convert
Whether to capitalize the first character
Valid JavaScript identifier
humanifyJsName
Converts a JavaScript identifier to a human-readable string.JavaScript identifier
Human-readable string
replaceAll
Replaces all occurrences of a token in a string.String to process
Token to find
Replacement token
Processed string
JSON Processing
fixJsonContent
Fixes common JSON issues like comments and trailing commas.JSON string to fix
Options object with
whitespace and trailingCommas boolean flagsFixed JSON string
consistentStringify
Stringifies an object with consistent property ordering.Object to stringify
Consistently formatted JSON string
parseJson
Safely parses a JSON string.JSON string to parse
Parsed object, or undefined on error
getJsonObject
Parses JSON with automatic comment/comma fixing.JSON string (may contain comments)
Parsed object, or undefined on error
UUID Generation
createUuid
Generates a random UUID v4.UUID string (e.g., “550e8400-e29b-41d4-a716-446655440000”)
canonicalizeUuid
Normalizes a UUID to lowercase and trimmed.UUID to normalize
Normalized UUID
uuidEqual
Compares two UUIDs for equality (case-insensitive).First UUID
Second UUID
True if UUIDs are equal
Encoding and Conversion
uint8ArrayToBase64
Converts a Uint8Array to base64 string.Byte array to convert
Base64-encoded string
base64ToUint8Array
Converts a base64 string to Uint8Array.Base64-encoded string
Decoded byte array
readStringUTF8
Reads a UTF-8 encoded string from a DataView.Buffer containing the string
Offset to start reading from
Number of bytes to read
Object with the decoded string and bytes read
Date and Time
getDateStr
Formats a date as a compact string (YYYYMMDDHHmmss).Date to format
Formatted date string
getDateFromStr
Parses a compact date string (YYYYMMDDHHmmss).Date string to parse
Parsed Date object
getFriendlySummaryHoursMinutes
Formats a date as friendly time (HH:MM 12-hour format).Date to format
Formatted time string
Validation
isNumeric
Checks if a string contains only numeric characters.String to check
True if numeric
isAlphaNumeric
Checks if a string contains only alphanumeric characters.String to check
True if alphanumeric
isValidUuid
Checks if a string is a valid UUID format.String to validate
True if valid UUID
String Formatting
ensureEndsWithSlash
Ensures a path ends with a forward slash.Path to process
Path with trailing slash
ensureStartsWithSlash
Ensures a path starts with a forward slash.Path to process
Path with leading slash
frontPadToLength
Pads a value to a specific length with a character.Value to pad
Target length
Padding character
Padded string
trimEllipsis
Truncates a string and adds ellipsis if too long.Text to truncate
Maximum length
Truncated text with ellipsis if needed
Random Generation
createRandomId
Generates a random alphanumeric ID.Length of the ID
Random ID string
createRandomLowerId
Generates a random lowercase alphanumeric ID.Length of the ID
Random lowercase ID
Usage Examples
Processing Minecraft Names
Safe JSON Processing
Working with UUIDs
String Formatting
Constants
MAX_JSON_SAFE_INTEGER
MIN_JSON_SAFE_INTEGER
See Also
- CreatorTools - Main application class
- Project - Project management
- ProjectItem - File management