Search in sources :

Example 1 with InteractRayTracing

use of fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing 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();
}
Also used : InteractRayTracing(fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing) FakeBlockCache(fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache) Test(org.junit.Test)

Example 2 with InteractRayTracing

use of fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing in project NoCheatPlus by NoCheatPlus.

the class TestInteractRayTracing 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.
    for (int y = 70; y < 73; y++) {
        bc.set(10, y, 10, Material.STONE);
        bc.set(11, y, 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);
        }
    }
    // TODO: Make work with strict set to false.
    // InteractRayTracing rt = new InteractRayTracing(true);
    InteractRayTracing rt = new InteractRayTracing(false);
    rt.setBlockCache(bc);
    // TODO: More Directions, also just behind the corner.
    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 } };
    TestRayTracing.runCoordinates(rt, setups, true, false, 3.0, true);
    rt.cleanup();
    bc.cleanup();
}
Also used : InteractRayTracing(fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing) FakeBlockCache(fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache) Test(org.junit.Test)

Example 3 with InteractRayTracing

use of fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing in project NoCheatPlus by NoCheatPlus.

the class TestInteractRayTracing method testAir.

@Test
public void testAir() {
    FakeBlockCache bc = new FakeBlockCache();
    InteractRayTracing rt = new InteractRayTracing();
    rt.setBlockCache(bc);
    double[] coords = new double[] { 0.5, 0.5, -0.5, 0.5, 0.5, 1.5 };
    rt.set(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
    rt.loop();
    if (rt.collides()) {
        TestRayTracing.doFail("Expect not to collide with air.", coords);
    }
    if (rt.getStepsDone() > 4) {
        TestRayTracing.doFail("Expect less than 4 steps for moving straight through a block of air.", coords);
    }
    rt.cleanup();
    bc.cleanup();
}
Also used : InteractRayTracing(fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing) FakeBlockCache(fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache) Test(org.junit.Test)

Aggregations

InteractRayTracing (fr.neatmonster.nocheatplus.utilities.collision.InteractRayTracing)3 FakeBlockCache (fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache)3 Test (org.junit.Test)3