29 using HintCallback = std::function<AString(const AString & aTypeName, const BlockState & aBlockState)>;
37 std::shared_ptr<cBlockHandler> aHandler,
38 const std::map<AString, AString> & aHints = std::map<AString, AString>(),
39 const std::map<AString, HintCallback> & aHintCallbacks = std::map<AString, HintCallback>()
110 void registerBlockType(
112 const AString & aBlockTypeName,
113 std::shared_ptr<cBlockHandler> aHandler,
114 const std::map<AString, AString> & aHints = std::map<AString, AString>(),
115 const std::map<AString, BlockInfo::HintCallback> & aHintCallbacks = std::map<AString, BlockInfo::HintCallback>()
120 std::shared_ptr<BlockInfo> blockInfo(
const AString & aBlockTypeName);
123 void removeAllByPlugin(
const AString & aPluginName);
127 void setBlockTypeHint(
128 const AString & aBlockTypeName,
136 void removeBlockTypeHint(
137 const AString & aBlockTypeName,
146 std::map<AString, std::shared_ptr<BlockInfo>>
mRegistry;
166 std::shared_ptr<BlockInfo> aPreviousRegistration,
167 std::shared_ptr<BlockInfo> aNewRegistration
184 std::shared_ptr<BlockInfo> aPreviousRegistration,
185 std::shared_ptr<BlockInfo> aNewRegistration
203 const AString & aBlockTypeName,
The exception thrown from BlockTypeRegistry::setBlockTypeHint() if the block type has not been regist...
Stores information on all known block types.
std::shared_ptr< cBlockHandler > handler() const
void setHint(const AString &aHintKey, const AString &aHintValue)
Sets (creates or updates) a static hint.
AString mPluginName
The name of the plugin that registered the block.
std::map< AString, std::shared_ptr< BlockInfo > > mRegistry
The actual block type registry.
BlockInfo(const AString &aPluginName, const AString &aBlockTypeName, std::shared_ptr< cBlockHandler > aHandler, const std::map< AString, AString > &aHints=std::map< AString, AString >(), const std::map< AString, HintCallback > &aHintCallbacks=std::map< AString, HintCallback >())
Creates a new instance with the specified BlockTypeName and handler / hints / callbacks.
std::map< AString, AString > mHints
Optional static hints for any subsystem to use, such as "IsSnowable" -> "1".
const AString & blockTypeName() const
const AString mBlockTypeName
AString hintValue(const AString &aHintName, const BlockState &aBlockState)
Retrieves the value associated with the specified hint for this specific BlockTypeName and BlockState...
void removeHint(const AString &aHintKey)
Removes a hint.
cCriticalSection mCSRegistry
The CS that protects mRegistry against multithreaded access.
Complete information about a single block type.
const AString & blockTypeName() const
std::shared_ptr< BlockInfo > mNewRegistration
AString mBlockTypeName
The name of the block type, such as "minecraft:redstone_lamp".
const AString & pluginName() const
std::function< AString(const AString &aTypeName, const BlockState &aBlockState)> HintCallback
Callback is used to query block hints dynamically, based on the current BlockState.
std::shared_ptr< BlockInfo > newRegistration() const
std::shared_ptr< BlockInfo > previousRegistration() const
std::shared_ptr< BlockInfo > mPreviousRegistration
The exception thrown from BlockTypeRegistry::registerBlockType() if the same block type is being regi...
std::map< AString, HintCallback > mHintCallbacks
The callbacks for dynamic evaluation of hints, such as "LightValue" -> function(BlockTypeName, BlockState).
std::shared_ptr< cBlockHandler > mHandler
The callbacks to call for various interaction.
Represents the state of a single block (previously known as "block meta").