Skip to content

[WIP]Implement written books#4616

Closed
Seadragon91 wants to merge 3 commits intocuberite:masterfrom
Seadragon91:add_books
Closed

[WIP]Implement written books#4616
Seadragon91 wants to merge 3 commits intocuberite:masterfrom
Seadragon91:add_books

Conversation

@Seadragon91
Copy link
Contributor

@Seadragon91 Seadragon91 commented Apr 4, 2020

  • Added new class cBookContent that contains the infos about a book
  • Loads and saves the book from player inventory and nbt
  • Added hooks: HOOK_PLAYER_EDITING_BOOK and HOOK_PLAYER_EDITED_BOOK

Revived that old branch. Tested and it works in 1.8.9, 1.9.4 and 1.12.2.
Will check the API and look to extend it with cJson.

@Seadragon91 Seadragon91 force-pushed the add_books branch 3 times, most recently from fa053bb to 0466183 Compare April 4, 2020 15:59
@Seadragon91 Seadragon91 changed the title Implement written books [WIP]Implement written books Apr 4, 2020
@Seadragon91
Copy link
Contributor Author

Had thought about adding a static function to deserialize from json string, but I think the API functions are already enough.

- Added new class cBookContent that contains the infos about a book
- Loads and saves the book from player inventory and nbt
- Added hooks: HOOK_PLAYER_EDITING_BOOK and HOOK_PLAYER_EDITED_BOOK
@Seadragon91
Copy link
Contributor Author

I tested against 1.8 and there written book are stored as simple strings and not as json strings.

@Seadragon91
Copy link
Contributor Author

Seadragon91 commented Apr 5, 2020

Okay, it's sent as a json string in 1.8, but the text is escaped:
1.9:

{
   "text" : "1\n2\n3\n4\n5"
}

1.8:

{
   "text" : "\"1\\n2\\n3\\n4\\n5\""
}

Should we change the content, before it's sent or when it's received? Or ignore it as it's only in 1.8?

@bearbin
Copy link
Member

bearbin commented Apr 5, 2020

When it's received seems to make more sense. Since we do support 1.8 still, we should make all features that can work in that version work.

@12xx12 12xx12 mentioned this pull request Sep 21, 2020
56 tasks
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.

2 participants