use of org.bukkit.util.BlockIterator in project MassiveCore by MassiveCraft.
the class DestinationUtil method getJumpLocation.
public static Location getJumpLocation(LivingEntity livingEntity) {
BlockIterator iter = createHeadlessIterator(livingEntity);
Block block = nextSolid(iter);
// Nothing solid in sight
if (block == null)
return null;
Location oldLocation = livingEntity.getLocation();
Location targetLocation = moveUp(moveLocationToBlock(oldLocation, block));
return targetLocation;
}
use of org.bukkit.util.BlockIterator in project MassiveCore by MassiveCraft.
the class DestinationUtil method createHeadlessIterator.
public static BlockIterator createHeadlessIterator(LivingEntity livingEntity) {
BlockIterator ret = new BlockIterator(livingEntity, 300);
ret.next();
return ret;
}
use of org.bukkit.util.BlockIterator in project Village_Defense by Plajer.
the class Util method getLineOfSight.
public static Queue<Block> getLineOfSight(LivingEntity entity, HashSet<Byte> transparent, int maxDistance, int maxLength) {
if (maxDistance > 120) {
maxDistance = 120;
}
Queue<Block> blocks = new LinkedList<>();
Iterator<Block> itr = new BlockIterator(entity, maxDistance);
while (itr.hasNext()) {
Block block = itr.next();
blocks.add(block);
if (maxLength != 0 && blocks.size() > maxLength) {
blocks.remove(0);
}
int id = block.getTypeId();
if (transparent == null) {
if (id != 0 && id != 50 && id != 59 && id != 31 && id != 175 && id != 38 && id != 37 && id != 6 && id != 106)
break;
} else {
if (!transparent.contains((byte) id))
break;
}
}
return blocks;
}
Aggregations