55import com .mojang .serialization .codecs .RecordCodecBuilder ;
66
77import io .github .haykam821 .consolebox .resource .ConsoleGameManager ;
8- import net .minecraft .text . Text ;
9- import net .minecraft .util .Identifier ;
10- import net .minecraft .util .dynamic . Codecs ;
11- import net .minecraft .util . math . Vec3d ;
8+ import net .minecraft .network . chat . Component ;
9+ import net .minecraft .resources .Identifier ;
10+ import net .minecraft .util .ExtraCodecs ;
11+ import net .minecraft .world . phys . Vec3 ;
1212import xyz .nucleoid .plasmid .api .game .GameOpenException ;
1313
1414public record ConsoleBoxConfig (
1515 Identifier game ,
16- Vec3d spectatorSpawnOffset ,
16+ Vec3 spectatorSpawnOffset ,
1717 int playerCount ,
1818 boolean swapXZ ,
1919 boolean save
2020) {
21- private static final Vec3d DEFAULT_SPECTATOR_SPAWN_OFFSET = new Vec3d (0 , 2 , 0 );
21+ private static final Vec3 DEFAULT_SPECTATOR_SPAWN_OFFSET = new Vec3 (0 , 2 , 0 );
2222
2323 public static final MapCodec <ConsoleBoxConfig > CODEC = RecordCodecBuilder .mapCodec (instance -> {
2424 return instance .group (
2525 Identifier .CODEC .fieldOf ("game" ).forGetter (ConsoleBoxConfig ::game ),
26- Codecs . VECTOR_3F .xmap (Vec3d ::new , Vec3d ::toVector3f ).optionalFieldOf ("spectator_spawn_offset" , DEFAULT_SPECTATOR_SPAWN_OFFSET ).forGetter (ConsoleBoxConfig ::spectatorSpawnOffset ),
26+ ExtraCodecs . VECTOR3F .xmap (Vec3 ::new , Vec3 ::toVector3f ).optionalFieldOf ("spectator_spawn_offset" , DEFAULT_SPECTATOR_SPAWN_OFFSET ).forGetter (ConsoleBoxConfig ::spectatorSpawnOffset ),
2727 Codec .intRange (1 , 4 ).optionalFieldOf ("players" , 1 ).forGetter (ConsoleBoxConfig ::playerCount ),
2828 Codec .BOOL .optionalFieldOf ("swap_x_z" , false ).forGetter (ConsoleBoxConfig ::swapXZ ),
2929 Codec .BOOL .optionalFieldOf ("save" , false ).forGetter (ConsoleBoxConfig ::save )
@@ -34,7 +34,7 @@ public byte[] getGameData() throws GameOpenException {
3434 byte [] data = ConsoleGameManager .getGameData (this .game );
3535
3636 if (data == null ) {
37- throw new GameOpenException (Text .translatable ("text.consolebox.nonexistent_console_game" , this .game ));
37+ throw new GameOpenException (Component .translatable ("text.consolebox.nonexistent_console_game" , this .game ));
3838 } else {
3939 return data ;
4040 }
0 commit comments