summaryrefslogtreecommitdiffstats
path: root/src/BlockID.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockID.cpp')
-rw-r--r--src/BlockID.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index bfe826f40..641a6a225 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -345,6 +345,41 @@ eDimension StringToDimension(const AString & a_DimensionString)
+AString DimensionToString(eDimension a_Dimension)
+{
+ // Decode using a built-in map:
+ static struct
+ {
+ eDimension m_Dimension;
+ const char * m_String;
+ } DimensionMap[] =
+ {
+ { dimOverworld, "Overworld" },
+ { dimOverworld, "Normal" },
+ { dimOverworld, "World" },
+ { dimNether, "Nether" },
+ { dimNether, "Hell" }, // Alternate name for Nether
+ { dimEnd, "End" },
+ { dimEnd, "Sky" }, // Old name for End
+ };
+
+ for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++)
+ {
+ if (DimensionMap[i].m_Dimension == a_Dimension)
+ {
+ return DimensionMap[i].m_String;
+ }
+ } // for i - DimensionMap[]
+
+ // Not found
+ LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", (int)a_Dimension);
+ return "Overworld";
+}
+
+
+
+
+
/// Translates damage type constant to a string representation (built-in).
AString DamageTypeToString(eDamageType a_DamageType)
{