42 public std::runtime_error
44 using Super = std::runtime_error;
48 Super(
fmt::format(FMT_STRING(
"No such palette index: {}"), aIndex))
56 public std::runtime_error
58 using Super = std::runtime_error;
85 const std::pair<AString, BlockState> &
entry(
UInt32 aIndex)
const;
Implements custom fmtlib formatting for cChunkCoords.
Represents the state of a single block (previously known as "block meta").
Holds a palette that maps between block type + state and numbers.
std::map< UInt32, UInt32 > createTransformMapAddMissing(const BlockTypePalette &aFrom)
Returns an index-transform map from aFrom to this (this.entry(idx) == aFrom.entry(res[idx])).
void loadFromString(const AString &aString)
Loads the palette from the string representation.
void loadFromTsv(const AString &aTsvPalette, bool aIsUpgrade)
Loads the palette from the regular or upgrade TSV representation.
std::pair< UInt32, bool > maybeIndex(const AString &aBlockTypeName, const BlockState &aBlockState) const
Returns the <index, true> of the specified block type name and state, if it exists.
std::unordered_map< AString, std::map< BlockState, UInt32 > > mBlockToNumber
The mapping from stringular to numeric representation.
UInt32 count() const
Returns the total number of entries in the palette.
void loadFromJsonString(const AString &aJsonPalette)
Loads the palette from the JSON representation, https://wiki.vg/Data_Generators Throws a LoadFailedEx...
UInt32 index(const AString &aBlockTypeName, const BlockState &aBlockState)
Returns the index of the specified block type name and state.
std::map< UInt32, UInt32 > createTransformMapWithFallback(const BlockTypePalette &aFrom, UInt32 aFallbackIndex) const
Returns an index-transform map from aFrom to this (this.entry(idx) == aFrom.entry(res[idx])).
const std::pair< AString, BlockState > & entry(UInt32 aIndex) const
Returns the blockspec represented by the specified palette index.
std::map< UInt32, std::pair< AString, BlockState > > mNumberToBlock
The mapping from numeric to stringular representation.
void addMapping(UInt32 aID, const AString &aBlockTypeName, const BlockState &aBlockState)
Adds a mapping between the numeric and stringular representation into both maps, updates the mMaxInde...
UInt32 mMaxIndex
The maximum index ever used in the maps.
BlockTypePalette()
Create a new empty instance.
Exception that is thrown if requiesting an index not present in the palette.
NoSuchIndexException(UInt32 aIndex)
Exception that is thrown when loading the palette fails hard (bad format).
LoadFailedException(const AString &aReason)