Patchouli (Fabric/Quilt)

Patchouli (Fabric/Quilt)

25M Downloads

Add page turning pulse to book on lectern

TheRealWormbo opened this issue ยท 0 comments

commented

Describe the feature

Lecterns have two redstone-related functionalities in the vanilla game:

  • When flipping through the pages of a book, the lectern gives off a short redstone pulse of signal strength 15, similar to a button attached to the block below. (In code this is done via signalPageChange on the LecternBlock, which is triggered by the LecternBlockEntity.)
  • Depending on the position in a written book, a comparator will output a signal strength corresponding to the relative position in the book. (The getRedstoneSignal method in the LecternBlockEntity calculates this based on what it knows about the number of pages and the current page number of the book.)

By default, the lectern only recognized Book and Quill or Written Book items for either of those features to work. If a Patchouli book (or any other item) is placed on a lectern, it will recognize it as a non-book item with zero pages. As a result, due to fallback logic, the comparator read-out will always be signal strength 14. Also, since it doesn't receive page-turning notifications, it will not output a redstone pulse.

Now I recognize that almost everything about Patchouli books happens per-player (unlocking, current page, etc.), so it suffers the same issue as the ender chest in terms of defining a server-side state for a comparator to read. However, maybe at least the page turning signal could be added.

Additional context

If the current page of a Patchouli book on a lectern could be saved in the LecternBlockEntity somehow, independently from the player-specific current page of the book item, a number of different options would open up for the comparator read-out. The simplest would likely be to output the relative position within the current section. Reading the relative unlock progress (of the entire book or the current section) would be neat, but probably difficult, since technically multiple people could look at the book at the same time but have different parts unlocked. The issue of potentially looking at the book while it is open on a locked section or entry would also need to be solved first.