Class RegionFile
- java.lang.Object
-
- net.minecraft.world.chunk.storage.RegionFile
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class RegionFile extends java.lang.Object implements java.lang.AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
RegionFile.ChunkBuffer
(package private) static interface
RegionFile.ICompleteCallback
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.Path
externalFileDir
private java.nio.channels.FileChannel
file
private java.nio.ByteBuffer
header
private static org.apache.logging.log4j.Logger
LOGGER
private java.nio.IntBuffer
offsets
private static java.nio.ByteBuffer
PADDING_BUFFER
private java.nio.IntBuffer
timestamps
protected RegionBitmap
usedSectors
private RegionFileVersion
version
-
Constructor Summary
Constructors Constructor Description RegionFile(java.io.File p_i231893_1_, java.io.File p_i231893_2_, boolean p_i231893_3_)
RegionFile(java.nio.file.Path p_i231894_1_, java.nio.file.Path p_i231894_2_, RegionFileVersion p_i231894_3_, boolean p_i231894_4_)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private java.io.DataInputStream
createChunkInputStream(ChunkPos p_227134_1_, byte p_227134_2_, java.io.InputStream p_227134_3_)
private java.io.DataInputStream
createExternalChunkInputStream(ChunkPos p_227133_1_, byte p_227133_2_)
private java.nio.ByteBuffer
createExternalStub()
private static java.io.ByteArrayInputStream
createStream(java.nio.ByteBuffer p_227137_0_, int p_227137_1_)
boolean
doesChunkExist(ChunkPos p_222662_1_)
void
flush()
java.io.DataInputStream
getChunkDataInputStream(ChunkPos p_222666_1_)
java.io.DataOutputStream
getChunkDataOutputStream(ChunkPos p_222661_1_)
private java.nio.file.Path
getExternalChunkPath(ChunkPos p_227145_1_)
private static byte
getExternalChunkVersion(byte p_227141_0_)
private static int
getNumSectors(int p_227131_0_)
private int
getOffset(ChunkPos p_222660_1_)
private static int
getOffsetIndex(ChunkPos p_222668_0_)
private static int
getSectorNumber(int p_227142_0_)
boolean
hasChunk(ChunkPos p_222667_1_)
private static boolean
isExternalStreamChunk(byte p_227130_0_)
private int
packSectorOffset(int p_227132_1_, int p_227132_2_)
private void
padToFullSector()
private static int
sizeToSectors(int p_227144_0_)
protected void
write(ChunkPos p_227135_1_, java.nio.ByteBuffer p_227135_2_)
private void
writeHeader()
private RegionFile.ICompleteCallback
writeToExternalFile(java.nio.file.Path p_227138_1_, java.nio.ByteBuffer p_227138_2_)
-
-
-
Field Detail
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER
-
PADDING_BUFFER
private static final java.nio.ByteBuffer PADDING_BUFFER
-
file
private final java.nio.channels.FileChannel file
-
externalFileDir
private final java.nio.file.Path externalFileDir
-
version
private final RegionFileVersion version
-
header
private final java.nio.ByteBuffer header
-
offsets
private final java.nio.IntBuffer offsets
-
timestamps
private final java.nio.IntBuffer timestamps
-
usedSectors
protected final RegionBitmap usedSectors
-
-
Constructor Detail
-
RegionFile
public RegionFile(java.io.File p_i231893_1_, java.io.File p_i231893_2_, boolean p_i231893_3_) throws java.io.IOException
- Throws:
java.io.IOException
-
RegionFile
public RegionFile(java.nio.file.Path p_i231894_1_, java.nio.file.Path p_i231894_2_, RegionFileVersion p_i231894_3_, boolean p_i231894_4_) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getExternalChunkPath
private java.nio.file.Path getExternalChunkPath(ChunkPos p_227145_1_)
-
getChunkDataInputStream
@Nullable public java.io.DataInputStream getChunkDataInputStream(ChunkPos p_222666_1_) throws java.io.IOException
- Throws:
java.io.IOException
-
isExternalStreamChunk
private static boolean isExternalStreamChunk(byte p_227130_0_)
-
getExternalChunkVersion
private static byte getExternalChunkVersion(byte p_227141_0_)
-
createChunkInputStream
@Nullable private java.io.DataInputStream createChunkInputStream(ChunkPos p_227134_1_, byte p_227134_2_, java.io.InputStream p_227134_3_) throws java.io.IOException
- Throws:
java.io.IOException
-
createExternalChunkInputStream
@Nullable private java.io.DataInputStream createExternalChunkInputStream(ChunkPos p_227133_1_, byte p_227133_2_) throws java.io.IOException
- Throws:
java.io.IOException
-
createStream
private static java.io.ByteArrayInputStream createStream(java.nio.ByteBuffer p_227137_0_, int p_227137_1_)
-
packSectorOffset
private int packSectorOffset(int p_227132_1_, int p_227132_2_)
-
getNumSectors
private static int getNumSectors(int p_227131_0_)
-
getSectorNumber
private static int getSectorNumber(int p_227142_0_)
-
sizeToSectors
private static int sizeToSectors(int p_227144_0_)
-
doesChunkExist
public boolean doesChunkExist(ChunkPos p_222662_1_)
-
getChunkDataOutputStream
public java.io.DataOutputStream getChunkDataOutputStream(ChunkPos p_222661_1_) throws java.io.IOException
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected void write(ChunkPos p_227135_1_, java.nio.ByteBuffer p_227135_2_) throws java.io.IOException
- Throws:
java.io.IOException
-
createExternalStub
private java.nio.ByteBuffer createExternalStub()
-
writeToExternalFile
private RegionFile.ICompleteCallback writeToExternalFile(java.nio.file.Path p_227138_1_, java.nio.ByteBuffer p_227138_2_) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHeader
private void writeHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
getOffset
private int getOffset(ChunkPos p_222660_1_)
-
hasChunk
public boolean hasChunk(ChunkPos p_222667_1_)
-
getOffsetIndex
private static int getOffsetIndex(ChunkPos p_222668_0_)
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.io.IOException
-
padToFullSector
private void padToFullSector() throws java.io.IOException
- Throws:
java.io.IOException
-
-