1
0
Fork 0
cuberite-2a/src
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
..
Bindings Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
BlockEntities Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
Blocks Comment capitalisation 2020-07-06 20:56:05 +01:00
Entities Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Generating Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
HTTP Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
Items Merged trivial item handlers into cSimplePlaceableItemHandler (#4766) 2020-06-26 21:34:22 +01:00
Mobs Reduced packet spam when entities idle 2020-07-06 20:56:05 +01:00
Noise Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
OSSupport Remove unnecessary includes 2020-07-12 23:41:54 +01:00
Protocol Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Resources WebAdmin improvements (#4433) 2019-12-28 02:15:12 +02:00
Simulator Fire sim: Handle fuel block being destroyed (#4751) 2020-05-31 20:27:08 +01:00
UI Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
WorldStorage Remove Schematic Chunk height limitation 2020-07-06 20:56:47 +01:00
mbedTLS++ Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
AllocationPool.h Cleanup unneeded globals (#4736) 2020-05-10 16:16:38 +00:00
BiomeDef.cpp CheckBasicStyle: Check number of empty lines between functions (#4267) 2018-07-26 22:24:36 +01:00
BiomeDef.h Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
BlockArea.cpp Enable C++17 in build 2020-05-09 20:37:16 +01:00
BlockArea.h Manage block entity lifetime with unique_ptr (#4080) 2020-04-03 23:23:38 +02:00
BlockInServerPluginInterface.h Refactored block-to-pickup conversion. (#4417) 2019-10-16 10:06:34 +02:00
BlockInfo.cpp Change stained clay hardness value 2020-04-10 13:07:16 +00:00
BlockInfo.h Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) 2020-04-03 08:57:01 +02:00
BlockState.cpp Add ProtocolBlockTypePalette (#4391) 2019-09-22 22:57:54 +02:00
BlockState.h Add ProtocolBlockTypePalette (#4391) 2019-09-22 22:57:54 +02:00
BlockTracer.h Use Vector3 for cLineBlockTracer and cBlockTracer (#4715) 2020-05-08 10:04:07 +01:00
BlockType.cpp Cleanup some workarounds and warnings (#4735) 2020-05-10 16:16:49 +00:00
BlockType.h Re-implement repeater locking 2020-04-18 16:51:29 +01:00
BlockTypePalette.cpp Update submodules (#4727) 2020-05-09 15:51:15 +01:00
BlockTypePalette.h BlockTypePalette: Load from TSV or original reports' JSON. 2019-12-28 22:43:35 +01:00
BlockTypeRegistry.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
BlockTypeRegistry.h Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
BoundingBox.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
BoundingBox.h cBoundingBox: Fix tolua warning (#4361) 2019-08-08 19:49:00 +01:00
BrewingRecipes.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
BrewingRecipes.h Minor cBrewingRecipes cleanup (#3731) 2017-05-28 20:08:23 +02:00
Broadcaster.cpp Improve entity position updates (#4701) 2020-05-04 08:10:47 +00:00
BuildInfo.h.cmake Added abilty to set build info 2014-09-10 16:07:00 +01:00
ByteBuffer.cpp Fix building with clang 8.0 (#4346) 2019-08-11 10:39:43 +01:00
ByteBuffer.h Add cUUID class (#3871) 2017-08-25 13:43:18 +01:00
CMakeLists.txt Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
ChatColor.cpp Removed extended ASCII, and added a check against it. (#4642) 2020-04-12 09:24:30 +02:00
ChatColor.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
CheckBasicStyle.lua Removed extended ASCII, and added a check against it. (#4642) 2020-04-12 09:24:30 +02:00
Chunk.cpp Send entities in cChunkSender (#4532) 2020-06-24 12:48:50 +01:00
Chunk.h Vector3 in Handlers (#4680) 2020-04-21 22:19:22 +02:00
ChunkData.cpp Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) 2020-04-03 08:57:01 +02:00
ChunkData.h cChunk and cChunkData: Use vectors for block get and set functions (#4172) 2018-02-04 22:15:31 +00:00
ChunkDataCallback.h Limit the size of cListAllocationPool's free list 2019-02-20 09:07:44 +00:00
ChunkDef.h Vector3 in Handlers (#4680) 2020-04-21 22:19:22 +02:00
ChunkGeneratorThread.cpp ChunkGenerator: Changed to use cChunkCoords. 2019-09-08 20:21:49 +02:00
ChunkGeneratorThread.h Separated chunk generator from world / plugin interfaces. 2019-09-06 16:12:33 +02:00
ChunkMap.cpp Add cEntity::GetBoundingBox, and use where appropriate. (#4711) 2020-05-03 21:04:33 +01:00
ChunkMap.h More Vector3 in cBlockHandler (#4644) 2020-04-17 10:36:37 +01:00
ChunkSender.cpp Send entities in cChunkSender (#4532) 2020-06-24 12:48:50 +01:00
ChunkSender.h Send entities in cChunkSender (#4532) 2020-06-24 12:48:50 +01:00
ChunkStay.cpp Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
ChunkStay.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
ClientHandle.cpp Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
ClientHandle.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Color.cpp Leather Armor can now be dyed. 2015-07-15 14:05:36 -06:00
Color.h Lua plugin cColor (#3833) 2017-07-12 12:30:43 +02:00
CommandOutput.cpp Update fmt to 6.2.0 (#4718) 2020-05-05 22:52:14 +01:00
CommandOutput.h Update fmt to 6.2.0 (#4718) 2020-05-05 22:52:14 +01:00
CompositeChat.cpp Update logging code to reduce unnecessary string copying: 2020-05-16 09:39:05 +01:00
CompositeChat.h Update logging code to reduce unnecessary string copying: 2020-05-16 09:39:05 +01:00
CraftingRecipes.cpp Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
CraftingRecipes.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Cuberite.vcxproj.user Added working directory for x64 builds (#4037) 2017-09-20 19:01:46 +01:00
Cuboid.cpp Added more clamping operations to cCuboid. 2019-08-10 12:25:06 +02:00
Cuboid.h Added a basic PalettedBlockArea implementation (#4377) 2019-08-28 08:29:02 +02:00
DeadlockDetect.cpp Using Super. 2020-04-16 20:07:48 +00:00
DeadlockDetect.h Cleanup unneeded globals (#4736) 2020-05-10 16:16:38 +00:00
Defines.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
Defines.h Extended Vector3 (#4666) 2020-04-18 11:44:35 +02:00
EffectID.h Update tolua and export EffectID 2017-06-29 18:58:48 +02:00
Enchantments.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
Enchantments.h Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
Endianness.h Fixes compilation failures on MacOSX 10.10 2015-07-09 11:15:37 -06:00
FastRandom.cpp Cleanup some workarounds and warnings (#4735) 2020-05-10 16:16:49 +00:00
FastRandom.h Tentative fix for player-limit race condition (#3862) 2017-07-28 17:54:40 +01:00
ForEachChunkProvider.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
FunctionRef.h Stop cFunctionRef constructor from disabling default copy constructor. (#4173) 2018-07-24 22:30:05 +01:00
FurnaceRecipe.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
FurnaceRecipe.h Smelting Gives Experience (#4094) 2018-04-11 07:46:11 +01:00
Globals.cpp Moved source to src 2013-11-24 14:19:41 +00:00
Globals.h Remove unnecessary includes 2020-07-12 23:41:54 +01:00
IniFile.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
IniFile.h Using Super. 2020-04-16 20:07:48 +00:00
Inventory.cpp Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Inventory.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Item.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
Item.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
ItemGrid.cpp Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
ItemGrid.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
JsonUtils.cpp Update submodules (#4727) 2020-05-09 15:51:15 +01:00
JsonUtils.h Update submodules (#4727) 2020-05-09 15:51:15 +01:00
LazyArray.h Cleanup unneeded globals (#4736) 2020-05-10 16:16:38 +00:00
LightingThread.cpp Using Super. 2020-04-16 20:07:48 +00:00
LightingThread.h Using Super. 2020-04-16 20:07:48 +00:00
LineBlockTracer.cpp Use Vector3 for cLineBlockTracer and cBlockTracer (#4715) 2020-05-08 10:04:07 +01:00
LineBlockTracer.h Use Vector3 for cLineBlockTracer and cBlockTracer (#4715) 2020-05-08 10:04:07 +01:00
LinearInterpolation.cpp Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
LinearInterpolation.h Unified the doxy-comment format. 2015-07-31 16:49:10 +02:00
LinearUpscale.h Upgrade to C++17 [CMake] (#4717) 2020-05-16 20:59:10 +01:00
Logger.cpp Update fmtlib to 7.0.0 2020-07-06 20:53:04 +01:00
Logger.h Update logging code to reduce unnecessary string copying: 2020-05-16 09:39:05 +01:00
LoggerListeners.cpp sizeof(char) 2020-05-16 09:39:05 +01:00
LoggerListeners.h Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
LoggerSimple.h Enable debug logging in test builds 2020-05-16 09:39:05 +01:00
Map.cpp Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) 2020-04-03 08:57:01 +02:00
Map.h Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) 2020-04-03 08:57:01 +02:00
MapManager.cpp Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
MapManager.h Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
Matrix4.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
MemorySettingsRepository.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
MemorySettingsRepository.h Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
MobCensus.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
MobCensus.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
MobFamilyCollecter.cpp Removed double includes (#3885) 2017-08-02 19:57:20 +01:00
MobFamilyCollecter.h Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
MobProximityCounter.cpp CheckBasicStyle: Check number of empty lines between functions (#4267) 2018-07-26 22:24:36 +01:00
MobProximityCounter.h Remove double includes part 2 (#3890) 2017-08-03 15:34:19 +02:00
MobSpawner.cpp Implement wither skeletons (#4563) 2020-04-04 13:44:17 +02:00
MobSpawner.h Moved growing from cWorld / cChunk to cBlockHandler descendants. 2019-10-28 10:45:43 +01:00
MonsterConfig.cpp Tweak attack ranges 2020-04-02 09:30:50 +02:00
MonsterConfig.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
NetherPortalScanner.cpp Correct world access in NetherPortalScanner 2020-04-19 21:43:14 +01:00
NetherPortalScanner.h MoveToWorld must always be provided a world 2020-04-18 19:51:30 +01:00
OpaqueWorld.h Broadcast refactor (#4264) 2018-07-24 22:30:49 +01:00
OverridesSettingsRepository.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
OverridesSettingsRepository.h Clang 5.0 fixes 2017-05-21 12:19:06 +02:00
PalettedBlockArea.cpp BlockTypePalette: Refactored for usage in both directions. 2019-12-28 22:43:35 +01:00
PalettedBlockArea.h Added a basic PalettedBlockArea implementation (#4377) 2019-08-28 08:29:02 +02:00
ProbabDistrib.cpp CheckBasicStyle: Check number of empty lines between functions (#4267) 2018-07-26 22:24:36 +01:00
ProbabDistrib.h FastRandom rewrite (#3754) 2017-06-13 21:35:30 +02:00
RCONServer.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
RCONServer.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
RankManager.cpp Update submodules (#4727) 2020-05-09 15:51:15 +01:00
RankManager.h Remove cRankManager migration code (#4714) 2020-05-05 21:20:07 +03:00
Root.cpp Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Root.h Introduce recipe book functionality (#4493) 2020-07-14 17:56:42 +01:00
Scoreboard.cpp CheckBasicStyle: Check number of empty lines between functions (#4267) 2018-07-26 22:24:36 +01:00
Scoreboard.h Replace ItemCallbacks with lambdas (#3993) 2017-09-11 23:20:49 +02:00
Server.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
Server.h Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
SetChunkData.cpp Manage block entity lifetime with unique_ptr (#4080) 2020-04-03 23:23:38 +02:00
SetChunkData.h Manage block entity lifetime with unique_ptr (#4080) 2020-04-03 23:23:38 +02:00
SettingsRepositoryInterface.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
SpawnPrepare.cpp Separated chunk generator from world / plugin interfaces. 2019-09-06 16:12:33 +02:00
SpawnPrepare.h Potential spawn prepare fix (#3924) 2017-08-22 14:34:43 +02:00
Statistics.cpp Cleanup some workarounds and warnings (#4735) 2020-05-10 16:16:49 +00:00
Statistics.h CheckBasicStyle: Check number of empty lines between functions (#4267) 2018-07-26 22:24:36 +01:00
Stopwatch.h BlockTypePalette: Load from TSV or original reports' JSON. 2019-12-28 22:43:35 +01:00
StringCompression.cpp Fixed type-casting-related warnings. 2016-08-24 22:26:53 +02:00
StringCompression.h Unified the doxy-comment format. 2015-07-31 16:49:10 +02:00
StringUtils.cpp Update fmtlib to 7.0.0 2020-07-06 20:53:04 +01:00
StringUtils.h Update fmt to 6.2.0 (#4718) 2020-05-05 22:52:14 +01:00
UUID.cpp Make offline UUIDs consistent with vanilla. (#4178) 2018-07-20 00:30:09 +01:00
UUID.h Add cUUID class (#3871) 2017-08-25 13:43:18 +01:00
Vector3.h Cleanup some workarounds and warnings (#4735) 2020-05-10 16:16:49 +00:00
VoronoiMap.cpp Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
VoronoiMap.h Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
WebAdmin.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
WebAdmin.h Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
World.cpp Enable some more clang-tidy linter checks (#4738) 2020-05-14 22:15:35 +00:00
World.h Improve entity position updates (#4701) 2020-05-04 08:10:47 +00:00
XMLParser.h Minor changes (#3909) 2017-08-24 11:19:40 +02:00
fmt.h Update fmtlib to 7.0.0 2020-07-06 20:53:04 +01:00
main.cpp Android build cleanup (#4734) 2020-05-10 16:18:28 +00:00