Search in sources :

Example 6 with ChunkStore

use of org.terasology.persistence.ChunkStore in project Terasology by MovingBlocks.

the class StorageManagerTest method testStoreAndRestoreChunkStore.

@Test
public void testStoreAndRestoreChunkStore() {
    Chunk chunk = new ChunkImpl(CHUNK_POS, blockManager, biomeManager);
    chunk.setBlock(0, 0, 0, testBlock);
    chunk.markReady();
    ChunkProvider chunkProvider = mock(ChunkProvider.class);
    when(chunkProvider.getAllChunks()).thenReturn(Arrays.asList(chunk));
    CoreRegistry.put(ChunkProvider.class, chunkProvider);
    esm.waitForCompletionOfPreviousSaveAndStartSaving();
    esm.finishSavingAndShutdown();
    ChunkStore restored = esm.loadChunkStore(CHUNK_POS);
    assertNotNull(restored);
    assertEquals(CHUNK_POS, restored.getChunkPosition());
    assertNotNull(restored.getChunk());
    assertEquals(testBlock, restored.getChunk().getBlock(0, 0, 0));
}
Also used : ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Chunk(org.terasology.world.chunks.Chunk) ChunkProvider(org.terasology.world.chunks.ChunkProvider) ChunkStore(org.terasology.persistence.ChunkStore) Test(org.junit.Test)

Aggregations

ChunkStore (org.terasology.persistence.ChunkStore)6 Chunk (org.terasology.world.chunks.Chunk)5 Test (org.junit.Test)4 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)4 ChunkProvider (org.terasology.world.chunks.ChunkProvider)3 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 StorageManager (org.terasology.persistence.StorageManager)2 ReadyChunkInfo (org.terasology.world.chunks.internal.ReadyChunkInfo)2 TShortObjectMap (gnu.trove.map.TShortObjectMap)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 LocationComponent (org.terasology.logic.location.LocationComponent)1 Vector3f (org.terasology.math.geom.Vector3f)1 Vector3i (org.terasology.math.geom.Vector3i)1 EntityData (org.terasology.protobuf.EntityData)1 ManagedChunk (org.terasology.world.chunks.ManagedChunk)1 AbstractChunkTask (org.terasology.world.chunks.pipeline.AbstractChunkTask)1 EntityBufferImpl (org.terasology.world.generation.impl.EntityBufferImpl)1