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

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

/**
 * Lua API function that places a block in front of the entity.
 */
public class PlaceBlockAheadFunction extends EduCraftApiFunction {
    @Override
    public Varargs execute(Varargs varargs) {
        if (getApi().getEnvironment().contains(getApi().getBlockAhead().getLocation())) {
            getApi().getBlockAhead().setType(PlaceBlockFunction.getMaterial(varargs.checkjstring(1)));
        }
        return LuaValue.NIL;
    }
}

@@ -111,16 +111,44 @@
 nction;%0A
+import org.bukkit.Location;%0A
 import o
@@ -410,85 +410,179 @@
     
-if (getApi().getEnvironment().contains(getApi().getBlockAhead().getL
+Location location = getApi().getBlockAhead().getLocation();%0A        if (getApi().getEnvironment().contains(location) && !getApi().getEnvironment().isAliveEntityAt(l
 ocation
-()
 )) %7B

Fix bot placing blocks inside entities.