package de.craften.plugins.educraft.luaapi.functions;

import de.craften.plugins.educraft.luaapi.EduCraftApiFunction;
import org.bukkit.Location;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;

/**
 * Lua API function to move one block forward.
 */
public class MoveForwardFunction extends EduCraftApiFunction {
    @Override
    public Varargs execute(Varargs varargs) {
        Location targetLocation = getApi().getStationaryBehavior().getLocation().clone().add(getApi().getDirection());

        if (!targetLocation.getBlock().getType().isSolid()) {
            getApi().getStationaryBehavior().setLocation(targetLocation);
        }

        return LuaValue.NIL;
    }
}

@@ -135,24 +135,59 @@
 t.Location;%0A
+import org.bukkit.block.BlockFace;%0A
 import org.l
@@ -590,16 +590,108 @@
 sSolid()
+%0A                && !targetLocation.getBlock().getRelative(BlockFace.UP).getType().isSolid()
 ) %7B%0A    

Check if two blocks are non-solid before moving forward.