@@ -58,14 +58,20 @@ public static final boolean hasCacheMarker(MapState state){
5858 private static final record MapStateSerializable (byte scale , boolean locked , String dimRegistry , String dimValue , byte [] colors ) implements Serializable {
5959 private static final long serialVersionUID = 2713495820097984925L ;
6060
61- public static MapStateSerializable fromMapState (MapState ms ){
61+ public static final MapStateSerializable fromMapState (MapState ms ){
6262 return ms == null /* || ms.colors == null*/ ? null :
63- new MapStateSerializable (ms .scale , ms .locked , ms .dimension .getRegistry ().toString (), ms .dimension .getValue ().toString (), ms .colors );
63+ new MapStateSerializable (ms .scale , ms .locked ,
64+ ms .dimension == null ? null : ms .dimension .getRegistry ().toString (),
65+ ms .dimension == null ? null : ms .dimension .getValue ().toString (), ms .colors );
6466 }
65- public MapState toMapState (){
66- Identifier registryId = Identifier .of (dimRegistry ), valueId = Identifier .of (dimValue );
67- RegistryKey <World > dimension = RegistryKey .of (RegistryKey .ofRegistry (registryId ), valueId );
68- MapState ms = MapState .of (scale , locked , dimension );
67+ public final MapState toMapState (){
68+ final RegistryKey <World > dimension ;
69+ if (dimRegistry != null ){
70+ final Identifier registryId = Identifier .of (dimRegistry ), valueId = Identifier .of (dimValue );
71+ dimension = RegistryKey .of (RegistryKey .ofRegistry (registryId ), valueId );
72+ }
73+ else dimension = null ;
74+ final MapState ms = MapState .of (scale , locked , dimension );
6975 ms .colors = colors ;
7076 ms .replaceDecorations (List .of (CACHED_MARKER_DECORATION ));
7177 return ms ;
0 commit comments