Files
2020-10-30 11:35:16 +08:00

856 lines
25 KiB
Diff

--- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
+++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
@@ -1,14 +1,12 @@
package net.minecraft.world.chunk.storage;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel.MapMode;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
@@ -16,359 +14,528 @@
public class RegionFile
{
- private static final byte[] emptySector = new byte[4096];
- private final File fileName;
- private RandomAccessFile dataFile;
- private final int[] offsets = new int[1024];
- private final int[] chunkTimestamps = new int[1024];
- private ArrayList sectorFree;
- private int sizeDelta;
- private long lastModified;
- private static final String __OBFID = "CL_00000381";
+ private static final byte[] emptySector = new byte[4096]; // Spigot - note: if this ever changes to not be 4096 bytes, update constructor!
+ private final File fileName;
+ private final int[] offsets = new int[1024];
+ private final int[] chunkTimestamps = new int[1024];
+ private ArrayList sectorFree;
+ private int sizeDelta;
+ private long lastModified;
+ private static final String __OBFID = "CL_00000381";
+
+ // Thermos - this mustn't be modified during runtime or we could change the mode while the region file was in use....that could cause horrible errors
+ private boolean ramMode = false && net.minecraftforge.cauldron.configuration.CauldronConfig.instance.ramChunks.getValue();
+
+ // Le RAMdisque
+ private MappedByteBuffer dataBuffer = null;
+ private RandomAccessFile dataFile = null;
+
+ public RegionFile(File p_i2001_1_)
+ {
+ this.fileName = p_i2001_1_;
+ this.sizeDelta = 0;
- public RegionFile(File p_i2001_1_)
- {
- this.fileName = p_i2001_1_;
- this.sizeDelta = 0;
+ try
+ {
+ if (p_i2001_1_.exists())
+ {
+ this.lastModified = p_i2001_1_.lastModified();
+ }
- try
- {
- if (p_i2001_1_.exists())
- {
- this.lastModified = p_i2001_1_.lastModified();
- }
+ RandomAccessFile dataFile = new RandomAccessFile(p_i2001_1_, "rw");
+ if (dataFile.length() - 120000000L < 16384L) // Refuse to use RAM chunks if the 12MB buffer is unable to keep 16KB free at its end for the region file
+ {
+ this.ramMode = false;
+ }
+ // Thermos drop it into the RAM, give it a 12MB cap
+ this.dataFile = dataFile;
+ if(ramMode)
+ {
+ this.dataBuffer = dataFile.getChannel().map(MapMode.READ_WRITE, 0, 120000000); // Only load up if RAM mode is enabled
+ int i;
+ if (this.dataBuffer.limit() < 4096L)
+ {
+ // Spigot - more efficient chunk zero'ing
+ this.dataBuffer.put(RegionFile.emptySector);
+ this.dataBuffer.put(RegionFile.emptySector);
- this.dataFile = new RandomAccessFile(p_i2001_1_, "rw");
- int i;
+ this.sizeDelta += 8192;
+ }
- if (this.dataFile.length() < 4096L)
- {
- for (i = 0; i < 1024; ++i)
- {
- this.dataFile.writeInt(0);
- }
+ if ((this.dataBuffer.limit() & 4095L) != 0L)
+ {
+ for (i = 0; (long)i < (this.dataBuffer.limit() & 4095L); ++i)
+ {
+ this.dataBuffer.put((byte)0);
+ }
+ }
- for (i = 0; i < 1024; ++i)
- {
- this.dataFile.writeInt(0);
- }
+ i = (int)this.dataBuffer.limit() / 4096;
+ this.sectorFree = new ArrayList(i);
+ int j;
- this.sizeDelta += 8192;
- }
+ for (j = 0; j < i; ++j)
+ {
+ this.sectorFree.add(Boolean.valueOf(true));
+ }
- if ((this.dataFile.length() & 4095L) != 0L)
- {
- for (i = 0; (long)i < (this.dataFile.length() & 4095L); ++i)
- {
- this.dataFile.write(0);
- }
- }
+ this.sectorFree.set(0, Boolean.valueOf(false));
+ this.sectorFree.set(1, Boolean.valueOf(false));
+ this.dataBuffer.position(0);
- i = (int)this.dataFile.length() / 4096;
- this.sectorFree = new ArrayList(i);
- int j;
+ int k;
- for (j = 0; j < i; ++j)
- {
- this.sectorFree.add(Boolean.valueOf(true));
- }
+ for (j = 0; j < 1024; ++j)
+ {
+ k = this.dataBuffer.getInt();
+ this.offsets[j] = k;
- this.sectorFree.set(0, Boolean.valueOf(false));
- this.sectorFree.set(1, Boolean.valueOf(false));
- this.dataFile.seek(0L);
- int k;
+ if (k != 0 && (k >> 8) + (k & 255) <= this.sectorFree.size())
+ {
+ for (int l = 0; l < (k & 255); ++l)
+ {
+ this.sectorFree.set((k >> 8) + l, Boolean.valueOf(false));
+ }
+ }
+ }
- for (j = 0; j < 1024; ++j)
- {
- k = this.dataFile.readInt();
- this.offsets[j] = k;
+ for (j = 0; j < 1024; ++j)
+ {
+ k = this.dataBuffer.getInt();
+ this.chunkTimestamps[j] = k;
+ }
+ }
+ else
+ {
+ int i;
+ if (this.dataFile.length() < 4096L)
+ {
+ // Spigot - more efficient chunk zero'ing
+ this.dataFile.write(RegionFile.emptySector); // Spigot
+ this.dataFile.write(RegionFile.emptySector); // Spigot
- if (k != 0 && (k >> 8) + (k & 255) <= this.sectorFree.size())
- {
- for (int l = 0; l < (k & 255); ++l)
- {
- this.sectorFree.set((k >> 8) + l, Boolean.valueOf(false));
- }
- }
- }
+ this.sizeDelta += 8192;
+ }
- for (j = 0; j < 1024; ++j)
- {
- k = this.dataFile.readInt();
- this.chunkTimestamps[j] = k;
- }
- }
- catch (IOException ioexception)
- {
- ioexception.printStackTrace();
- }
- }
+ if ((this.dataFile.length() & 4095L) != 0L)
+ {
+ for (i = 0; (long)i < (this.dataFile.length() & 4095L); ++i)
+ {
+ this.dataFile.write(0);
+ }
+ }
- // This is a copy (sort of) of the method below it, make sure they stay in sync
- public synchronized boolean chunkExists(int x, int z)
- {
- if (this.outOfBounds(x, z)) return false;
+ i = (int)this.dataFile.length() / 4096;
+ this.sectorFree = new ArrayList(i);
+ int j;
- try
- {
- int offset = this.getOffset(x, z);
+ for (j = 0; j < i; ++j)
+ {
+ this.sectorFree.add(Boolean.valueOf(true));
+ }
- if (offset == 0) return false;
+ this.sectorFree.set(0, Boolean.valueOf(false));
+ this.sectorFree.set(1, Boolean.valueOf(false));
+ this.dataFile.seek(0L);
- int sectorNumber = offset >> 8;
- int numSectors = offset & 255;
+ int k;
+ // Paper Start
+ ByteBuffer header = ByteBuffer.allocate(8192);
+ while (header.hasRemaining()) {
+ if (this.dataFile.getChannel().read(header) == -1) throw new EOFException();
+ }
+ header.clear();
+ IntBuffer headerAsInts = header.asIntBuffer();
+ // Paper End
+ for (j = 0; j < 1024; ++j)
+ {
+ k = headerAsInts.get(); // Paper
+ this.offsets[j] = k;
- if (sectorNumber + numSectors > this.sectorFree.size()) return false;
+ if (k != 0 && (k >> 8) + (k & 255) <= this.sectorFree.size())
+ {
+ for (int l = 0; l < (k & 255); ++l)
+ {
+ this.sectorFree.set((k >> 8) + l, Boolean.valueOf(false));
+ }
+ }
+ }
- this.dataFile.seek((long)(sectorNumber * 4096));
- int length = this.dataFile.readInt();
+ for (j = 0; j < 1024; ++j)
+ {
+ k = headerAsInts.get(); // Paper
+ this.chunkTimestamps[j] = k;
+ }
+ }
+ }
+ catch (IOException ioexception)
+ {
+ ioexception.printStackTrace();
+ }
+ }
- if (length > 4096 * numSectors || length <= 0) return false;
+ // This is a copy (sort of) of the method below it, make sure they stay in sync
+ public synchronized boolean chunkExists(int x, int z)
+ {
+ if (this.outOfBounds(x, z)) return false;
- byte version = this.dataFile.readByte();
+ try
+ {
+ int offset = this.getOffset(x, z);
+ if (offset == 0) return false;
- if (version == 1 || version == 2) return true;
- }
- catch (IOException ioexception)
- {
- return false;
- }
+ int sectorNumber = offset >> 8;
+ int numSectors = offset & 255;
- return false;
- }
+ if (sectorNumber + numSectors > this.sectorFree.size()) return false;
- public synchronized DataInputStream getChunkDataInputStream(int p_76704_1_, int p_76704_2_)
- {
- if (this.outOfBounds(p_76704_1_, p_76704_2_))
- {
- return null;
- }
- else
- {
- try
- {
- int k = this.getOffset(p_76704_1_, p_76704_2_);
+ if(ramMode)
+ {
+ this.dataBuffer.position(sectorNumber * 4096);
+ int length = this.dataBuffer.getInt();
+ if(length > 4096 * numSectors || length <= 0) return false;
- if (k == 0)
- {
- return null;
- }
- else
- {
- int l = k >> 8;
- int i1 = k & 255;
+ byte version = this.dataBuffer.get();
- if (l + i1 > this.sectorFree.size())
- {
- return null;
- }
- else
- {
- this.dataFile.seek((long)(l * 4096));
- int j1 = this.dataFile.readInt();
+ if (version == 1 || version == 2) return true;
+ }
+ else
+ {
+ this.dataFile.seek((long)(sectorNumber * 4096));
+ int length = this.dataFile.readInt();
- if (j1 > 4096 * i1)
- {
- return null;
- }
- else if (j1 <= 0)
- {
- return null;
- }
- else
- {
- byte b0 = this.dataFile.readByte();
- byte[] abyte;
+ if (length > 4096 * numSectors || length <= 0) return false;
- if (b0 == 1)
- {
- abyte = new byte[j1 - 1];
- this.dataFile.read(abyte);
- return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte))));
- }
- else if (b0 == 2)
- {
- abyte = new byte[j1 - 1];
- this.dataFile.read(abyte);
- return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte))));
- }
- else
- {
- return null;
- }
- }
- }
- }
- }
- catch (IOException ioexception)
- {
- return null;
- }
- }
- }
+ byte version = this.dataFile.readByte();
- public DataOutputStream getChunkDataOutputStream(int p_76710_1_, int p_76710_2_)
- {
- return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_)));
- }
+ if (version == 1 || version == 2) return true;
+ }
+ }
+ catch (IOException ioexception)
+ {
+ return false;
+ }
- protected synchronized void write(int p_76706_1_, int p_76706_2_, byte[] p_76706_3_, int p_76706_4_)
- {
- try
- {
- int l = this.getOffset(p_76706_1_, p_76706_2_);
- int i1 = l >> 8;
- int j1 = l & 255;
- int k1 = (p_76706_4_ + 5) / 4096 + 1;
+ return false;
+ }
- if (k1 >= 256)
- {
- return;
- }
+ public synchronized DataInputStream getChunkDataInputStream(int p_76704_1_, int p_76704_2_)
+ {
+ if (this.outOfBounds(p_76704_1_, p_76704_2_))
+ {
+ return null;
+ }
+ else
+ {
+ try
+ {
+ int k = this.getOffset(p_76704_1_, p_76704_2_);
- if (i1 != 0 && j1 == k1)
- {
- this.write(i1, p_76706_3_, p_76706_4_);
- }
- else
- {
- int l1;
+ if (k == 0)
+ {
+ return null;
+ }
+ else
+ {
+ int l = k >> 8;
+ int i1 = k & 255;
- for (l1 = 0; l1 < j1; ++l1)
- {
- this.sectorFree.set(i1 + l1, Boolean.valueOf(true));
- }
+ if (l + i1 > this.sectorFree.size())
+ {
+ return null;
+ }
+ else if(ramMode)
+ {
+ this.dataBuffer.position((l * 4096));
+ int j1 = this.dataBuffer.getInt();
- l1 = this.sectorFree.indexOf(Boolean.valueOf(true));
- int i2 = 0;
- int j2;
+ if (j1 > 4096 * i1)
+ {
+ return null;
+ }
+ else if (j1 <= 0)
+ {
+ return null;
+ }
+ else
+ {
+ byte b0 = this.dataBuffer.get();
+ byte[] abyte;
- if (l1 != -1)
- {
- for (j2 = l1; j2 < this.sectorFree.size(); ++j2)
- {
- if (i2 != 0)
- {
- if (((Boolean)this.sectorFree.get(j2)).booleanValue())
- {
- ++i2;
- }
- else
- {
- i2 = 0;
- }
- }
- else if (((Boolean)this.sectorFree.get(j2)).booleanValue())
- {
- l1 = j2;
- i2 = 1;
- }
+ if (b0 == 1)
+ {
+ abyte = new byte[j1 - 1];
+ this.dataBuffer.get(abyte);
+ return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte))));
+ }
+ else if (b0 == 2)
+ {
+ abyte = new byte[j1 - 1];
+ this.dataBuffer.get(abyte);
+ return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte))));
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ else
+ {
+ this.dataFile.seek((long)(l * 4096));
+ int j1 = this.dataFile.readInt();
- if (i2 >= k1)
- {
- break;
- }
- }
- }
+ if (j1 > 4096 * i1)
+ {
+ return null;
+ }
+ else if (j1 <= 0)
+ {
+ return null;
+ }
+ else
+ {
+ byte b0 = this.dataFile.readByte();
+ byte[] abyte;
- if (i2 >= k1)
- {
- i1 = l1;
- this.setOffset(p_76706_1_, p_76706_2_, l1 << 8 | k1);
+ if (b0 == 1)
+ {
+ abyte = new byte[j1 - 1];
+ this.dataFile.read(abyte);
+ return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte))));
+ }
+ else if (b0 == 2)
+ {
+ abyte = new byte[j1 - 1];
+ this.dataFile.read(abyte);
+ return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte))));
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ }
+ }
+ catch (IOException ioexception)
+ {
+ return null;
+ }
+ }
+ }
- for (j2 = 0; j2 < k1; ++j2)
- {
- this.sectorFree.set(i1 + j2, Boolean.valueOf(false));
- }
+ public DataOutputStream getChunkDataOutputStream(int p_76710_1_, int p_76710_2_)
+ {
+ return this.outOfBounds(p_76710_1_, p_76710_2_) ? null : new DataOutputStream(new java.io.BufferedOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(p_76710_1_, p_76710_2_)))); // Spigot - use a BufferedOutputStream to greatly improve file write performance
+ }
- this.write(i1, p_76706_3_, p_76706_4_);
- }
- else
- {
- this.dataFile.seek(this.dataFile.length());
- i1 = this.sectorFree.size();
+ protected synchronized void write(int p_76706_1_, int p_76706_2_, byte[] p_76706_3_, int p_76706_4_)
+ {
+ try
+ {
+ int l = this.getOffset(p_76706_1_, p_76706_2_);
+ int i1 = l >> 8;
+ int j1 = l & 255;
+ int k1 = (p_76706_4_ + 5) / 4096 + 1;
- for (j2 = 0; j2 < k1; ++j2)
- {
- this.dataFile.write(emptySector);
- this.sectorFree.add(Boolean.valueOf(false));
- }
+ if (k1 >= 256)
+ {
+ return;
+ }
- this.sizeDelta += 4096 * k1;
- this.write(i1, p_76706_3_, p_76706_4_);
- this.setOffset(p_76706_1_, p_76706_2_, i1 << 8 | k1);
- }
- }
+ if (i1 != 0 && j1 == k1)
+ {
+ this.write(i1, p_76706_3_, p_76706_4_);
+ }
+ else
+ {
+ int l1;
- this.setChunkTimestamp(p_76706_1_, p_76706_2_, (int)(MinecraftServer.getSystemTimeMillis() / 1000L));
- }
- catch (IOException ioexception)
- {
- ioexception.printStackTrace();
- }
- }
+ for (l1 = 0; l1 < j1; ++l1)
+ {
+ this.sectorFree.set(i1 + l1, Boolean.valueOf(true));
+ }
- private void write(int p_76712_1_, byte[] p_76712_2_, int p_76712_3_) throws IOException
- {
- this.dataFile.seek((long)(p_76712_1_ * 4096));
- this.dataFile.writeInt(p_76712_3_ + 1);
- this.dataFile.writeByte(2);
- this.dataFile.write(p_76712_2_, 0, p_76712_3_);
- }
+ l1 = this.sectorFree.indexOf(Boolean.valueOf(true));
+ int i2 = 0;
+ int j2;
- private boolean outOfBounds(int p_76705_1_, int p_76705_2_)
- {
- return p_76705_1_ < 0 || p_76705_1_ >= 32 || p_76705_2_ < 0 || p_76705_2_ >= 32;
- }
+ if (l1 != -1)
+ {
+ for (j2 = l1; j2 < this.sectorFree.size(); ++j2)
+ {
+ if (i2 != 0)
+ {
+ if (((Boolean)this.sectorFree.get(j2)).booleanValue())
+ {
+ ++i2;
+ }
+ else
+ {
+ i2 = 0;
+ }
+ }
+ else if (((Boolean)this.sectorFree.get(j2)).booleanValue())
+ {
+ l1 = j2;
+ i2 = 1;
+ }
- private int getOffset(int p_76707_1_, int p_76707_2_)
- {
- return this.offsets[p_76707_1_ + p_76707_2_ * 32];
- }
+ if (i2 >= k1)
+ {
+ break;
+ }
+ }
+ }
- public boolean isChunkSaved(int p_76709_1_, int p_76709_2_)
- {
- return this.getOffset(p_76709_1_, p_76709_2_) != 0;
- }
+ if (i2 >= k1)
+ {
+ i1 = l1;
+ this.setOffset(p_76706_1_, p_76706_2_, l1 << 8 | k1);
- private void setOffset(int p_76711_1_, int p_76711_2_, int p_76711_3_) throws IOException
- {
- this.offsets[p_76711_1_ + p_76711_2_ * 32] = p_76711_3_;
- this.dataFile.seek((long)((p_76711_1_ + p_76711_2_ * 32) * 4));
- this.dataFile.writeInt(p_76711_3_);
- }
+ for (j2 = 0; j2 < k1; ++j2)
+ {
+ this.sectorFree.set(i1 + j2, Boolean.valueOf(false));
+ }
- private void setChunkTimestamp(int p_76713_1_, int p_76713_2_, int p_76713_3_) throws IOException
- {
- this.chunkTimestamps[p_76713_1_ + p_76713_2_ * 32] = p_76713_3_;
- this.dataFile.seek((long)(4096 + (p_76713_1_ + p_76713_2_ * 32) * 4));
- this.dataFile.writeInt(p_76713_3_);
- }
+ this.write(i1, p_76706_3_, p_76706_4_);
+ }
+ else if(ramMode)
+ {
+ this.dataBuffer.position(this.dataBuffer.limit());
+ i1 = this.sectorFree.size();
- public void close() throws IOException
- {
- if (this.dataFile != null)
- {
- this.dataFile.close();
- }
- }
+ for (j2 = 0; j2 < k1; ++j2)
+ {
+ //this.dataBuffer.limit(this.dataBuffer.limit()+ emptySector.length);
+ this.dataBuffer.put(emptySector);
+ this.sectorFree.add(Boolean.valueOf(false));
+ }
- class ChunkBuffer extends ByteArrayOutputStream
- {
- private int chunkX;
- private int chunkZ;
- private static final String __OBFID = "CL_00000382";
+ this.sizeDelta += 4096 * k1;
+ this.write(i1, p_76706_3_, p_76706_4_);
+ this.setOffset(p_76706_1_, p_76706_2_, i1 << 8 | k1);
+ }
+ else
+ {
+ this.dataFile.seek(this.dataFile.length());
+ i1 = this.sectorFree.size();
- public ChunkBuffer(int p_i2000_2_, int p_i2000_3_)
- {
- super(8096);
- this.chunkX = p_i2000_2_;
- this.chunkZ = p_i2000_3_;
- }
+ for (j2 = 0; j2 < k1; ++j2)
+ {
+ this.dataFile.write(emptySector);
+ this.sectorFree.add(Boolean.valueOf(false));
+ }
- public void close() throws IOException
- {
- RegionFile.this.write(this.chunkX, this.chunkZ, this.buf, this.count);
- }
- }
+ this.sizeDelta += 4096 * k1;
+ this.write(i1, p_76706_3_, p_76706_4_);
+ this.setOffset(p_76706_1_, p_76706_2_, i1 << 8 | k1);
+ }
+ }
+
+ this.setChunkTimestamp(p_76706_1_, p_76706_2_, (int)(MinecraftServer.getSystemTimeMillis() / 1000L));
+ }
+ catch (IOException ioexception)
+ {
+ ioexception.printStackTrace();
+ }
+ }
+
+ private void write(int p_76712_1_, byte[] p_76712_2_, int p_76712_3_) throws IOException
+ {
+ if(ramMode)
+ {
+ this.dataBuffer.position((p_76712_1_ * 4096));
+ this.dataBuffer.putInt(p_76712_3_ + 1);
+ this.dataBuffer.put( (byte) 2);
+ this.dataBuffer.put(p_76712_2_, 0, p_76712_3_);
+ }
+ else
+ {
+ this.dataFile.seek((long)(p_76712_1_ * 4096));
+ this.dataFile.writeInt(p_76712_3_ + 1);
+ this.dataFile.writeByte(2);
+ this.dataFile.write(p_76712_2_, 0, p_76712_3_);
+ }
+ }
+
+ public boolean outOfBounds(int p_76705_1_, int p_76705_2_)
+ {
+ return p_76705_1_ < 0 || p_76705_1_ >= 32 || p_76705_2_ < 0 || p_76705_2_ >= 32;
+ }
+
+ public int getOffset(int p_76707_1_, int p_76707_2_)
+ {
+ return this.offsets[p_76707_1_ + p_76707_2_ * 32];
+ }
+
+ public boolean isChunkSaved(int p_76709_1_, int p_76709_2_)
+ {
+ return this.getOffset(p_76709_1_, p_76709_2_) != 0;
+ }
+
+ private void setOffset(int p_76711_1_, int p_76711_2_, int p_76711_3_) throws IOException
+ {
+ this.offsets[p_76711_1_ + p_76711_2_ * 32] = p_76711_3_;
+ if (ramMode)
+ {
+ this.dataBuffer.position(((p_76711_1_ + p_76711_2_ * 32) * 4));
+ this.dataBuffer.putInt(p_76711_3_);
+ }
+ else
+ {
+ this.dataFile.seek((long)((p_76711_1_ + p_76711_2_ * 32) * 4));
+ this.dataFile.writeInt(p_76711_3_);
+ }
+ }
+
+ private void setChunkTimestamp(int p_76713_1_, int p_76713_2_, int p_76713_3_) throws IOException
+ {
+ this.chunkTimestamps[p_76713_1_ + p_76713_2_ * 32] = p_76713_3_;
+ if (ramMode)
+ {
+ this.dataBuffer.position((4096 + (p_76713_1_ + p_76713_2_ * 32) * 4));
+ this.dataBuffer.putInt(p_76713_3_);
+ }
+ else
+ {
+ this.dataFile.seek((long)(4096 + (p_76713_1_ + p_76713_2_ * 32) * 4));
+ this.dataFile.writeInt(p_76713_3_);
+ }
+ }
+
+ public void close() throws IOException
+ {
+ if (this.ramMode)
+ {
+ if(this.dataBuffer != null)
+ {
+ this.dataBuffer.force();
+ }
+ }
+ if (this.dataFile != null)
+ {
+ this.dataFile.close();
+ }
+ }
+
+ class ChunkBuffer extends ByteArrayOutputStream
+ {
+ private int chunkX;
+ private int chunkZ;
+ private static final String __OBFID = "CL_00000382";
+
+ public ChunkBuffer(int p_i2000_2_, int p_i2000_3_)
+ {
+ super(8096);
+ this.chunkX = p_i2000_2_;
+ this.chunkZ = p_i2000_3_;
+ }
+
+ public void close() throws IOException
+ {
+ RegionFile.this.write(this.chunkX, this.chunkZ, this.buf, this.count);
+ }
+ }
}