Java Code Examples for com.sk89q.worldedit.regions.Region#contains()

The following examples show how to use com.sk89q.worldedit.regions.Region#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiRegionExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean contains(int x, int y, int z) {
    if (region.contains(x, y, z)) {
        return true;
    }
    for (int i = 0; i < regions.length; i++) {
        if (i != index) {
            Region current = regions[i];
            if (current.contains(x, y, z)) {
                region = current;
                index = i;
                return true;
            }
        }
    }
    return false;
}
 
Example 2
Source File: MultiRegionExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean contains(int x, int z) {
    if (region.contains(x, z)) {
        return true;
    }
    for (int i = 0; i < regions.length; i++) {
        if (i != index) {
            Region current = regions[i];
            if (current.contains(x, z)) {
                region = current;
                index = i;
                return true;
            }
        }
    }
    return false;
}
 
Example 3
Source File: LoseCheckerTask.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
private boolean isInsideDeathzone(Location location, Game game, boolean useLiquidDeathzone) {
	boolean result = false;
	if (useLiquidDeathzone && FLOWING_MATERIALS.contains(location.getBlock().getType())) {
		result = true;
	} else {
		Vector vec = BukkitUtil.toVector(location);
		
		for (Region deathzone : game.getDeathzones().values()) {
			if (deathzone.contains(vec)) {
				//Location is in deathzone
				result = true;
				break;
			}
		}
	}
	
	return result;
}
 
Example 4
Source File: BukkitWorld.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
    World world = getWorld();

    List<Entity> ents = world.getEntities();
    List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>();
    for (Entity ent : ents) {
        if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
            addEntities(ent, entities);
        }
    }
    return entities;
}
 
Example 5
Source File: NukkitWorld.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
    Level world = getLevel();
    cn.nukkit.entity.Entity[] ents = world.getEntities();
    List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>();
    for (cn.nukkit.entity.Entity ent : ents) {
        if (region.contains(NukkitUtil.toVector(ent.getLocation()))) {
            entities.add(new NukkitEntity(ent));
        }
    }
    return entities;
}
 
Example 6
Source File: BlockArrayClipboard.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<? extends Entity> getEntities(Region region) {
    List<Entity> filtered = new ArrayList<Entity>();
    for (Entity entity : getEntities()) {
        if (region.contains(entity.getLocation().toVector())) {
            filtered.add(entity);
        }
    }
    return Collections.unmodifiableList(filtered);
}
 
Example 7
Source File: CuboidClipboard.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Copies blocks to the clipboard.
 *
 * @param editSession The EditSession from which to take the blocks
 * @param region      A region that further constrains which blocks to take.
 */
public void copy(EditSession editSession, Region region) {
    for (int x = 0; x < size.getBlockX(); ++x) {
        for (int y = 0; y < size.getBlockY(); ++y) {
            for (int z = 0; z < size.getBlockZ(); ++z) {
                final Vector pt = new Vector(x, y, z).add(getOrigin());
                if (region.contains(pt)) {
                    setBlock(x, y, z, editSession.getBlock(pt));
                } else {
                    setBlock(x, y, z, null);
                }
            }
        }
    }
}
 
Example 8
Source File: WEManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean isIn(int x, int y, int z, Region region) {
    if (region.contains(x, y, z)) {
        return true;
    }
    return false;
}