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();
}
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);
}
Aggregations