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.
Implements #214
Adds logging for sign (and hanging sign) text editing and item-based interactions including waxing, dyeing, ink, and glow ink, with rollback support.
Editing signs mutates the block entity instance which makes it difficult to properly log for rollbacks. My solution is a bit of a hack that captures the old block entity data by copying the NBT data into a new block entity instance and then logging that copy as the old block entity. This seems to me to be the only way to do this, but I would definitely prefer something that doesn't involve direct NBT copying like this.
Currently, this does not seem to work with restoring. However, when I looked into it, restoring block entity data seems to just be a missing feature in Ledger. Perhaps another PR could implement this, or I could look into creating a new action type for sign editing. Especially for text editing, it might be nice to see something like "old text" -> "new text" in the result, similar to what happens when you wax a copper block. The sign text might be a bit long for a single line in a chat message, though.
There is also an issue where rolling back a sign does not cause it to immediately update its appearance. Its data does indeed change, and you can verify by checking with
/data
or by rejoining the server. I assume this is related to another issue where signs also appear blank after inspecting them with left-click. It might be fixable by sending some sort of block entity update packet to nearby players on restore, but that might incur some additional cost of iterating over all players to find the nearby ones many times (and of course, the cost of actually sending those packets).Let me know what you think :D