feat: add item tracking for Chiseled Bookshelf#368
Open
netcrafts wants to merge 1 commit intoQuiltServerTools:masterfrom
Open
feat: add item tracking for Chiseled Bookshelf#368netcrafts wants to merge 1 commit intoQuiltServerTools:masterfrom
netcrafts wants to merge 1 commit intoQuiltServerTools:masterfrom
Conversation
Adds item-insert and item-remove logging for ChiseledBookShelfBlock. Players inserting or removing books from a Chiseled Bookshelf are now tracked, with full rollback and restore support. Modelled on the existing ShelfBlockMixin pattern: - Inject into addBook() after setItem() fires ItemInsertCallback - ModifyExpressionValue on removeBook() to capture the removed stack and fire ItemRemoveCallback ChiseledBookShelfBlockEntity implements ListBackedContainer extends Container, so rollback resolves through the existing getInventory() path in ItemChangeActionType with no additional changes required. Note: preview rollback has no visual effect on Chiseled Bookshelf — this is a pre-existing limitation of ServerPlayerEntityMixin which intercepts ClientboundContainerSetContentPacket, a packet not sent for blocks using block-state slot properties. The same limitation exists for ShelfBlock. Actual rollback and restore work correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change?
Adds
item-insertanditem-removeaction logging for the Chiseled Bookshelf block. When a player places a book into or removes a book from a Chiseled Bookshelf, the action is now logged and fully supports rollback and restore.Why?
The Chiseled Bookshelf bypasses the standard container menu system — players interact directly with the block face to slot and unslot books, so the existing
AbstractContainerMenuMixinnever fires for it. This left a gap in logging for a commonly used storage block.How?
Added
ChiseledBookShelfBlockMixin.java, modelled directly on the existingShelfBlockMixin.javapattern:@Injectinto the private staticaddBook()method, firingItemInsertCallbackaftersetItem()stores the book@ModifyExpressionValueonremoveBook(), capturing theItemStackreturned byremoveItem()and firingItemRemoveCallbackBoth hooks only run server-side (guard on
level instanceof ServerLevel), matching the pattern used throughout the codebase.ChiseledBookShelfBlockEntityimplementsListBackedContainer extends Container, so rollback and restore work through the existingItemChangeActionType.getInventory()path with no changes needed.Testing
Tested on a local Fabric 0.18.4 / Minecraft 1.26.1 server:
item-insertitem-remove/ledger rollback range:2 action:item-insert after:10m— books correctly removed from the bookshelf (2 rollback entries logged)Known limitation:
/ledger preview rollbackdoes not visually reflect Chiseled Bookshelf changes. This is a pre-existing limitation of the preview system —ServerPlayerEntityMixininterceptsClientboundContainerSetContentPacket, which is not sent for blocks that track slot state via block-state properties rather than a container screen. The same limitation exists forShelfBlock. Actual rollback and restore work correctly.