1
0
Fork 0
cuberite-2a/Server
Tobias Wilken 36eab1b323
Introduce recipe book functionality (#4493)
* Introduce recipe book functionality

The recipe book helps especially new players. Missing it gives the
impression that cuberite is not as advanced as it is.

The handling of the recipe book uses the following functions:

- Unlock Recipes
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Unlock_Recipes) to
make recipes available and show the notification for new recipes.
Initialization is done on player login for known ones, the update is done
when new items are discovered.
- Craft Recipe Request
(https://wiki.vg/index.php?title=Protocol&oldid=14204#Craft_Recipe_Request)
when the user selects a recipe from the recipe book to fill the slots.

Known recipes are initialized on player login via `Unlock Recipes` with
`Action` 0.
As soon as a new recipe is discovered this is added via `Unlock Recipes`
with `Action` 1.

To be able to know and recognize new recipes the player class is
extended with `KnownItems` and `KnownRecipes`. As soon as a player
touches an item this is compared to the list of `KnownItems`, if the
item is unknown the recipes are checked for this item and the other
ingredients are checked with the list of `KnownItems`. If a full match
is discovered the recipe is unlocked with the client and stored in the
`KnownRecipes`.

To unlock recipes the recipe ID is sent to the client. A mapping file
(for protocol 1.12.2) translated the minecraft recipe names to ids. The
crafting.txt is extended with and minecraft recipe names is possible.

Limitations:
Only a single recipe is added to the crafting area. Multiple clicks or
shift click does not increase the number of builds.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>

* Address first issues mentioned by @peterbell10

- Some linting
- Extract loading of recipe specific protocol mapping into a function
- Build `RecipeNameMap` only once
- Use `std::optional`
- Extract `LoadRecipe` from `Window`

* Start to implement new suggestions

* Update with suggestions from @peterbell10

* Some minor cleanup

* Update protocol packet IDs
* Remove unused include
* Include header in cmake
* Change a vector to integer counter

* Change dromedaryCase method names to PascalCase

* Address suggestions from @madmaxoft

* Read Protocol subdirectories to load recipe books

To load all recipebooks iterate over the `Protocol` subdirectories
to find mapping files.

Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-07-14 17:56:42 +01:00
..
Install More CMake cleanup 2020-07-12 22:00:07 +01:00
Plugins Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Prefabs Fixed and extended TestRails cubeset. 2016-12-15 11:09:11 +01:00
Protocol Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
webadmin WebAdmin logo improvements (#4604) 2020-04-03 15:41:29 +00:00
.gitignore Removed binary ToLua++ from build. 2017-05-04 17:38:05 +02:00
README.txt Change outdated support link 2019-12-30 03:53:29 +02:00
brewing.txt Potion changes (#4601) 2020-04-04 14:16:36 +00:00
crafting.txt Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
delete_windows_service.cmd Renamed output directory to Server 2015-09-05 22:01:21 +02:00
favicon.png New icon colors (#3675) 2017-06-03 18:49:02 +02:00
furnace.txt Corrected furnace recipes for log 2020-04-25 12:27:27 +01:00
hg Renamed leftover strings to Cuberite / Server, as needed. 2016-01-01 21:05:09 +01:00
hg.supp Renamed leftover strings to Cuberite / Server, as needed. 2016-01-01 21:05:09 +01:00
install_windows_service.cmd Renamed output directory to Server 2015-09-05 22:01:21 +02:00
items.ini Correct spider eye item ID (#4110) 2017-12-25 09:04:38 +00:00
monsters.ini Add Zombie Villagers 2020-04-10 00:50:45 +01:00
vg Renamed leftover strings to Cuberite / Server, as needed. 2016-01-01 21:05:09 +01:00
vg.supp Renamed output directory to Server 2015-09-05 22:01:21 +02:00

README.txt

--------------------------------------------------------------------------------
   Welcome to your new Cuberite server, compatible with Minecraft 1.8 - 1.12!
--------------------------------------------------------------------------------

 - To get started with your server, read the user's manual at
   https://book.cuberite.org/

 - Subscribe to the Newsletter for update news and important information at
   https://cuberite.org/news/#subscribe

 - For information about adding plugins to your server, visit
   https://cuberite.org/plugins/

 - For additional support, visit https://cuberite.org/discuss/

--------------------------------------------------------------------------------