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_.BlockAssert;
import com.frotty27.hrtk.api.assert_.HytaleAssert;
import com.frotty27.hrtk.api.assert_.WorldAssert;
import com.frotty27.hrtk.api.context.WorldTestContext;
import com.frotty27.hrtk.api.lifecycle.IsolationStrategy;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
@HytaleSuite(value = "Block Surface Tests", isolation = IsolationStrategy.DEDICATED_WORLD)
@Tag("blocks")
public class BlockSurfaceTests {
@WorldTest
@Order(1)
@DisplayName("Place a stone block and verify its material")
void placeAndVerifyMaterial(WorldTestContext ctx) {
ctx.setBlock(5, 64, 5, "Rock_Sandstone");
Object blockType = BlockType.fromString("Rock_Sandstone");
BlockAssert.assertBlockMaterial(blockType, "stone");
}
@WorldTest
@Order(2)
@DisplayName("Verify block state is 'default' after placement")
void blockStateIsDefault(WorldTestContext ctx) {
ctx.setBlock(10, 64, 10, "Rock_Sandstone");
Object blockType = BlockType.fromString("Rock_Sandstone");
BlockAssert.assertBlockState(blockType, "default");
}
@WorldTest
@Order(3)
@DisplayName("Verify trigger block is detected correctly")
void triggerBlockIsDetected(WorldTestContext ctx) {
ctx.setBlock(15, 64, 15, "Pressure_Plate");
Object blockType = BlockType.fromString("Pressure_Plate");
BlockAssert.assertBlockIsTrigger(blockType);
}
@WorldTest
@Order(4)
@DisplayName("Verify block group membership")
void blockBelongsToGroup(WorldTestContext ctx) {
ctx.setBlock(20, 64, 20, "Iron_Ore");
Object blockType = BlockType.fromString("Iron_Ore");
BlockAssert.assertBlockGroup(blockType, "ores");
}
@WorldTest
@Order(5)
@DisplayName("Place blocks in a region and verify corners")
void fillRegionAndVerify(WorldTestContext ctx) {
// fillRegion is batched into a single world-thread dispatch.
// This means the entire region is consistent when you assert.
ctx.fillRegion(0, 60, 0, 10, 60, 10, "Grass_Full");
WorldAssert.assertBlockAt(ctx.getWorld(), 0, 60, 0, "Grass_Full");
WorldAssert.assertBlockAt(ctx.getWorld(), 10, 60, 10, "Grass_Full");
WorldAssert.assertBlockAt(ctx.getWorld(), 5, 60, 5, "Grass_Full");
}
@WorldTest
@Order(6)
@DisplayName("Replacing a block changes its type")
void replacingBlockChangesType(WorldTestContext ctx) {
ctx.setBlock(25, 64, 25, "Rock_Sandstone");
WorldAssert.assertBlockAt(ctx.getWorld(), 25, 64, 25, "Rock_Sandstone");
// Overwrite the stone with dirt.
ctx.setBlock(25, 64, 25, "Soil_Dirt");
WorldAssert.assertBlockAt(ctx.getWorld(), 25, 64, 25, "Soil_Dirt");
WorldAssert.assertBlockNotAt(ctx.getWorld(), 25, 64, 25, "Rock_Sandstone");
}
@WorldTest
@Order(7)
@DisplayName("Read block type at coordinates")
void readBlockType(WorldTestContext ctx) {
ctx.setBlock(30, 64, 30, "Rock_Sandstone");
String blockType = ctx.getBlock(30, 64, 30);
HytaleAssert.assertEquals("Rock_Sandstone", blockType);
}
}