Okay it now works:
function DirtsprayProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
echo("Normal: " @ %normal);
echo("Pos: " @ %pos);
%pos = %col.getPosition();
%x = getWord(%pos, 0);
%y = getWord(%pos, 1);
%z = getWord(%pos, 2);
switch(%normal)
{
case "0 0 1":
%pos2 = %x SPC %y SPC %z+2;
case "0 0 -1":
%pos2 = %x SPC %y SPC %z-2;
case "0 1 0":
%pos2 = %x SPC %y+2 SPC %z;
case "0 -1 0":
%pos2 = %x SPC %y-2 SPC %z;
case "1 0 0":
%pos2 = %x+2 SPC %y SPC %z;
case "-1 0 0":
%pos2 = %x-2 SPC %y SPC %z;
default:
echo("** Normals Error");
}
echo("Pos2: " @ %pos2);
%x2 = getWord(%pos2, 0);
%y2 = getWord(%pos2, 1);
%z2 = getWord(%pos2, 2);
if(%col.getDatablock().brickSizeX == 4 && %col.getDatablock().brickSizeY == 4 && %obj.client.dig_dirt >= 1 ) //&& !$Dig_hasDirt[%pos2])
{
%obj.client.dig_dirt--;
Dig_PlaceDirt(%pos2,%obj.client);
$Dig_placedDirt[%pos2] = 1;
$Dig_hasDirt[%pos2] = 1;
}
else if(%pos2 != %col.getPosition())
echo("*** The pos2 is the same as the col pos thing errored");
else if($Dig_hasDirt[%pos2] != 0)
echo("*** Has dirt on pos thing errored");
else if($Dig_placedDirt[%pos2])
echo("*** Placed dirt thing errored");
else if(mAbs(%x2) <= 11 && mAbs(%y2) <= 11 && %z2 <= 10 && %z2 >= 0)
echo("*** mAbs thing errored");
}
The problem now is, whenever the normals are "0 -1 0", "0 1 0", "0 0 1", and "0 0 -1", the block always plants on top of the block. The x axis is fine, but the two other axes always add vectors to the top.