fix: close current inventory when opening a book

This commit is contained in:
mworzala 2024-04-14 20:34:26 -04:00
parent 7daf8d69b7
commit e8e22a2b15
No known key found for this signature in database
GPG Key ID: B148F922E64797C7
1 changed files with 5 additions and 0 deletions

View File

@ -995,6 +995,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
@Override
public void openBook(@NotNull Book book) {
// Close the open inventory if there is one because the book will replace it.
if (getOpenInventory() != null) {
closeInventory();
}
final ItemStack writtenBook = ItemStack.builder(Material.WRITTEN_BOOK)
.meta(WrittenBookMeta.class, builder -> builder.resolved(false)
.generation(WrittenBookMeta.WrittenBookGeneration.ORIGINAL)