use of fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache in project NoCheatPlus by NoCheatPlus.
the class TestInteractRayTracing method testRoom.
@Test
public void testRoom() {
// TODO: Test for differing middle points (negative to positive range, random, selected rays).
FakeBlockCache bc = new FakeBlockCache();
bc.room(-1, 64, -1, 1, 66, 1, Material.STONE);
// Note that reversed checks are slightly different with the centered version, but start + end blocks are air anyway.
// Free spot.
double[] middle = new double[] { 0.5, 65.5, 0.5 };
// TODO: Must work with strict set to false.
CenteredInteractRayTracing rt = new CenteredInteractRayTracing(false, 0, 65, 0);
// CenteredInteractRayTracing rt = new CenteredInteractRayTracing(true, 0, 65, 0);
rt.setBlockCache(bc);
double[][] pastFailures = new double[][] { { 2.1393379885667643, 67.18197661625649, 1.7065201483677281, 0.0, 65.0, 0.0 }, { 2.7915547712543676, 66.65545738305906, 1.310222428430474, 0.0, 65.0, 0.0 }, // strict is false.
{ 0.0, 65.0, 4.5, 0.0, 65.0, 1.0 }, // strict is false.
{ -3.5, 61.5, -3.5, 0.0, 65.0, 0.0 } };
TestRayTracing.runCoordinates(rt, pastFailures, true, false, 3, true);
boolean intense = BuildParameters.testLevel > 1;
for (double x = -0.5; x < 1.0; x += 0.5) {
for (double y = -0.5; y < 1.0; y += 0.5) {
for (double z = -0.5; z < 1.0; z += 0.5) {
double add = Math.abs(x) + Math.abs(y) + Math.abs(z);
TestRayTracing.runCenterRays(rt, middle[0] + x, middle[1] + y, middle[2] + z, 2.0 + add, intense ? 10000 : 1000, true, false, true);
}
}
}
rt.cleanup();
bc.cleanup();
}
use of fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache in project NoCheatPlus by NoCheatPlus.
the class TestInteractRayTracing method testWall.
@Test
public void testWall() {
FakeBlockCache bc = new FakeBlockCache();
// Wall using full blocks.
bc.walls(0, 65, 0, 16, 67, 0, Material.STONE);
// Ground using full blocks (roughly 16 margin to each side).
bc.fill(-16, 64, -16, 32, 64, 16, Material.STONE);
// TODO: Test chest like bounds for target blocks.
InteractRayTracing rt = new InteractRayTracing(false);
rt.setBlockCache(bc);
// TODO: More cases, head inside block itself, angles, ...
double[][] noCollision = new double[][] { { 8.5, 66.75, 1.2, 8.5, 65.8, 1.0 }, { 8.5, 66.75, 1.2, 8.5, 70.0, 0.9 } };
TestRayTracing.runCoordinates(rt, noCollision, false, true, 3.0, true);
double[][] shouldCollide = new double[][] { { 8.5, 66.75, 1.2, 8.5, 65.8, 0.0 }, { 8.5, 66.75, 1.2, 8.5, 65.8, -0.2 } };
TestRayTracing.runCoordinates(rt, shouldCollide, true, false, 3.0, true);
rt.cleanup();
bc.cleanup();
}
use of fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache in project NoCheatPlus by NoCheatPlus.
the class TestPassableRayTracing method testEmptyCorner.
/**
* Moving diagonally through an "empty corner", seen from above:<br>
* ox<br>
* xo
*/
@Test
public void testEmptyCorner() {
FakeBlockCache bc = new FakeBlockCache();
// The "empty corner" setup.
bc.set(10, 70, 10, Material.STONE);
bc.set(11, 70, 11, Material.STONE);
// Ground.
for (int x = 9; x < 13; x++) {
for (int z = 9; z < 13; z++) {
bc.set(x, 69, z, Material.STONE);
}
}
PassableRayTracing rt = new PassableRayTracing();
rt.setBlockCache(bc);
// TODO: More Directions, over a corner, sides, etc.
double[][] setups = new double[][] { // Slightly off the middle (11, y, 11)
{ 11.4, 70.0, 10.4, 10.6, 70.0, 11.4 }, // Going exactly through the middle (11, y, 11)
{ 11.4, 70.0, 10.6, 10.6, 70.0, 11.4 }, { 11.5, 70.0, 10.5, 10.5, 70.0, 11.5 } // {11.5, 70.0, 10.5, 10.99999999999, 70.0, 11.00000000001}, // TODO: Craft something here
};
TestRayTracing.runCoordinates(rt, setups, true, false, 3.0, true);
rt.cleanup();
bc.cleanup();
}
use of fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache in project NoCheatPlus by NoCheatPlus.
the class TestPassableRayTracing method testRoom.
@Test
public void testRoom() {
FakeBlockCache bc = new FakeBlockCache();
bc.room(-1, 64, -1, 1, 66, 1, Material.STONE);
// Free spot.
double[] middle = new double[] { 0.5, 65.5, 0.5 };
PassableRayTracing rt = new PassableRayTracing();
rt.setBlockCache(bc);
boolean intense = BuildParameters.testLevel > 1;
for (double x = -0.5; x < 1.0; x += 0.5) {
for (double y = -0.5; y < 1.0; y += 0.5) {
for (double z = -0.5; z < 1.0; z += 0.5) {
double add = Math.abs(x) + Math.abs(y) + Math.abs(z);
TestRayTracing.runCenterRays(rt, middle[0] + x, middle[1] + y, middle[2] + z, 2.0 + add, intense ? 10000 : 1000, true, false, true);
}
}
}
rt.cleanup();
bc.cleanup();
}
use of fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache in project NoCheatPlus by NoCheatPlus.
the class TestPassableRayTracing method testGround.
@Test
public void testGround() {
FakeBlockCache bc = new FakeBlockCache();
// Ground using full blocks.
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
bc.set(x, 65, z, Material.STONE);
}
}
PassableRayTracing rt = new PassableRayTracing();
rt.setBlockCache(bc);
// TODO: More Directions, also from air underneath to ground).
double[][] noCollision = new double[][] { { 1.3, 66.0, 2.43, 5.25, 66.0, 7.12 } };
TestRayTracing.runCoordinates(rt, noCollision, false, true, 3.0, true);
double[][] shouldCollide = new double[][] { { 1.3, 65.1, 2.43, 2.3, 65.1, 4.43 }, { 1.3, 65.0, 2.43, 2.3, 65.0, 4.43 }, { 1.3, 66.0, 2.43, 1.3, 65.9, 2.43 }, { 1.3, 66.0, 2.43, 5.25, 65.9, 7.12 }, // No distance.
{ 1.3, 65.4, 2.43, 1.3, 65.4, 2.43 } };
TestRayTracing.runCoordinates(rt, shouldCollide, true, false, 3.0, true);
rt.cleanup();
bc.cleanup();
}
Aggregations