function mc_blockData_grass::onPlant(%d,%o){echo(yes);%o.setColliding(0);}
function mc_blockData_grass2::onPlant(%d,%o){%o.setColliding(0);}
function mc_blockData_snowCover::onPlant(%d,%o){%o.setColliding(0);}

mc_blockData_tnt.mcHasInteractSpecial = true;

function mc_blockData_tnt_mcInteractSpecial( %this, %obj, %pl )
{
	if ( !%pl.client.isAdmin )
	{
		return true;
	}

	if ( isEventPending( %obj.explodeSchedule ) )
	{
		return true;
	}

	serverPlay3D( Minecraft_Click, %obj.getPosition() );

	%obj.tntActivator = %pl.client;
	%obj.tntBlink = %obj.schedule( 500, "tntBlink" );
	%obj.explodeSchedule = %obj.schedule( 4000, "tntExplode" );

	return true;
}

function fxDTSBrick::tntBlink( %this )
{
	cancel( %this.tntBlink );

	if ( %this.colorFxID $= 3 )
	{
		//%this.setColorFX( 0 );
		//%this.setColor( mc_tntBlock.colorBCS );
	}
	else
	{
		//%this.setColorFX( 3 );
		//%this.setColor( $completeWhite );
	}

	%this.tntBlink = %this.schedule( 500, "tntBlink" );
}

function fxDTSBrick::tntExplode( %this )
{
	if ( %this.startExplode )
	{
		return;
	}

	%this.startExplode = true;

	%pos = %this.getPosition();
	%near = %this.getNumNearbyTNT();
	%rads = 4 + mFloor( %near );
	%scal = 1 + mFloor( %near / 2 );

	%this.spawnExplosion( rocketLauncherProjectile, %scal, %this.tntActivator );
	%this.mcDestroy();

	initContainerRadiusSearch( %pos, %rads, $TypeMasks::fxBrickObjectType );

	while ( isObject( %obj = containerSearchNext() ) )
	{
		if ( %obj $= %this )
		{
			continue;
		}

		%obj.mcDestroy();
	}
}

function fxDTSBrick::getNumNearbyTNT( %this )
{
	%num = 0;

	initContainerRadiusSearch( %this.getPosition(), 6, $TypeMasks::fxBrickObjectType );

	while ( isObject( %obj = containerSearchNext() ) )
	{
		if ( %obj $= %this )
		{
			continue;
		}

		if ( %obj.getDataBlock().uiName $= "TNT" )
		{
			%num++;
		}
	}

	return %num;
}
