A Swift library for reading and manipulating Minecraft Bedrock Edition world files, featuring integrated LevelDB support and NBT parsing capabilities.
- LevelDB Integration: Full-featured Swift wrapper for LevelDB operations
- NBT Support: Complete implementation of Named Binary Tag format parsing and writing
- World Management: Read and manipulate Minecraft Bedrock world files (.mcworld)
- Chunk Processing: Load and modify world chunks with block and biome data
- NetEase Support: Handle NetEase encrypted world files
- Cross-Platform: Supports iOS, iOS Simulator, macOS (Intel & Apple Silicon)
Add CoreBedrock to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/your-username/CoreBedrock", branch: "main")
]Then add the library to your target:
targets: [
.target(
name: "YourTarget",
dependencies: ["CoreBedrock"]
)
]import CoreBedrock
// Open a Minecraft world and access its database
let worldURL = URL(fileURLWithPath: "/path/to/world")
let world = try MCWorld(from: worldURL, meta: nil)
let db = world.database // LevelKeyValueStore protocol
// Basic operations
try db.putData(Data("myValue".utf8), forKey: Data("myKey".utf8))
let value = try db.data(forKey: Data("myKey".utf8))
try db.removeValue(forKey: Data("myKey".utf8))
// Iterate through database entries
let iterator = try db.makeIterator()
iterator.seekToFirst()
while iterator.valid() {
let key = iterator.key()
let value = iterator.value()
// Process key-value pair
iterator.next()
}
// Batch operations
let batch = LvDBWriteBatch()
batch.put(Data("key1".utf8), value: Data("value1".utf8))
batch.remove(Data("key2".utf8))
try db.writeBatch(batch)
// Close the database when done
world.closeDB()Note:
LvDB,LvDBIteratorandLvDBWriteBatchare re-exported through CoreBedrock for advanced workflows, allowing direct access to these types without importing LvDBWrapper.
import CoreBedrock
// Create NBT tags
let compound = CompoundTag()
compound["playerName"] = StringTag("Steve")
compound["level"] = IntTag(42)
// Write to binary data
let writer = CBTagWriter()
try writer.write(tag: StringTag(name: "name", "value"))
let data: Data = writer.toData()
// Read from binary data
let reader = CBTagReader(data: data)
let readTag: NBT? = try reader.readNext()import CoreBedrock
// Open a Minecraft world
let worldURL = URL(fileURLWithPath: "/path/to/world")
let world = try MCWorld(from: worldURL, meta: nil)
// Access world metadata
print("World name: \(world.worldName)")
print("Game mode: \(world.meta.gameMode)")
// Close the database when done
world.closeDB()CoreBedrock is designed as a unified library with the following components:
- High-level Minecraft world manipulation
- NBT parsing and writing
- World metadata management
- Chunk and block operations
- NetEase world support
- LevelDB database abstraction through the
LevelKeyValueStoreprotocol
- Low-level LevelDB C++ wrapper bundled within this package
- Provides Swift-friendly interface to LevelDB operations
- Includes binary dependencies for compression libraries (libcrc32c, libsnappy, libz, libzstd, libleveldb)
- Not exposed as a separate product; consumers only need to add CoreBedrock to their dependencies
- Key types like
LvDBIteratorandLvDBWriteBatchare re-exported through CoreBedrock for advanced use cases
| iOS(arm64) | MacOS(arm64) | MacOS(x86) | iOS Simulator(arm64) | |
|---|---|---|---|---|
| libleveldb.xcframework | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
| libz.xcframework | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
| libsnappy.xcframework | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
| libzstd.xcframework | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
| libcrc32c.xcframework | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
Build XCFrameworks yourself: Run the build script to compile all library dependencies from source:
cd CoreBedrock
git submodule update --init
./Scripts/build.shThis will download and build LevelDB and compression libraries for all supported platforms.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request