38 std::shared_ptr<cBlockHandler> aHandler,
39 const std::map<AString, AString> & aHints = std::map<AString, AString>(),
40 const std::map<AString, HintCallback> & aHintCallbacks = std::map<AString, HintCallback>()
113 const AString & aBlockTypeName,
114 std::shared_ptr<cBlockHandler> aHandler,
115 const std::map<AString, AString> & aHints = std::map<AString, AString>(),
116 const std::map<AString, BlockInfo::HintCallback> & aHintCallbacks = std::map<AString, BlockInfo::HintCallback>()
129 const AString & aBlockTypeName,
138 const AString & aBlockTypeName,
167 const std::shared_ptr<BlockInfo> & aPreviousRegistration,
168 const std::shared_ptr<BlockInfo> & aNewRegistration
185 const std::shared_ptr<BlockInfo> & aPreviousRegistration,
186 const std::shared_ptr<BlockInfo> & aNewRegistration
204 const AString & aBlockTypeName,
Represents the state of a single block (previously known as "block meta").
Complete information about a single block type.
AString hintValue(const AString &aHintName, const BlockState &aBlockState)
Retrieves the value associated with the specified hint for this specific BlockTypeName and BlockState...
std::function< AString(const AString &aTypeName, const BlockState &aBlockState)> HintCallback
Callback is used to query block hints dynamically, based on the current BlockState.
const AString & blockTypeName() const
std::shared_ptr< cBlockHandler > handler() const
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::shared_ptr< cBlockHandler > m_Handler
The callbacks to call for various interaction.
void setHint(const AString &aHintKey, const AString &aHintValue)
Sets (creates or updates) a static hint.
AString m_PluginName
The name of the plugin that registered the block.
std::map< AString, AString > m_Hints
Optional static hints for any subsystem to use, such as "IsSnowable" -> "1".
std::map< AString, HintCallback > m_HintCallbacks
The callbacks for dynamic evaluation of hints, such as "LightValue" -> function(BlockTypeName,...
AString m_BlockTypeName
The name of the block type, such as "minecraft:redstone_lamp".
const AString & pluginName() const
void removeHint(const AString &aHintKey)
Removes a hint.
Stores information on all known block types.
void setBlockTypeHint(const AString &aBlockTypeName, const AString &aHintKey, const AString &aHintValue)
Sets (adds or overwrites) a single Hint value for a BlockType.
BlockTypeRegistry()=default
Creates an empty new instance of the block type registry.
cCriticalSection m_CSRegistry
The CS that protects m_Registry against multithreaded access.
void removeAllByPlugin(const AString &aPluginName)
Removes all registrations done by the specified plugin.
std::map< AString, std::shared_ptr< BlockInfo > > m_Registry
The actual block type registry.
std::shared_ptr< BlockInfo > blockInfo(const AString &aBlockTypeName)
Returns the registration information for the specified BlockTypeName.
void registerBlockType(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, BlockInfo::HintCallback > &aHintCallbacks=std::map< AString, BlockInfo::HintCallback >())
Registers the specified block type.
void removeBlockTypeHint(const AString &aBlockTypeName, const AString &aHintKey)
Removes a previously registered single Hint value for a BlockType.
The exception thrown from BlockTypeRegistry::registerBlockType() if the same block type is being regi...
AlreadyRegisteredException(const std::shared_ptr< BlockInfo > &aPreviousRegistration, const std::shared_ptr< BlockInfo > &aNewRegistration)
Creates a new instance of the exception that provides info on both the original registration and the ...
std::shared_ptr< BlockInfo > previousRegistration() const
std::shared_ptr< BlockInfo > newRegistration() const
std::shared_ptr< BlockInfo > m_NewRegistration
static AString message(const std::shared_ptr< BlockInfo > &aPreviousRegistration, const std::shared_ptr< BlockInfo > &aNewRegistration)
Returns the general exception message formatted by the two registrations.
std::shared_ptr< BlockInfo > m_PreviousRegistration
The exception thrown from BlockTypeRegistry::setBlockTypeHint() if the block type has not been regist...
const AString & blockTypeName() const
const AString m_BlockTypeName
NotRegisteredException(const AString &aBlockTypeName, const AString &aHintKey, const AString &aHintValue)
Creates a new instance of the exception that provides info on both the original registration and the ...