Fix saving entities in DiskOptimizedClipboard when no tiles are present (#1815)

This commit is contained in:
Jordan 2022-06-19 00:58:47 +01:00 committed by GitHub
parent 907ad8528e
commit 003cec30be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,7 +182,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
readBiomeStatusFromHeader(); readBiomeStatusFromHeader();
int nbtCount = readNBTSavedCountFromHeader(); int nbtCount = readNBTSavedCountFromHeader();
int entitiesCount = readEntitiesSavedCountFromHeader(); int entitiesCount = readEntitiesSavedCountFromHeader();
if (Settings.settings().CLIPBOARD.SAVE_CLIPBOARD_NBT_TO_DISK && nbtCount + entitiesCount > 0) { if (Settings.settings().CLIPBOARD.SAVE_CLIPBOARD_NBT_TO_DISK && (nbtCount + entitiesCount > 0)) {
loadNBTFromFileFooter(nbtCount, entitiesCount, biomeLength); loadNBTFromFileFooter(nbtCount, entitiesCount, biomeLength);
} }
} else if (braf.length() - headerSize == ((long) getVolume() << 1) + biomeLength) { } else if (braf.length() - headerSize == ((long) getVolume() << 1) + biomeLength) {
@ -551,6 +551,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
nbtOS.flush();
if (baOS.size() > nbtBytesRemaining) { if (baOS.size() > nbtBytesRemaining) {
LOGGER.warn( LOGGER.warn(
"Clipboard file {} does not have enough remaining space to store entity data on disk.", "Clipboard file {} does not have enough remaining space to store entity data on disk.",
@ -564,14 +565,14 @@ public class DiskOptimizedClipboard extends LinearClipboard {
} }
} }
if (output == null) {
return;
}
if (entitiesFit) { if (entitiesFit) {
output = baOS.toByteArray(); output = baOS.toByteArray();
} }
if (output == null) {
return;
}
long currentLength = this.braf.length(); long currentLength = this.braf.length();
this.braf.setLength(currentLength + baOS.size()); this.braf.setLength(currentLength + baOS.size());
MappedByteBuffer tempBuffer = fileChannel.map( MappedByteBuffer tempBuffer = fileChannel.map(