Fix copying written book and increment generation #187
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.
At the moment, copying written books using printer behaves in a seemingly bugged way:
copyingWrittenBookAlwaysGetOriginalVersion
set totrue
, copying any written book sets the original's generation to 0 (original).copyingWrittenBookAlwaysGetOriginalVersion
set tofalse
, 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 asret
, but then proceeds to modifytarget
without affectingret
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:
copyingWrittenBookAlwaysGetOriginalVersion
set totrue
, a perfect copy of the original is returned. No modifications togeneration
are necessary at all, ensuring that the actual original version is preserved, as stated by the description of the setting.copyingWrittenBookAlwaysGetOriginalVersion
set tofalse
, the result'sgeneration
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.