Search in sources :

Example 1 with BlockFace

use of com.elmakers.mine.bukkit.block.BlockFace in project MagicPlugin by elBukkit.

the class RecurseAction method getDirections.

@Nullable
protected List<BlockFace> getDirections(String name) {
    if (name == null) {
        return null;
    }
    if (name.equalsIgnoreCase("cardinal")) {
        return cardinalDirections;
    }
    if (name.equalsIgnoreCase("all")) {
        return allDirections;
    }
    if (name.equalsIgnoreCase("plane")) {
        return planeDirections;
    }
    BlockFace single = getBlockFace(name);
    if (single == null)
        return null;
    List<BlockFace> singleSet = new ArrayList<>();
    singleSet.add(single);
    return singleSet;
}
Also used : BlockFace(com.elmakers.mine.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) Nullable(javax.annotation.Nullable)

Example 2 with BlockFace

use of com.elmakers.mine.bukkit.block.BlockFace in project MagicPlugin by elBukkit.

the class RecurseAction method step.

@Override
public SpellResult step(CastContext context) {
    StackEntry current = stack.peek();
    Block block = current.block;
    int faceIndex = current.face++;
    if (faceIndex >= 0) {
        block = directions.get(faceIndex).getRelative(block);
    }
    long id = BlockData.getBlockId(block);
    if (touched.contains(id)) {
        return SpellResult.NO_TARGET;
    }
    if (!context.isDestructible(block)) {
        return SpellResult.NO_TARGET;
    }
    if (replaceable != null && !replaceable.contains(new MaterialAndData(block))) {
        return SpellResult.NO_TARGET;
    }
    if (faceIndex >= 0 && stack.size() <= recursionDepth) {
        if (checker) {
            BlockFace direction = directions.get(faceIndex);
            block = direction.getRelative(block);
        }
        stack.push(new StackEntry(block));
    }
    touched.add(id);
    actionContext.setTargetLocation(block.getLocation());
    actionContext.playEffects("recurse");
    return startActions();
}
Also used : BlockFace(com.elmakers.mine.bukkit.block.BlockFace) MaterialAndData(com.elmakers.mine.bukkit.block.MaterialAndData) Block(org.bukkit.block.Block)

Aggregations

BlockFace (com.elmakers.mine.bukkit.block.BlockFace)2 MaterialAndData (com.elmakers.mine.bukkit.block.MaterialAndData)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 Block (org.bukkit.block.Block)1