mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2024-11-21 20:56:14 +00:00
47 lines
2.2 KiB
Diff
47 lines
2.2 KiB
Diff
From fb7a9453597b28375b81406837c17001302a7647 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <git@md-5.net>
|
|
Date: Tue, 19 Feb 2019 22:30:00 +1100
|
|
Subject: [PATCH] Allow Reading Old Large Chunks
|
|
|
|
The size of chunks in the region format is overdetermined. In particular their size on disk is indicated by both a sector count in the header, and actual size in the body.
|
|
If their size would overflow the header field (>= 255 sectors), it can just be read directly from the body instead.
|
|
|
|
This code/concept was adapted from MinecraftForge.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
index cd9dc278cd..072f07e270 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
@@ -90,6 +90,14 @@ public class RegionFile implements AutoCloseable {
|
|
if (l != 0) {
|
|
int i1 = getSectorNumber(l);
|
|
int j1 = getNumSectors(l);
|
|
+ // Spigot start
|
|
+ if (j1 == 255) {
|
|
+ // We're maxed out, so we need to read the proper length from the section
|
|
+ ByteBuffer realLen = ByteBuffer.allocate(4);
|
|
+ this.file.read(realLen, i1 * 4096);
|
|
+ j1 = (realLen.getInt(0) + 4) / 4096 + 1;
|
|
+ }
|
|
+ // Spigot end
|
|
|
|
if (i1 < 2) {
|
|
RegionFile.LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", new Object[]{path, k, i1});
|
|
@@ -129,6 +137,13 @@ public class RegionFile implements AutoCloseable {
|
|
} else {
|
|
int j = getSectorNumber(i);
|
|
int k = getNumSectors(i);
|
|
+ // Spigot start
|
|
+ if (k == 255) {
|
|
+ ByteBuffer realLen = ByteBuffer.allocate(4);
|
|
+ this.file.read(realLen, j * 4096);
|
|
+ k = (realLen.getInt(0) + 4) / 4096 + 1;
|
|
+ }
|
|
+ // Spigot end
|
|
int l = k * 4096;
|
|
ByteBuffer bytebuffer = ByteBuffer.allocate(l);
|
|
|
|
--
|
|
2.47.0
|
|
|