Search in sources :

Example 1 with AField

use of org.asassecreations.engine.serializer.AField in project Voxel_Game by ASasseCreations.

the class PlayerSave method load.

public static final void load(final Player player) {
    player.position.x = 8;
    player.position.y = 120;
    player.position.z = 8;
    player.rotation = 25;
    ChunkGenerator.init(new Random().nextLong());
    Time.rawTime = .1f;
    if (!new File(Content.WORLD_FOLDER + "Player.dat").exists())
        return;
    final ADatabase database = ADatabase.DeserializeFromFile(Content.WORLD_FOLDER + "Player.dat");
    final AObject object = database.findObject("Player");
    AField temp;
    if ((temp = object.findField("x")) != null)
        player.position.x = temp.getFloat();
    if ((temp = object.findField("y")) != null)
        player.position.y = temp.getFloat();
    if ((temp = object.findField("z")) != null)
        player.position.z = temp.getFloat();
    if ((temp = object.findField("rotation")) != null)
        player.rotation = temp.getFloat();
    if ((temp = object.findField("seed")) != null)
        ChunkGenerator.init(temp.getLong());
    if ((temp = object.findField("time")) != null)
        Time.rawTime = temp.getFloat();
    temp = null;
}
Also used : Random(java.util.Random) AObject(org.asassecreations.engine.serializer.AObject) File(java.io.File) ADatabase(org.asassecreations.engine.serializer.ADatabase) AField(org.asassecreations.engine.serializer.AField)

Aggregations

File (java.io.File)1 Random (java.util.Random)1 ADatabase (org.asassecreations.engine.serializer.ADatabase)1 AField (org.asassecreations.engine.serializer.AField)1 AObject (org.asassecreations.engine.serializer.AObject)1