test: extend coverage of testPortal
This commit is contained in:
1 parent
dd55276675
commit
7eb223fa7a
1 file changed
+87
@@ -318,3 +318,90 @@ VF_TEST(builtFrameCarvesItsOwnApproachOutOfTheTerrain) {
|
|||||||
for (int gz = 0; gz < 10; ++gz)
|
for (int gz = 0; gz < 10; ++gz)
|
||||||
world.setBlock(gx, gy, gz, Block::Netherrack);
|
world.setBlock(gx, gy, gz, Block::Netherrack);
|
||||||
|
|
||||||
|
PortalFrame frame;
|
||||||
|
frame.origin = {4, 42, 5};
|
||||||
|
frame.width = 2;
|
||||||
|
frame.height = 3;
|
||||||
|
frame.alongX = true;
|
||||||
|
frame.dimension = DimensionId::Nether;
|
||||||
|
|
||||||
|
CHECK(PortalScan::siteUsable(world, frame));
|
||||||
|
PortalScan::buildFrame(world, frame);
|
||||||
|
|
||||||
|
CHECK(PortalScan::intact(world, frame));
|
||||||
|
CHECK(PortalScan::interiorClear(world, frame));
|
||||||
|
CHECK_EQ(world.blockAt(4, 42, 4), Block::Air);
|
||||||
|
CHECK_EQ(world.blockAt(5, 42, 6), Block::Air);
|
||||||
|
CHECK_EQ(world.blockAt(4, 41, 4), Block::Obsidian);
|
||||||
|
CHECK_EQ(world.blockAt(4, 41, 6), Block::Obsidian);
|
||||||
|
CHECK_EQ(world.blockAt(0, 42, 0), Block::Netherrack);
|
||||||
|
CHECK_EQ(PortalScan::light(world, frame), 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
VF_TEST(bedrockMakesASiteUnusable) {
|
||||||
|
World world;
|
||||||
|
PortalFrame frame;
|
||||||
|
frame.origin = {0, 2, 0};
|
||||||
|
frame.width = 2;
|
||||||
|
frame.height = 3;
|
||||||
|
frame.alongX = true;
|
||||||
|
|
||||||
|
CHECK(PortalScan::siteUsable(world, frame));
|
||||||
|
world.setBlock(0, 1, 0, Block::Bedrock);
|
||||||
|
CHECK(!PortalScan::siteUsable(world, frame));
|
||||||
|
}
|
||||||
|
|
||||||
|
VF_TEST(endPortalIgnitesOnlyOnceEveryEyeIsSeated) {
|
||||||
|
DimensionSet dimensions(121u);
|
||||||
|
PortalNetwork network(dimensions);
|
||||||
|
Vec3i center{40, 60, 40};
|
||||||
|
|
||||||
|
CHECK_EQ(network.buildEndFrame(DimensionId::End, center), PortalNetwork::endFrameSlots);
|
||||||
|
const World& world = dimensions.end().world();
|
||||||
|
CHECK_EQ(world.blockAt(38, 60, 40), Block::EndPortalFrame);
|
||||||
|
CHECK_EQ(world.blockAt(40, 60, 42), Block::EndPortalFrame);
|
||||||
|
CHECK_EQ(world.blockAt(38, 60, 38), Block::Air); // corners stay empty
|
||||||
|
CHECK_EQ(world.blockAt(42, 60, 42), Block::Air);
|
||||||
|
CHECK_EQ(world.blockAt(40, 60, 40), Block::Air);
|
||||||
|
|
||||||
|
const int offsetX[PortalNetwork::endFrameSlots] = {-2, -2, -2, 2, 2, 2, -1, 0, 1, -1, 0, 1};
|
||||||
|
const int offsetZ[PortalNetwork::endFrameSlots] = {-1, 0, 1, -1, 0, 1, -2, -2, -2, 2, 2, 2};
|
||||||
|
|
||||||
|
for (int slot = 0; slot < PortalNetwork::endFrameSlots - 1; ++slot) {
|
||||||
|
Vec3i socket{center.x + offsetX[slot], center.y, center.z + offsetZ[slot]};
|
||||||
|
CHECK(network.insertEndEye(DimensionId::End, socket));
|
||||||
|
CHECK(network.hasEndEye(DimensionId::End, socket));
|
||||||
|
CHECK_EQ(network.endEyeCount(DimensionId::End, center), slot + 1);
|
||||||
|
CHECK(!network.endFrameComplete(DimensionId::End, center));
|
||||||
|
CHECK_EQ(world.blockAt(center.x, center.y, center.z), Block::Air);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3i last{center.x + offsetX[11], center.y, center.z + offsetZ[11]};
|
||||||
|
CHECK(network.insertEndEye(DimensionId::End, last));
|
||||||
|
CHECK(network.endFrameComplete(DimensionId::End, center));
|
||||||
|
|
||||||
|
int portalCells = 0;
|
||||||
|
for (int dx = -1; dx <= 1; ++dx)
|
||||||
|
for (int dz = -1; dz <= 1; ++dz)
|
||||||
|
if (world.blockAt(center.x + dx, center.y, center.z + dz) == Block::EndPortal)
|
||||||
|
++portalCells;
|
||||||
|
CHECK_EQ(portalCells, 9);
|
||||||
|
}
|
||||||
|
|
||||||
|
VF_TEST(endPortalEyesOnlyGoIntoRealFrameBlocks) {
|
||||||
|
DimensionSet dimensions(122u);
|
||||||
|
PortalNetwork network(dimensions);
|
||||||
|
Vec3i center{0, 50, 0};
|
||||||
|
network.buildEndFrame(DimensionId::End, center);
|
||||||
|
|
||||||
|
Vec3i socket{-2, 50, 0};
|
||||||
|
CHECK(network.insertEndEye(DimensionId::End, socket));
|
||||||
|
CHECK(!network.insertEndEye(DimensionId::End, socket));
|
||||||
|
CHECK(!network.insertEndEye(DimensionId::End, {-2, 50, -2}));
|
||||||
|
CHECK(!network.insertEndEye(DimensionId::End, {9, 9, 9}));
|
||||||
|
CHECK_EQ(network.endEyeCount(DimensionId::End, center), 1);
|
||||||
|
|
||||||
|
// The same socket in another dimension is a different socket entirely.
|
||||||
|
CHECK(!network.hasEndEye(DimensionId::Overworld, socket));
|
||||||
|
CHECK(!network.activateEndPortal(DimensionId::End, center));
|
||||||
|
}
|
||||||
Reference in new issue
Block a user