Landscape is an alternative format for Minecraft worlds that focuses primarily on speed and simplicity originally designed for Machine server.
- Designed for large generated worlds with variable height
- Fast loading and saving times
- NBT, tile entities, ticking blocks and biomes support
- Doesn't load whole chunks but only their segments (16x16x16 sections)
- Thread-safe
- Easy to use
- Automatic memory management
Landscape is available from machine-repository-releases
<repository>
<id>machinemc-repository-releases</id>
<name>MachineMC Repository</name>
<url>https://repo.machinemc.org/releases</url>
</repository>
<dependency>
<groupId>org.machinemc</groupId>
<artifactId>landscape</artifactId>
<version>{version}</version>
</dependency>
maven {
url = uri("https://repo.machinemc.org/releases")
}
implementation("org.machinemc:landscape:{version}")
Name format: r_x_y.ls
, x and y being the Landscape coordinates
File content:
Header (12 bytes) | Lookup Table (8 bytes per segment) | Segments data |
---|---|---|
short version, int x, int y, short height | (int position, int length) per segment | data per segment |
// Creates new or loads already existing Landscape file
// Height, in this case 256, doesn't have to be specified for already existing files
Landscape landscape = Landscape.of(dir, 0, 0, (short) 256, handler);
// Loads a segment at coordinates (0, 0, 0)
Segment segment = landscape.loadSegment(0 , 0, 0);
// Reading information about block at coordinates (0, 0, 0) in the segment
String block = segment.getBlock(0, 0, 0); // getting saved block type
NBTCompound nbt = segment.getNBT(0, 0, 0); // getting NBT of the block
boolean isTicking segment.isTicking(0, 0, 0); // whether the block is saved as ticking
// Writing information about a block at coordinates (0, 0, 0) in the segment
segment.setBlock(0, 0, 0, "minecraft:cobblestone", compound, false);
// After writing all the information to the segment we need to push it to
// make sure the changes save once the landscape instance is flushed
segment.push();
// ...
// Saves all pushed and referenced segments to the file and clears segments that
// are no longer referenced in the code
landscape.flush();