Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copying written book and increment generation #187

Open
wants to merge 1 commit into
base: 1.20.1/0.5.1-dev
Choose a base branch
from

Conversation

IS4Code
Copy link

@IS4Code IS4Code commented Nov 13, 2024

At the moment, copying written books using printer behaves in a seemingly bugged way:

  • With copyingWrittenBookAlwaysGetOriginalVersion set to true, copying any written book sets the original's generation to 0 (original).
  • With copyingWrittenBookAlwaysGetOriginalVersion set to false, copying any written book sets the original's generation to 1 (copy of original).

I am not sure if this behaviour is intended or not, but it is definitely inconsistent and counter-intuitive. In normal Minecraft, copying a written book degrades the result, not the source. There are no other situations in this mod where using a printer on something would modify the actual item stored in the printer. It is also in conflict with the description of copyingWrittenBookAlwaysGetOriginalVersion:

#Whether or not copying a written book always get original version. Setting it to false let you always get copy version of the book.

My best guess is that it is an error ‒ the code copies target (the item in the printer) and stores it as ret, but then proceeds to modify target without affecting ret at all. As a result, a perfect copy of the original is outputted, while the original is modified in-place.

This pull request changes the existing behaviour to the following:

  • With copyingWrittenBookAlwaysGetOriginalVersion set to true, a perfect copy of the original is returned. No modifications to generation are necessary at all, ensuring that the actual original version is preserved, as stated by the description of the setting.
  • With copyingWrittenBookAlwaysGetOriginalVersion set to false, the result's generation is incremented for values 0 (original) and 1 (copy of original), going to 1 and 2, respectively, while it is unchanged for other generations. This makes the printer more in-line with Minecraft's behaviour of copying books, while the advantage of being able to copy books in generation 2 (copy of copy) stays the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant