summaryrefslogtreecommitdiffstats
path: root/src/Inventory.h (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-01-14Fixed Compiler Warningsx12xx12x1-3/+3
2020-07-14Introduce recipe book functionality (#4493)Tobias Wilken1-4/+3
* 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-04-02Replace buckets to the selected hotbar slot, rather than the first available. (#4580)Alexander Harkness1-0/+10
* Replace buckets to the selected hotbar slot, rather than the first available. Replicates vanilla behaviour, as well as being more logical. * Refactor cInventory::AddItem. Behaviour is now documented * Add new cInventory::ReplaceOneEquippedItem and ::SetEquippedItem methods * Return empty potion to the same slot after drinking * Replace buckets correctly in other situations, not simply water and lava Uses the new ReplaceOneEquippedItem method * Correct collecting water from source block with bottle * Add cPlayer::ReplaceOneEquippedItemTossRest method * Handle stacked filled buckets (in theory) Use new cPlayer::ReplaceOneEquippedItemTossRest method
2017-08-03Removed unused forward declarations (#3888)Lukas Pioch1-1/+0
2017-05-24Off-hand/shield slot functional, save and load slot, bow + arrow functional (#3725)Pablo Beltrán1-2/+19
Fixes #3714.
2017-05-21Clang 5.0 fixesLukas Pioch1-1/+1
- Added override keyword - Removed inherited member variables
2016-07-18Updated API documentation.Mattes D1-2/+2
2016-02-05Bulk clearing of whitespaceLogicParrot1-25/+25
2015-05-18Fixes #2052Tiger Wang1-8/+2
2015-05-09CheckBasicStyle: checks spaces around * and &.Mattes D1-1/+1
2015-03-19Removed unwanted base classes from Lua API.Mattes D1-0/+2
2014-10-23En masse NULL -> nullptr replaceTiger Wang1-2/+2
2014-10-20En masse NULL -> nullptr replaceTiger Wang1-2/+2
2014-08-11Gave names to unnamed enumsarchshift1-2/+2
2014-07-21Style: Normalized to no spaces before closing parenthesis.madmaxoft1-1/+1
2014-07-18Clarified RemoveItem()'s comments.madmaxoft1-1/+2
2014-07-18Added RemoveItem() function to the player inventory.Howaner1-0/+3
2014-07-17Fixed basic whitespace problems.madmaxoft1-1/+1
Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines.
2014-05-09Add DIG_STATUS_CANCELLED packet and add item resend, when a block can't place/break.Howaner1-19/+22
2014-03-28Fixed non-virtual destructors warnings.madmaxoft1-0/+2
2014-02-17Map item handler; Fixed several bugsandrew1-0/+3
2013-11-24Moved source to srcAlexander Harkness1-0/+0
2013-11-05Removed the obsolete SendWholeInventory(cInventory &) function.madmaxoft1-2/+0
This won't compile because there's still a change in Protocol17x.cpp pending; the next commit will fix this.
2013-07-26cInventory: Added the ChangeSlotCount() function to the Lua APImadmaxoft@gmail.com1-0/+6
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1683 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-07-03Empty buckets replace fluid buckets on use and vice versa (patch contributed by Mgueydan)madmaxoft1-3/+9
Fixes FS #277. API change: added an optional parameter to cItemGrid:AddItem(), cItemGrid:AddItems(), cInventory:AddItem() and cInventory:AddItems() git-svn-id: http://mc-server.googlecode.com/svn/trunk@1643 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-05-24Slight cleanup in the cInventory / cItemGrid APImadmaxoft@gmail.com1-2/+2
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1504 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-05-24Refactored cInventory to use cItemGrid for the actual Storagemadmaxoft@gmail.com1-47/+112
This makes the API more orthogonal and is easier to use in the plugins. Also changes in the inventory are now propagated to the needed places (armor updates to BroadcastEntityEquipment etc.) even when the inventory is changed by a plugin. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1503 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-05-19Fixed linux compilationmadmaxoft@gmail.com1-1/+1
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1496 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-05-19Inventory code cleanup, players can now see each other's armormadmaxoft@gmail.com1-11/+22
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1493 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-01-12Merged branch "branches/hooks" into "trunk".madmaxoft@gmail.com1-13/+13
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1139 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-12-21Extended player inventory by direct r/o access to armor slotsmadmaxoft@gmail.com1-0/+7
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1086 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-10-24Fixed issues with pickups. sebi.noreply@gmail.com1-0/+1
* Now when picking up max. stack amount is checked. * Added cInventory::AddItemAnyAmount() which will not fail if it cannot add all items (it will just modify amount) * If there is no space in inventory and picking up stacked items, it will try to fill stacks already in inventory, partially picking up the item. * When closing inventory player will drop any items it's currently 'dragging' git-svn-id: http://mc-server.googlecode.com/svn/trunk@1008 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-09-24Source files cleanup: The rest of the files renamed.madmaxoft@gmail.com1-1/+1
git-svn-id: http://mc-server.googlecode.com/svn/trunk@887 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-09-20Refactored windows.madmaxoft@gmail.com1-23/+17
As described on the forum: http://forum.mc-server.org/showthread.php?tid=561 For now, only basic clicking works; shift-click not implemented yet. git-svn-id: http://mc-server.googlecode.com/svn/trunk@867 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-29Gotten completely rid of all cPackets. The cProtocol125 class now does all the parsing and writing by itself.madmaxoft@gmail.com1-2/+0
git-svn-id: http://mc-server.googlecode.com/svn/trunk@802 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-24Monster classes don't use cPackets. Chat messages are sent / broadcast without cPackets. BlockEntities don't use cPackets.madmaxoft@gmail.com1-1/+2
git-svn-id: http://mc-server.googlecode.com/svn/trunk@783 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-19Another handful of packets rewritten.madmaxoft@gmail.com1-3/+3
Also changed cItem::m_ItemID into m_ItemType of type short. Easier handling. m_ItemID kept for compatibility reasons (Lua-interface etc.) git-svn-id: http://mc-server.googlecode.com/svn/trunk@756 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-18Packet refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects.madmaxoft@gmail.com1-1/+1
This breaks plugin API! Plugins need to modify their hook functions to match those used in the Core plugin git-svn-id: http://mc-server.googlecode.com/svn/trunk@750 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-11Added partial shift+click handling to the survival inventorymadmaxoft@gmail.com1-0/+7
git-svn-id: http://mc-server.googlecode.com/svn/trunk@730 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-11Removed a useless include file.madmaxoft@gmail.com1-1/+4
git-svn-id: http://mc-server.googlecode.com/svn/trunk@725 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-08-07Prepared WindowOwner class hierarchy for minecart with chest.madmaxoft@gmail.com1-0/+3
git-svn-id: http://mc-server.googlecode.com/svn/trunk@719 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-14Attempt to bring sanity to newlines across systems.cedeel@gmail.com1-82/+82
git-svn-id: http://mc-server.googlecode.com/svn/trunk@606 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-03-19Basic cWindow thread-safetymadmaxoft@gmail.com1-1/+10
git-svn-id: http://mc-server.googlecode.com/svn/trunk@420 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-01-01CreativeInventory Updatelapayo94@gmail.com1-0/+2
- Fixed various problems with the new creative inventory (Crafting, furnace, etc) - Creative inventory will now be saved to disk, so you keep your creative inventory also for the next sessions git-svn-id: http://mc-server.googlecode.com/svn/trunk@162 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-01-01- implemented separated inventory for creative mode (cSurvivalInventory and cCreativeInventory)lapayo94@gmail.com1-6/+5
(Separation is not perfect yet, because maybe there are some mayor changes needed :D) - implemented CreativeInventoryAction (was mistakenly called CreateInventoryAction) -> Fixed meta data for creative selected blocks ->->Slabs/Steps are now placed correctly - slabs can now be build to a double slab - fixed a bug in the inventory which put items with different meta values in the same slot git-svn-id: http://mc-server.googlecode.com/svn/trunk@160 0a769ca7-a7f5-676a-18bf-c427514a06d6
2011-10-31Player data is saved and loaded as human readable JSON now.faketruth1-2/+7
cFileFormatUpdate will loop through old files and convert them to new files (should replace legacy old format loading code) cItem has two new functions to load from Json and output Json, this will keep the items in Json standard ChestEntity and FurnaceEntity use the new functions in cItem git-svn-id: http://mc-server.googlecode.com/svn/trunk@35 0a769ca7-a7f5-676a-18bf-c427514a06d6
2011-10-26Made several recomended changes. Gamemode is now world based. Need to add it to player.admin@omencraft.com1-1/+0
git-svn-id: http://mc-server.googlecode.com/svn/trunk@18 0a769ca7-a7f5-676a-18bf-c427514a06d6
2011-10-26Added CreateInventoryAction packet for creative mode. Used cPacketEntityEquipment as template. Forced server into Creative Mode. Can't break blocks yet. Player can stil be damaged in creative mode and dying takes you back to survival mode.admin@omencraft.com1-1/+2
git-svn-id: http://mc-server.googlecode.com/svn/trunk@15 0a769ca7-a7f5-676a-18bf-c427514a06d6
2011-10-03MCServer c++ source filesfaketruth1-0/+67
git-svn-id: http://mc-server.googlecode.com/svn/trunk@3 0a769ca7-a7f5-676a-18bf-c427514a06d6