1
0
Fork 0
Commit Graph

25 Commits

Author SHA1 Message Date
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
peterbell10 ab350d1e43
cItemGrid: Allocate storage lazily (#4083)
* cItemGrid: Allocate storage lazily
* cItemGrid: Fix spelling, Prioritary -> Priority
2018-01-21 18:45:13 +00:00
peterbell10 b2634bade0 cItemGrid bounds check (#3837) 2017-07-09 22:54:56 +02:00
Mattes D 0dd1cd750b BlockEntities: Support cloning self. 2017-06-16 14:11:28 +02:00
LogicParrot ca6ef58b1e Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
Samuel Barney 804805d35a Silenced and fixed many warning messages across multiple files. 2015-07-29 09:49:30 -06:00
tycho dae9e5792a Made -Weverything an error. 2015-05-24 12:56:56 +01:00
Mattes D 9e9459a367 Fixed a possible division by zero. 2014-12-21 19:48:29 +01:00
Mattes D 2467d29a4e Moved all Noise-related files into a separate folder. 2014-11-18 12:07:08 +01:00
Tiger Wang a26541a7c3 En masse NULL -> nullptr replace 2014-10-22 20:12:49 -07:00
Mattes D cf73fee7e3 Fixed minor style issues. 2014-10-19 18:45:42 +02:00
STRWarrior 07b5ce0c54 Changed i variable to j
The server wasn't going over all the items before.
2014-10-16 11:17:39 +02:00
STRWarrior fa6f8fb38e The code now prevents conflicting enchantments. 2014-10-15 15:44:52 +02:00
STRWarrior 57f8d2a55e Adding enchantments directly instead of first getting the name of it. 2014-10-15 15:31:06 +02:00
STRWarrior e4ee71868e Renamed the counter to 'j' 2014-10-15 15:25:48 +02:00
STRWarrior ff5f57514e Returned cFastRandom and cEnchantment:GetRandomEnchantmentFromVector to before
Added cEnchantment:GenerateEnchantmentFromVector that allows to get the same enchantments over and over.
2014-10-15 14:44:07 +02:00
STRWarrior e3aa6e4857 Enchanted books generate in MineShafts chests 2014-10-15 14:08:45 +02:00
Howaner ef4d68adfd Merge branch 'master' into Inventory 2014-07-26 13:27:27 +02:00
Howaner 51b91befbd Added RemoveItem() function to the player inventory. 2014-07-18 23:11:59 +02:00
Howaner 9c32e31edf Items should first added to the first slot, not the latest. 2014-07-18 01:02:25 +02:00
archshift e8143de01b Nullify deleted pointers. 2014-06-19 01:49:56 -07:00
Tiger Wang f97ce30151 Changed inheritance a bit
* cBlockEntityWithItems now inherits from cBlockEntityWindowOwner
2014-02-12 22:01:22 +00:00
Tiger Wang 74645fdfaa Removed obsoleted functions 2014-01-16 19:00:49 +00:00
madmaxoft dfa81829fe Fixed signedness warning in cItemGrid. 2013-12-22 15:45:45 +01:00
Alexander Harkness 675b4aa878 Moved source to src 2013-11-24 14:19:41 +00:00