mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
46 lines
2.2 KiB
Diff
46 lines
2.2 KiB
Diff
From 8f4768942ce3a6434ec822a57889831994c432df 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 f092322bd..4ae293661 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
|
|
@@ -87,6 +87,14 @@ public class RegionFile implements AutoCloseable {
|
|
if (l != 0) {
|
|
int i1 = b(l);
|
|
int j1 = a(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", path, k, i1);
|
|
@@ -122,6 +130,13 @@ public class RegionFile implements AutoCloseable {
|
|
} else {
|
|
int j = b(i);
|
|
int k = a(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.25.1
|
|
|