package com.example.tests;
import com.frotty27.hrtk.api.annotation.HytaleSuite;
import com.frotty27.hrtk.api.annotation.WorldTest;
import com.frotty27.hrtk.api.annotation.Tag;
import com.frotty27.hrtk.api.annotation.DisplayName;
import com.frotty27.hrtk.api.annotation.Order;
import com.frotty27.hrtk.api.assert_.ChunkAssert;
import com.frotty27.hrtk.api.assert_.HytaleAssert;
import com.frotty27.hrtk.api.context.WorldTestContext;
import com.frotty27.hrtk.api.lifecycle.IsolationStrategy;
@HytaleSuite(value = "Chunk Surface Tests", isolation = IsolationStrategy.DEDICATED_WORLD)
@Tag("chunks")
public class ChunkSurfaceTests {
@WorldTest
@Order(1)
@DisplayName("Chunk at spawn origin is loaded after entity spawn")
void chunkLoadedAtSpawn(WorldTestContext ctx) {
// Spawning an entity forces the chunk at that position to load.
ctx.spawnNPC("Kweebec_Sapling", 0, 64, 0);
ctx.waitTicks(5);
// Chunk coordinates are block coordinates divided by chunk size.
// Block (0, 64, 0) falls in chunk (0, 0).
ChunkAssert.assertChunkLoaded(ctx.getWorld(), 0, 0);
}
@WorldTest
@Order(2)
@DisplayName("Distant chunk is not loaded")
void distantChunkNotLoaded(WorldTestContext ctx) {
// A chunk far from any entity or player should not be loaded.
// Chunk (1000, 1000) is very far from the origin.
ChunkAssert.assertChunkNotLoaded(ctx.getWorld(), 1000, 1000);
}
@WorldTest
@Order(3)
@DisplayName("Placing a block loads the containing chunk")
void blockPlacementLoadsChunk(WorldTestContext ctx) {
// Place a block at (160, 64, 160), which falls in chunk (10, 10).
ctx.setBlock(160, 64, 160, "Rock_Sandstone");
ctx.waitTicks(5);
ChunkAssert.assertChunkLoaded(ctx.getWorld(), 10, 10);
}
}