SchematicDiskCache

public final class SchematicDiskCache

An on-disk cache of schematics already converted to the running server's data version. One instance covers one load pass over one loader's schematic set.

Shipped .schem files carry the Minecraft DataVersion they were saved at, which is older than the running server. WorldEdit therefore hands every block entity in every file to Mojang's DataFixerUpper on the way in. That was ~8s of a full-content start, and it does not parallelise: thread dumps show workers parked on CompletableFutures inside DFU while it builds its shared rewrite rules, so the cost is largely fixed per JVM no matter how many threads read files. It also grows with every Minecraft release, as the conversion chain from the shipped version to current gets longer.

So the converted result is written back out at the current DataVersion and reused. Entries are keyed by the source file's contents, the Minecraft data version and the WorldEdit version, so editing a schematic, updating the server or updating WorldEdit all miss and reconvert. Each entry is also proven equal to its source before it is published (see writeCache). A miss, an unreadable entry, or any failure to write one falls back to reading the original — the cache is only ever an optimisation, never the source of truth.

Constructors

Link copied to clipboard
public void SchematicDiskCache(File cacheFolder)

Types

Link copied to clipboard
public final class LoadedClipboard extends Record
Link copied to clipboard
public final class SourceIdentity extends Record
The identity and parsed value always describe the same captured bytes.

Functions

Link copied to clipboard
public static File componentCacheFolder()
Link copied to clipboard
public int filesRead()
How many files this instance actually read, whether from a cache entry or the original — that is, files the caller's in-memory clipboard cache could not vouch for.
Link copied to clipboard
public Clipboard load(File schematicFile)
Loads a schematic, going through the on-disk cache of already-converted copies.
Link copied to clipboard
Link copied to clipboard
public static File moduleCacheFolder()
Link copied to clipboard
public void pruneStaleEntries(Collection<File> schematicFiles)

public void pruneStaleEntries(Collection<File> schematicFiles, Runnable cancellationCheck)
Deletes cache entries that no schematic currently maps to.
Link copied to clipboard
public static File structureCacheFolder()
The cache folder for the structure schematic loader.