Skip to content

Instantly share code, notes, and snippets.

@Spottedleaf
Created May 13, 2019 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Spottedleaf/dec40400015df81ad2081df35905e3a8 to your computer and use it in GitHub Desktop.
Save Spottedleaf/dec40400015df81ad2081df35905e3a8 to your computer and use it in GitHub Desktop.
private RegionFile a(ChunkCoordIntPair chunkcoordintpair) throws IOException {
long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i);
if (regionfile != null) {
return regionfile;
} else {
if (this.cache.size() >= 256) {
this.cache.removeLast(); // The relevant line.
}
if (!this.a.exists()) {
this.a.mkdirs();
}
File file = new File(this.a, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca");
RegionFile regionfile1 = new RegionFile(file);
this.cache.putAndMoveToFirst(i, regionfile1);
return regionfile1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment