Search in sources :

Example 21 with BlockIterator

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;
}
Also used : BlockIterator(org.bukkit.util.BlockIterator) Block(org.bukkit.block.Block) Location(org.bukkit.Location)

Example 22 with BlockIterator

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;
}
Also used : BlockIterator(org.bukkit.util.BlockIterator)

Example 23 with BlockIterator

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;
}
Also used : BlockIterator(org.bukkit.util.BlockIterator) Block(org.bukkit.block.Block) LinkedList(java.util.LinkedList)

Aggregations

BlockIterator (org.bukkit.util.BlockIterator)23 Block (org.bukkit.block.Block)20 Player (org.bukkit.entity.Player)10 Location (org.bukkit.Location)7 Material (org.bukkit.Material)6 EventHandler (org.bukkit.event.EventHandler)6 Entity (org.bukkit.entity.Entity)5 ItemStack (org.bukkit.inventory.ItemStack)5 ArrayList (java.util.ArrayList)4 ASkyBlock (com.wasteofplastic.acidisland.ASkyBlock)3 ASkyBlock (com.wasteofplastic.askyblock.ASkyBlock)3 RegionSign (me.wiefferink.areashop.features.signs.RegionSign)3 World (org.bukkit.World)3 HashMultiset (com.google.common.collect.HashMultiset)2 Multiset (com.google.common.collect.Multiset)2 Island (com.wasteofplastic.acidisland.Island)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileWriter (java.io.FileWriter)2 FilenameFilter (java.io.FilenameFilter)2