@@ -19,7 +19,7 @@ public class World
19
19
/// <summary>
20
20
/// The dimension info of the world
21
21
/// </summary>
22
- private static Dimension curDimension = new ( ) ;
22
+ private static Dimension curDimension = new ( ) ;
23
23
24
24
private static readonly Dictionary < string , Dimension > dimensionList = new ( ) ;
25
25
@@ -87,10 +87,32 @@ public static void StoreOneDimension(string dimensionName, Dictionary<string, ob
87
87
/// </summary>
88
88
/// <param name="name"> The name of the dimension type</param>
89
89
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
90
- public static void SetDimension ( string name )
91
- {
92
- curDimension = dimensionList [ name ] ; // Should not fail
93
- }
90
+ public static void SetDimension ( string name )
91
+ {
92
+ // Try to get the dimension using the name as is
93
+ if ( dimensionList . TryGetValue ( name , out Dimension dimension ) )
94
+ {
95
+ curDimension = dimension ;
96
+ return ; // Dimension found
97
+ }
98
+
99
+ // If not found, check if name lacks 'minecraft:' prefix and try again
100
+ if ( ! name . StartsWith ( "minecraft:" ) )
101
+ {
102
+ string prefixedName = "minecraft:" + name ;
103
+ if ( dimensionList . TryGetValue ( prefixedName , out dimension ) )
104
+ {
105
+ curDimension = dimension ;
106
+ return ; // Dimension found with prefixed name
107
+ }
108
+ }
109
+
110
+ // If still not found, dimension does not exist
111
+ throw new KeyNotFoundException ( $ "Dimension '{ name } ' not found in dimensions dictionary.") ;
112
+ }
113
+
114
+
115
+
94
116
95
117
96
118
/// <summary>
0 commit comments