IDK these errors are weird

-Changed the loading to fit the byte changes
This commit is contained in:
opfromthestart 2021-08-05 14:12:37 -04:00
parent 8bc23acb61
commit 8167c40f64

View File

@ -249,21 +249,21 @@ public class TestWorldDiskIO {
//output.mark(sectorSize*sectorLength); //output.mark(sectorSize*sectorLength);
DataOutputStream trueOutput = new DataOutputStream(Channels.newOutputStream(output.getChannel())); DataOutputStream trueOutput = new DataOutputStream(Channels.newOutputStream(output.getChannel()));
CountingOutputStream countOutput = new CountingOutputStream(trueOutput); //CountingOutputStream countOutput = new CountingOutputStream(trueOutput);
//trueOutput. //trueOutput.
ChunkIO.save(chunk, trueOutput, IOContext.SAVE); ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
writeGenerationHint(chunk, trueOutput, server); writeGenerationHint(chunk, trueOutput, server);
while (countOutput.getCount()%sectorSize != 0) { while (trueOutput.size()%sectorSize != 0) {
countOutput.write(0); trueOutput.write(0);
} }
output.seek(shortOffset+offsetBytes); output.seek(shortOffset+offsetBytes);
LOG.info(countOutput.getCount()); LOG.info(trueOutput.size());
output.write((int) countOutput.getCount()/sectorSize); output.write((int) trueOutput.size()/sectorSize);
countOutput.close(); trueOutput.close();
} }
} }
// else if (currentFormat) // else if (currentFormat)
@ -494,17 +494,19 @@ public class TestWorldDiskIO {
new InflaterInputStream(new BufferedInputStream(Files.newInputStream(path))) new InflaterInputStream(new BufferedInputStream(Files.newInputStream(path)))
) )
) { ) {
LOG.info(path.toString());
Vec3i pos = getRegionLoc(chunkPos); Vec3i pos = getRegionLoc(chunkPos);
int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x)); int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x));
int fullOffset = (offsetBytes+1)*(chunksPerRegion); int fullOffset = (offsetBytes+1)*(chunksPerRegion);
input.skipNBytes(shortOffset); input.skipNBytes(shortOffset);
int offset = 0; int offset = input.readInt();
for (int i=0;i<offsetBytes;i++) /*for (int i=0;i<offsetBytes;i++)
{ {
offset*=256; offset*=256;
offset += input.read(); offset += input.read();
} }*/
int sectorLength = input.read(); int sectorLength = offset & 255;
offset = offset << 8;
input.skipNBytes(fullOffset-shortOffset-offsetBytes-1); input.skipNBytes(fullOffset-shortOffset-offsetBytes-1);
input.skipNBytes(sectorSize*offset); input.skipNBytes(sectorSize*offset);
input.mark(sectorSize*sectorLength); input.mark(sectorSize*sectorLength);