How openysm/ysmparser works
Purpose and entry points
YSMParser is a C++20 offline converter/decryptor for encrypted Yes Steve Model (.ysm) assets. It restores Blockbench-compatible project content, including models, animations, textures, sounds, metadata, and reconstructed editable geometry. The native CLI entry point is YSMParser/main.cpp; parser APIs are exposed through YSMParser/parsers/YSMParser.hpp. Java and browser consumers are supported through JNI and a small web wrapper: java/com/ysm/parser/YSMParser.java, web/app.js.
Build and delivery boundary
CMake is the build orchestrator for native and Emscripten/WASM targets. Root build definitions and target presets are in CMakeLists.txt, CMakePresets.json, and YSMParser/CMakeLists.txt. The repository ships vendored native dependencies rather than relying on runtime package services. Release automation is GitHub Actions at .github/workflows/release.yml; no backend or database service is represented.
CLI orchestration
The CLI accepts input/output directories, verbosity, and thread-count controls, then processes .ysm files in an input directory. YSMParser/main.cpp is the application boundary and uses the bundled command-line parser in YSMParser/CLI11.hpp. Control moves from filesystem-oriented batch orchestration into the parser facade, which should isolate callers from format-specific implementations.
Parser facade and binary reading
YSMParser/parsers/YSMParser.cpp / YSMParser/parsers/YSMParser.hpp form the central dispatch layer. They receive encrypted model input, identify/select the applicable format parser, and produce restored project output. YSMParser/parsers/BufferReader.hpp is the low-level binary boundary: format decoders should consume structured values through it rather than manipulate raw buffers throughout the stack. Parse failures cross a dedicated error boundary at YSMParser/parsers/exceptions/ParserException.hpp.
Versioned format pipeline
Separate implementations preserve format-specific encryption and serialization behavior:
• V1: YSMParser/parsers/YSMParserV1.cpp, YSMParser/parsers/YSMParserV1.hpp
• V2: YSMParser/parsers/YSMParserV2.cpp, YSMParser/parsers/YSMParserV2.hpp
• V3: YSMParser/parsers/v3/YSMParserV3.cpp, YSMParser/parsers/v3/YSMParserV3.hpp
V3 further separates header interpretation and player texture extraction into YSMParser/parsers/v3/YSGPHeaderParser.hpp and YSMParser/parsers/v3/PlayerTextureCollector.hpp. The principal flow is encrypted bytes → version/header interpretation → version-specific decryption/decompression → decoded project assets and JSON/Blockbench reconstruction.
Cryptography, compression, and asset codecs
Shared cryptographic operations are centralized in YSMParser/algorithms/CryptoAlgorithms.cpp and YSMParser/algorithms/CryptoAlgorithms.hpp, keeping cipher/key derivation behavior outside version parsers. Compression support is wrapped by YSMParser/algorithms/YsmZstd.hpp. Vendored implementations include AES, XChaCha20, CityHash, MD5, zlib, zstd, base64, fast PNG, and JSON—for example external/AES/src/AES.cpp, external/xchacha20/src/xchacha20.cc, and external/zstd/lib/zstd.h.
Native interop and platform targets
JNI adapters expose parser and algorithm capabilities to Java: YSMParser/parsers/YSMParserJNI.cpp and YSMParser/algorithms/NativeAlgorithmsJNI.cpp, with Java-facing declarations in java/com/ysm/parser/YSMNative.java. Platform portability is consolidated in YSMParser/platform/PlatformCompat.hpp. Emscripten builds make the same core suitable for Node/WASM and browser use; web/index.html and web/app.js are the browser-facing host layer rather than a server application.
Main entry points: YSMParser.cpp Parser facade · CMakeLists.txt CMake targets · YSMParserV1.cpp V1 decoder · YSMParserV2.cpp V2 decoder
Components 16
Build & Delivery
- CMake targets · Builds native and Emscripten/WASM targets.
CMakeLists.txt - Release workflow
.github/workflows/release.yml
Consumer Hosts
- Native CLI · Batch-converts .ysm files from input directories.
YSMParser/main.cpp - Java API
java/com/ysm/parser/YSMParser.java - Browser wrapper
web/app.js - JNI adapters · Exposes parser and algorithm capabilities to Java.
YSMParser/parsers/YSMParserJNI.cpp
Parser Core
- Parser facade · Selects a format decoder and returns restored project output.
YSMParser/parsers/YSMParser.cpp - Buffer reader
YSMParser/parsers/BufferReader.hpp - Parser errors
YSMParser/parsers/exceptions/ParserException.hpp
Versioned Decoders
- V1 decoder
YSMParser/parsers/YSMParserV1.cpp - V2 decoder
YSMParser/parsers/YSMParserV2.cpp - V3 decoder · Interprets headers and extracts player textures before reconstruction.
YSMParser/parsers/v3/YSMParserV3.cpp
Shared Native Services
- Crypto algorithms · Centralizes cipher and key-derivation operations.
YSMParser/algorithms/CryptoAlgorithms.cpp - Zstd wrapper
YSMParser/algorithms/YsmZstd.hpp - Platform compatibility
YSMParser/platform/PlatformCompat.hpp - Vendored codecs · Bundled AES, XChaCha20, zstd, image, hash, and JSON implementations.
external/AES/src/AES.cpp
Connections 23
- Release workflow → CMake targets: builds releases
- CMake targets → Native CLI: builds native
- CMake targets → Browser wrapper: builds WASM host
- CMake targets → Platform compatibility: selects targets
- Native CLI → Parser facade: converts batch inputs
- Java API → JNI adapters: calls native
- JNI adapters → Parser facade: invokes parser
- Browser wrapper → Parser facade: uses WASM core
- Parser facade → V1 decoder: dispatches V1
- Parser facade → V2 decoder: dispatches V2
- Parser facade → V3 decoder: dispatches V3
- Parser facade → Parser errors: reports failures
- V1 decoder → Buffer reader: reads bytes
- V2 decoder → Buffer reader: reads bytes
- V3 decoder → Buffer reader: reads bytes
- V1 decoder → Crypto algorithms: decrypts
- V2 decoder → Crypto algorithms: decrypts
- V3 decoder → Crypto algorithms: decrypts
- V1 decoder → Zstd wrapper: decompresses
- V2 decoder → Zstd wrapper: decompresses
- V3 decoder → Zstd wrapper: decompresses
- Crypto algorithms → Vendored codecs: uses implementations
- Zstd wrapper → Vendored codecs: uses zstd