fix: missing NBT tile entity data for clipboards on disk #3389
+18
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The DiskOptimizedClipboard uses a compressed OS (with underlying LZ4 streams) for storing tile and entity nbt data.
For storing the resulting bytes into the MappedByteBuffer of the clipboards file FileChannel it flushes the OutputStream after writing tile entity data and stores the resulting buffer (
NBTOutputStream > FaweOutputStream > FastBufferedOutputStream > LZ4BlockOutputStream > [...] > ByteArrayOutputStream) into a local byte array.That byte array is written into the file. If regular entity data is in the clipboard, the local buffer will be refreshed after closing the OutputStream(s) - but without those, the buffer will be the same.
The issue is, that simply flushing doesn't commit the LZ4 data if the current size does not exceed the configured block size (which is quite large in FAWE). Setting

syncFlushto true in the constructor of the LZ4BlockOS forces the non-exhausted block to be written and flushed, as documented:The issue won't occur if entities are written, as then the byte array would've been updated with the bytes of the underlying buffer after closing the streams (and therefor after flushing everything).
Submitter Checklist
@since TODO.