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;
}
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();
}
Aggregations