Cuberite
A lightweight, fast and extensible game server for Minecraft
RecipeMapper.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../CraftingRecipes.h"
4 #include <optional>
5 
14 {
15 public:
16  cRecipeMapper(void);
18 
20  std::optional<UInt32> GetProtocolRecipeId(UInt32 a_RecipeId, UInt32 a_ProtocolVersion);
21 
23  std::optional<UInt32> GetCuberiteRecipeId(UInt32 a_ProtocolRecipeId, UInt32 a_ProtocolVersion);
24 
25 private:
27  std::map<AString, std::map<UInt32, UInt32>> m_ProtocolVersionMap;
28 
30  void loadRecipes(const AString & a_ProtocolVersion);
31 
33  void AddRecipeLine(const AString & a_ProtocolVersion, int a_LineNum, const AString & a_RecipeLine, const std::map<AString, UInt32> & a_RecipeNameMap);
34 
35 };
unsigned int UInt32
Definition: Globals.h:157
std::string AString
Definition: StringUtils.h:11
The RecipeMapper handles the translation of crafting recipes into protocol specific recipe Ids.
Definition: RecipeMapper.h:14
std::optional< UInt32 > GetProtocolRecipeId(UInt32 a_RecipeId, UInt32 a_ProtocolVersion)
Translates the cuberite RecipeId to the protocol specific RecipeId.
cRecipeMapper(void)
Definition: RecipeMapper.cpp:5
std::optional< UInt32 > GetCuberiteRecipeId(UInt32 a_ProtocolRecipeId, UInt32 a_ProtocolVersion)
Translates the protocol specific RecipeId to the cuberite RecipeId.
std::map< AString, std::map< UInt32, UInt32 > > m_ProtocolVersionMap
A mapping for each protocol from the protocol specific RecipeId and the cuberite RecipeId.
Definition: RecipeMapper.h:27
void AddRecipeLine(const AString &a_ProtocolVersion, int a_LineNum, const AString &a_RecipeLine, const std::map< AString, UInt32 > &a_RecipeNameMap)
Handles a single line of the protocol specific mapping file.
void loadRecipes(const AString &a_ProtocolVersion)
Load Recipes from the protocol specific mapping file.