mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Extend Region files to support >1MB per chunk.
If the 'sector count' is 255, ask the compressed data header for the proper length.
This commit is contained in:
1 parent
d5ff207fab
commit
ed67b6fd31
1 file changed
+101
-1
@@ -1,6 +1,44 @@
|
||||
--- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
|
||||
+++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
|
||||
@@ -95,6 +95,12 @@
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
public class RegionFile
|
||||
{
|
||||
+ // Minecraft is limited to 256 sections per chunk. So 1MB. This can easily be override.
|
||||
+ // So we extend this to use the REAL size when the count is maxed by seeking to that section and reading the length.
|
||||
+ private static final boolean FORGE_ENABLE_EXTENDED_SAVE = Boolean.parseBoolean(System.getProperty("forge.enableExtendedSave", "true"));
|
||||
private static final byte[] field_76720_a = new byte[4096];
|
||||
private final File field_76718_b;
|
||||
private RandomAccessFile field_76719_c;
|
||||
@@ -74,13 +77,25 @@
|
||||
int k = this.field_76719_c.readInt();
|
||||
this.field_76716_d[j1] = k;
|
||||
|
||||
- if (k != 0 && (k >> 8) + (k & 255) <= this.field_76714_f.size())
|
||||
+ int length = k & 255;
|
||||
+ if (length == 255)
|
||||
{
|
||||
- for (int l = 0; l < (k & 255); ++l)
|
||||
+ if ((k >> 8) <= this.field_76714_f.size())
|
||||
+ { // We're maxed out, so we need to read the proper length from the section
|
||||
+ this.field_76719_c.seek((k >> 8) * 4096);
|
||||
+ length = (this.field_76719_c.readInt() / 4096) + 1;
|
||||
+ this.field_76719_c.seek(j1 * 4 + 4); //Go back to where we were
|
||||
+ }
|
||||
+ }
|
||||
+ if (k != 0 && (k >> 8) + length <= this.field_76714_f.size())
|
||||
+ {
|
||||
+ for (int l = 0; l < length; ++l)
|
||||
{
|
||||
this.field_76714_f.set((k >> 8) + l, Boolean.valueOf(false));
|
||||
}
|
||||
}
|
||||
+ else if (length > 0)
|
||||
+ net.minecraftforge.fml.common.FMLLog.log.warn("Invalid chunk: ({}, {}) Offset: {} Length: {} runs off end file. {}", j1 % 32, (int)(j1 / 32), k >> 8, length, p_i2001_1_);
|
||||
}
|
||||
|
||||
for (int k1 = 0; k1 < 1024; ++k1)
|
||||
@@ -95,6 +110,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,3 +51,65 @@
|
||||
@Nullable
|
||||
|
||||
public synchronized DataInputStream func_76704_a(int p_76704_1_, int p_76704_2_)
|
||||
@@ -117,6 +138,11 @@
|
||||
{
|
||||
int j = i >> 8;
|
||||
int k = i & 255;
|
||||
+ if (k == 255)
|
||||
+ {
|
||||
+ this.field_76719_c.seek(j * 4096);
|
||||
+ k = this.field_76719_c.readInt() / 4096 + 1;
|
||||
+ }
|
||||
|
||||
if (j + k > this.field_76714_f.size())
|
||||
{
|
||||
@@ -129,10 +155,12 @@
|
||||
|
||||
if (l > 4096 * k)
|
||||
{
|
||||
+ net.minecraftforge.fml.common.FMLLog.log.warn("Invalid chunk: ({}, {}) Offset: {} Invalid Size: {}>{} {}", p_76704_1_, p_76704_2_, j, l, k * 4096, field_76718_b);
|
||||
return null;
|
||||
}
|
||||
else if (l <= 0)
|
||||
{
|
||||
+ net.minecraftforge.fml.common.FMLLog.log.warn("Invalid chunk: ({}, {}) Offset: {} Invalid Size: {} {}", p_76704_1_, p_76704_2_, j, l, field_76718_b);
|
||||
return null;
|
||||
}
|
||||
else
|
||||
@@ -179,11 +207,17 @@
|
||||
int i = this.func_76707_e(p_76706_1_, p_76706_2_);
|
||||
int j = i >> 8;
|
||||
int k = i & 255;
|
||||
+ if (k == 255)
|
||||
+ {
|
||||
+ this.field_76719_c.seek(j * 4096);
|
||||
+ k = this.field_76719_c.readInt() / 4096 + 1;
|
||||
+ }
|
||||
int l = (p_76706_4_ + 5) / 4096 + 1;
|
||||
|
||||
if (l >= 256)
|
||||
{
|
||||
- return;
|
||||
+ if (!FORGE_ENABLE_EXTENDED_SAVE) return;
|
||||
+ net.minecraftforge.fml.common.FMLLog.log.warn("Large Chunk Detected: ({}, {}) Size: {} {}", p_76706_1_, p_76706_2_, l, field_76718_b);
|
||||
}
|
||||
|
||||
if (j != 0 && k == l)
|
||||
@@ -231,7 +265,7 @@
|
||||
if (j1 >= l)
|
||||
{
|
||||
j = l1;
|
||||
- this.func_76711_a(p_76706_1_, p_76706_2_, l1 << 8 | l);
|
||||
+ this.func_76711_a(p_76706_1_, p_76706_2_, l1 << 8 | (l > 255 ? 255 : l));
|
||||
|
||||
for (int j2 = 0; j2 < l; ++j2)
|
||||
{
|
||||
@@ -253,7 +287,7 @@
|
||||
|
||||
this.field_76715_g += 4096 * l;
|
||||
this.func_76712_a(j, p_76706_3_, p_76706_4_);
|
||||
- this.func_76711_a(p_76706_1_, p_76706_2_, j << 8 | l);
|
||||
+ this.func_76711_a(p_76706_1_, p_76706_2_, j << 8 | (l > 255 ? 255 : l));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user