@@ -522,18 +522,18 @@ public boolean receiveMetadata(NbtCompound data)
522
522
{
523
523
MiniHUD .debugLog ("HudDataStorage#receiveMetadata(): received METADATA from Servux" );
524
524
525
- if (data .getInt ("version" ) != ServuxHudPacket .PROTOCOL_VERSION )
525
+ if (data .getInt ("version" , - 1 ) != ServuxHudPacket .PROTOCOL_VERSION )
526
526
{
527
527
MiniHUD .LOGGER .warn ("hudDataChannel: Mis-matched protocol version!" );
528
528
}
529
529
530
- this .setServuxVersion (data .getString ("servux" ));
531
- this .setWorldSpawn (new BlockPos (data .getInt ("spawnPosX" ), data .getInt ("spawnPosY" ), data .getInt ("spawnPosZ" )));
532
- this .setSpawnChunkRadius (data .getInt ("spawnChunkRadius" ), true );
530
+ this .setServuxVersion (data .getString ("servux" , "?" ));
531
+ this .setWorldSpawn (new BlockPos (data .getInt ("spawnPosX" , 0 ), data .getInt ("spawnPosY" , 0 ), data .getInt ("spawnPosZ" , 0 )));
532
+ this .setSpawnChunkRadius (data .getInt ("spawnChunkRadius" , 2 ), true );
533
533
534
- if (data .contains ("worldSeed" , Constants . NBT . TAG_LONG ))
534
+ if (data .contains ("worldSeed" ))
535
535
{
536
- this .setWorldSeed (data .getLong ("worldSeed" ));
536
+ this .setWorldSeed (data .getLong ("worldSeed" , - 1L ));
537
537
}
538
538
539
539
this .setIsServuxServer ();
@@ -588,13 +588,13 @@ public void receiveSpawnMetadata(NbtCompound data)
588
588
{
589
589
MiniHUD .debugLog ("HudDataStorage#receiveSpawnMetadata(): from Servux" );
590
590
591
- this .setServuxVersion (data .getString ("servux" ));
592
- this .setWorldSpawn (new BlockPos (data .getInt ("spawnPosX" ), data .getInt ("spawnPosY" ), data .getInt ("spawnPosZ" )));
593
- this .setSpawnChunkRadius (data .getInt ("spawnChunkRadius" ), true );
591
+ this .setServuxVersion (data .getString ("servux" , "?" ));
592
+ this .setWorldSpawn (new BlockPos (data .getInt ("spawnPosX" , 0 ), data .getInt ("spawnPosY" , 0 ), data .getInt ("spawnPosZ" , 0 )));
593
+ this .setSpawnChunkRadius (data .getInt ("spawnChunkRadius" , 2 ), true );
594
594
595
- if (data .contains ("worldSeed" , Constants . NBT . TAG_LONG ))
595
+ if (data .contains ("worldSeed" ))
596
596
{
597
- this .setWorldSeed (data .getLong ("worldSeed" ));
597
+ this .setWorldSeed (data .getLong ("worldSeed" , - 1L ));
598
598
}
599
599
600
600
if (Configs .Generic .HUD_DATA_SYNC .getBooleanValue ())
@@ -618,25 +618,25 @@ public void receiveWeatherData(NbtCompound data)
618
618
{
619
619
//MiniHUD.printDebug("HudDataStorage#receiveWeatherData(): from Servux");
620
620
621
- if (data .contains ("SetRaining" , Constants . NBT . TAG_INT ))
621
+ if (data .contains ("SetRaining" ))
622
622
{
623
- this .rainWeatherTimer = data .getInt ("SetRaining" );
623
+ this .rainWeatherTimer = data .getInt ("SetRaining" , - 1 );
624
624
}
625
625
if (data .contains ("isRaining" ))
626
626
{
627
- this .isRaining = data .getBoolean ("isRaining" );
627
+ this .isRaining = data .getBoolean ("isRaining" , false );
628
628
}
629
- if (data .contains ("SetThundering" , Constants . NBT . TAG_INT ))
629
+ if (data .contains ("SetThundering" ))
630
630
{
631
- this .thunderWeatherTimer = data .getInt ("SetThundering" );
631
+ this .thunderWeatherTimer = data .getInt ("SetThundering" , - 1 );
632
632
}
633
633
if (data .contains ("isThundering" ))
634
634
{
635
- this .isThundering = data .getBoolean ("isThundering" );
635
+ this .isThundering = data .getBoolean ("isThundering" , false );
636
636
}
637
- if (data .contains ("SetClear" , Constants . NBT . TAG_INT ))
637
+ if (data .contains ("SetClear" ))
638
638
{
639
- this .clearWeatherTimer = data .getInt ("SetClear" );
639
+ this .clearWeatherTimer = data .getInt ("SetClear" , - 1 );
640
640
}
641
641
642
642
if (!this .hasServuxServer () && DataStorage .getInstance ().hasServuxServer ())
@@ -677,17 +677,17 @@ public void receiveRecipeManager(NbtCompound data)
677
677
if (!DataStorage .getInstance ().hasIntegratedServer () && data .contains ("RecipeManager" ))
678
678
{
679
679
Collection <RecipeEntry <?>> recipes = new ArrayList <>();
680
- NbtList list = data .getList ("RecipeManager" , Constants . NBT . TAG_COMPOUND );
680
+ NbtList list = data .getOrCreateList ("RecipeManager" );
681
681
int count = 0 ;
682
682
683
683
this .preparedRecipes = PreparedRecipes .EMPTY ;
684
684
this .recipeCount = 0 ;
685
685
686
686
for (int i = 0 ; i < list .size (); i ++)
687
687
{
688
- NbtCompound item = list .getCompound (i );
689
- Identifier idReg = Identifier .tryParse (item .getString ("id_reg" ));
690
- Identifier idValue = Identifier .tryParse (item .getString ("id_value" ));
688
+ NbtCompound item = list .getOrCreateCompound (i );
689
+ Identifier idReg = Identifier .tryParse (item .getString ("id_reg" , "" ));
690
+ Identifier idValue = Identifier .tryParse (item .getString ("id_value" , "" ));
691
691
692
692
if (idReg == null || idValue == null )
693
693
{
@@ -697,7 +697,7 @@ public void receiveRecipeManager(NbtCompound data)
697
697
try
698
698
{
699
699
RegistryKey <Recipe <?>> key = RegistryKey .of (RegistryKey .ofRegistry (idReg ), idValue );
700
- Pair <Recipe <?>, NbtElement > pair = Recipe .CODEC .decode (DataStorage .getInstance ().getWorldRegistryManager ().getOps (NbtOps .INSTANCE ), item .getCompound ("recipe" )).getOrThrow ();
700
+ Pair <Recipe <?>, NbtElement > pair = Recipe .CODEC .decode (DataStorage .getInstance ().getWorldRegistryManager ().getOps (NbtOps .INSTANCE ), item .getOrCreateCompound ("recipe" )).getOrThrow ();
701
701
RecipeEntry <?> entry = new RecipeEntry <>(key , pair .getFirst ());
702
702
recipes .add (entry );
703
703
count ++;
0 commit comments