Search in sources :

Example 6 with PassableRayTracing

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

the class TestPassableRayTracing method testThroughOneBlock.

@Test
public void testThroughOneBlock() {
    FakeBlockCache bc = new FakeBlockCache();
    bc.set(0, 0, 0, Material.STONE);
    PassableRayTracing rt = new PassableRayTracing();
    rt.setBlockCache(bc);
    double[][] setups = new double[][] { // Through the middle of the block.
    { 0.5, 0.5, -0.5, 0.5, 0.5, 1.5 }, { -0.5, 0.5, 0.5, 1.5, 0.5, 0.5 }, { 0.5, -0.5, 0.5, 0.5, 1.5, 0.5 }, // Along the edges.
    { 0.5, 0.0, -0.5, 0.5, 0.0, 1.5 }, { -0.5, 0.0, 0.5, 1.5, 0.0, 0.5 }, // 3d
    { -0.5, -0.5, -0.5, 1.5, 1.5, 1.5 }, // 2d
    { -0.5, 0.0, -0.5, 1.5, 0.0, 1.5 }, // Through a corner.
    { 1.2, 0.5, 0.5, 0.5, 0.5, 1.2 } // TODO: More of each and other... + generic set-ups?
    };
    TestRayTracing.runCoordinates(rt, setups, true, false, 3.0, true);
    rt.cleanup();
    bc.cleanup();
}
Also used : PassableRayTracing(fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing) FakeBlockCache(fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache) Test(org.junit.Test)

Example 7 with PassableRayTracing

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

the class BlockProperties method init.

/**
 * Initialize blocks and tools properties. This can be called at any time
 * during runtime.
 *
 * @param mcAccess
 *            If mcAccess implements BlockPropertiesSetup,
 *            mcAccess.setupBlockProperties will be called directly after
 *            basic initialization but before the configuration is applied.
 * @param worldConfigProvider
 *            the world config provider
 */
public static void init(final IHandle<MCAccess> mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
    wrapBlockCache = new WrapBlockCache();
    rtRay = new PassableRayTracing();
    rtAxis = new PassableAxisTracing();
    pLoc = new PlayerLocation(mcAccess, null);
    // getClass().getName() or some abstract.
    final Set<String> blocksFeatures = new LinkedHashSet<String>();
    try {
        initTools(mcAccess, worldConfigProvider);
        initBlocks(mcAccess, worldConfigProvider);
        blocksFeatures.add("BlocksMC1_4");
        // Extra hand picked setups.
        try {
            blocksFeatures.addAll(new VanillaBlocksFactory().setupVanillaBlocks(worldConfigProvider));
        } catch (Throwable t) {
            StaticLog.logSevere("Could not initialize vanilla blocks: " + t.getClass().getSimpleName() + " - " + t.getMessage());
            StaticLog.logSevere(t);
        }
        // Allow mcAccess to setup block properties.
        if (mcAccess instanceof BlockPropertiesSetup) {
            try {
                ((BlockPropertiesSetup) mcAccess).setupBlockProperties(worldConfigProvider);
                blocksFeatures.add(mcAccess.getClass().getSimpleName());
            } catch (Throwable t) {
                StaticLog.logSevere("McAccess.setupBlockProperties (" + mcAccess.getClass().getSimpleName() + ") could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
                StaticLog.logSevere(t);
            }
        }
    // TODO: Add registry for further BlockPropertiesSetup instances.
    } catch (Throwable t) {
        StaticLog.logSevere(t);
    }
    // Override feature tags for blocks.
    NCPAPIProvider.getNoCheatPlusAPI().setFeatureTags("blocks", blocksFeatures);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VanillaBlocksFactory(fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory) PassableAxisTracing(fr.neatmonster.nocheatplus.utilities.collision.PassableAxisTracing) PassableRayTracing(fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing) PlayerLocation(fr.neatmonster.nocheatplus.utilities.location.PlayerLocation) BlockPropertiesSetup(fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup)

Aggregations

PassableRayTracing (fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing)7 FakeBlockCache (fr.neatmonster.nocheatplus.utilities.map.FakeBlockCache)6 Test (org.junit.Test)6 BlockPropertiesSetup (fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup)1 VanillaBlocksFactory (fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory)1 PassableAxisTracing (fr.neatmonster.nocheatplus.utilities.collision.PassableAxisTracing)1 PlayerLocation (fr.neatmonster.nocheatplus.utilities.location.PlayerLocation)1 LinkedHashSet (java.util.LinkedHashSet)1