当前位置: 首页>>代码示例>>Java>>正文


Java BlockIterator.next方法代码示例

本文整理汇总了Java中org.bukkit.util.BlockIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java BlockIterator.next方法的具体用法?Java BlockIterator.next怎么用?Java BlockIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.util.BlockIterator的用法示例。


在下文中一共展示了BlockIterator.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTarget

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
public static <T extends Entity> T getTarget(Player player, int range, Collection<T> entities) {
	BlockIterator iterator = new BlockIterator(player, range);
	while (iterator.hasNext()) {
		Block block = iterator.next();
		for (T entity : entities) {
			int accuracy = 2;
			for (int offX = -accuracy; offX < accuracy; offX++) {
				for (int offY = -accuracy; offY < accuracy; offY++) {
					for (int offZ = -accuracy; offZ < accuracy; offZ++) {
						if (entity.getLocation().getBlock().getRelative(offX, offY, offZ).equals(block)) {
							return entity;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:20,代码来源:BukkitTargetUtils.java

示例2: getTarget

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
private static Entity getTarget(final Player player) {
	try {
		BlockIterator iterator = new BlockIterator(player.getWorld(), player
                .getLocation().toVector(), player.getEyeLocation()
                .getDirection(), 0, 10);
        while (iterator.hasNext()) {
            Block item = iterator.next();
            for (Entity entity : player.getNearbyEntities(10, 10, 10)) {
            	int acc = 2;
            	for (int y = -acc; y < acc; y++){
            		if (entity.getLocation().getBlock()
                            .getRelative(0, y, 0).equals(item)) {
                        return entity;
                    }
            	}
            }
        }
	} catch(IllegalStateException ignored){}
    return null;
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:21,代码来源:RPPlayerListener.java

示例3: getTargetBlock

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
public static Block getTargetBlock(@Nullable Set<Material> transparent, 
                                   @Nonnull Location location, int maxDistance) {
  Preconditions.checkNotNull(location, "location cannot be null.");
  if (maxDistance > 120) {
    maxDistance = 120;
  }
  
  Block result = null;
  BlockIterator itr = new BlockIterator(location, 0, maxDistance);
  while (itr.hasNext()) {
    result = itr.next();
    Material material = result.getType();
    if (transparent == null) {
      if (!material.equals(Material.AIR)) {
        break;
      }
    } else if (!transparent.contains(material)) {
      break;
    }
  }
  return result;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:23,代码来源:TargetingUtils.java

示例4: getTargetEntity

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
private LivingEntity getTargetEntity(int range) {
	BlockIterator iterator = new BlockIterator(player, range);
	while (iterator.hasNext()) {
		Block block = iterator.next();
		for (Entity entity : player.getNearbyEntities(range, range, range)) {
			if (entity instanceof LivingEntity) {
				int accuracy = 2;
				for (int offX = -accuracy; offX < accuracy; offX++) {
					for (int offY = -accuracy; offY < accuracy; offY++) {
						for (int offZ = -accuracy; offZ < accuracy; offZ++) {
							if (entity.getLocation().getBlock().getRelative(offX, offY, offZ).equals(block)) {
								return (LivingEntity) entity;
							}
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:mcardy,项目名称:Zephyrus-II,代码行数:22,代码来源:OnlineUser.java

示例5: getTargetBlock

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
private Block getTargetBlock(Player player) {
    BlockIterator iterator = new BlockIterator(player.getEyeLocation(), 0D, 10);
    Block block = null;
    while (iterator.hasNext()) {
        Block b = iterator.next();
        if (b != null && b.getType() != Material.AIR) {
            block = b;
            break;
        }
    }

    if (block == null) {
        plugin.getMessageManager().getMessage("errors.must_look_at_sign").sendTo(player);
        return null;
    }

    if (!(block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
        plugin.getMessageManager().getMessage("errors.block_not_sign").sendTo(player);
        return null;
    }
    return block;
}
 
开发者ID:Gamegine,项目名称:Gamegine,代码行数:23,代码来源:CmdSign.java

示例6: getTargetBlock

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
/**
 * Iterates over blocks in the direction the player is looking until the
 * max distance is reached or a block that isn't {@link org.bukkit.Material#AIR}
 * is found.
 *
 * @param player       The {@link Player}.
 * @param maxDistance  The max distance to search.
 *
 * @return  The {@link Block} that was found or null if the max distance was reached.
 */
@Nullable
public static Block getTargetBlock(Player player, int maxDistance) {
    PreCon.notNull(player);
    PreCon.positiveNumber(maxDistance);

    BlockIterator bit = new BlockIterator(player, maxDistance);
    Block next;
    while(bit.hasNext())
    {
        next = bit.next();

        if (next != null && next.getType() != Material.AIR)
            return next;
    }

    return null;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:28,代码来源:PlayerUtils.java

示例7: getTarget

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
private Entity getTarget(Player player) {
	BlockIterator iterator = new BlockIterator(player.getWorld(), player
			.getLocation().toVector(), player.getEyeLocation()
			.getDirection(), 0, 100);
	Entity target = null;
	while (iterator.hasNext()) {
		Block item = iterator.next();
		for (Entity entity : player.getNearbyEntities(100, 100, 100)) {
			int acc = 2;
			for (int x = -acc; x < acc; x++)
				for (int z = -acc; z < acc; z++)
					for (int y = -acc; y < acc; y++)
						if (entity.getLocation().getBlock()
								.getRelative(x, y, z).equals(item)) 
							return target = entity;
		}
	}
	return target;
}
 
开发者ID:EvilKanoa,项目名称:RodsTwo,代码行数:20,代码来源:Pickpocket.java

示例8: getTarget

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
private Entity getTarget(Player player) {

		BlockIterator iterator = new BlockIterator(player.getWorld(), player
				.getLocation().toVector(), player.getEyeLocation()
				.getDirection(), 0, 100);
		Entity target = null;
		while (iterator.hasNext()) {
			Block item = iterator.next();
			for (Entity entity : player.getNearbyEntities(100, 100, 100)) {
				int acc = 2;
				for (int x = -acc; x < acc; x++)
					for (int z = -acc; z < acc; z++)
						for (int y = -acc; y < acc; y++)
							if (entity.getLocation().getBlock()
									.getRelative(x, y, z).equals(item)) 
								return target = entity;
			}
		}
		return target;
	}
 
开发者ID:EvilKanoa,项目名称:RodsTwo,代码行数:21,代码来源:Curse.java

示例9: getTarget

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
/**
 * Gets the player's target entity
 * 
 * @param player
 *            The player to get the target of
 * @return Null if there is no target
 */
public Entity getTarget(Player player) {
	BlockIterator iterator = new BlockIterator(player.getWorld(), player.getLocation().toVector(), player
			.getEyeLocation().getDirection(), 0, 100);
	while (iterator.hasNext()) {
		Block item = iterator.next();
		for (Entity entity : player.getNearbyEntities(10, 10, 10)) {
			int acc = 2;
			for (int x = -acc; x < acc; x++) {
				for (int z = -acc; z < acc; z++) {
					for (int y = -acc; y < acc; y++) {
						if (entity.getLocation().getBlock().getRelative(x, y, z).equals(item)) {
							return entity;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:mcardy,项目名称:Zephyrus,代码行数:28,代码来源:Spell.java

示例10: onProjectileHitEvent

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent event) {
    final Projectile projectile = event.getEntity();
    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(projectile);
    if(projectileDefinition == null) return;

    final Filter filter = projectileDefinition.destroyFilter();
    if(filter == null) return;

    final BlockIterator blockIterator = new BlockIterator(projectile.getWorld(), projectile.getLocation().toVector(), projectile.getVelocity().normalize(), 0d, 2);
    Block hitBlock = null;
    while(blockIterator.hasNext()) {
        hitBlock = blockIterator.next();
        if(hitBlock.getType() != Material.AIR) break;
    }

    if(hitBlock != null) {
        final MatchPlayer shooter = projectile.getShooter() instanceof Player ? getMatch().getPlayer((Player) projectile.getShooter()) : null;
        final IQuery query = shooter != null ? new PlayerBlockEventQuery(shooter, event, hitBlock.getState())
                                             : new BlockEventQuery(event, hitBlock);

        if(filter.query(query).isAllowed()) {
            final BlockTransformEvent bte = new BlockTransformEvent(event, hitBlock, Material.AIR);
            match.callEvent(bte);

            if(!bte.isCancelled()) {
                hitBlock.setType(Material.AIR);
                projectile.remove();
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:33,代码来源:ProjectileMatchModule.java

示例11: getTargetLiving

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
@Override
public LivingEntity getTargetLiving() {
	if (livingEntityTarget != null)
		return livingEntityTarget;
	int range = 100;
	Player player = getPlayer();
	BlockIterator iterator = new BlockIterator(player, range);
	List<Entity> entities = player.getNearbyEntities(range, range, range);
	while (iterator.hasNext()) {
		Block block = iterator.next();
		for (Entity entity : entities) {
			if (entity instanceof LivingEntity) {
				int accuracy = 2;
				for (int offX = -accuracy; offX < accuracy; offX++) {
					for (int offY = -accuracy; offY < accuracy; offY++) {
						for (int offZ = -accuracy; offZ < accuracy; offZ++) {
							if (entity.getLocation().getBlock().getRelative(offX, offY, offZ).equals(block)) {
								return livingEntityTarget = (LivingEntity) entity;
							}
						}
					}
				}
			}
		}
	}
	return livingEntityTarget = null;
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:28,代码来源:PlayerCaster.java

示例12: getTargetPlayer

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
public Player getTargetPlayer(int range) {
	ConfigManager.load("blacklist.yml", "");
	List<String> blacklist = ConfigManager.get("blacklist.yml").getStringList("list");
	List<Material> materials = new ArrayList<Material>();
	for(String s : blacklist){
		materials.add(Material.valueOf(s));
	}
	BlockIterator bItr = new BlockIterator(player, range);
	Block block;
	Location loc;
	int bx, by, bz;
	double ex, ey, ez;
	// loop through player's line of sight
	while (bItr.hasNext()) {
		block = bItr.next();
		if(materials.contains(block.getType()))
			bItr.next();
		bx = block.getX();
		by = block.getY();
		bz = block.getZ();
		// check for entities near this block in the line of sight
		for (Entity e : player.getNearbyEntities(range, range, range)) {
			loc = e.getLocation();
			ex = loc.getX();
			ey = loc.getY();
			ez = loc.getZ();
			if ((bx - .75 <= ex && ex <= bx + 1.75) && (bz - .75 <= ez && ez <= bz + 1.75)
					&& (by - 1 <= ey && ey <= by + 2.5)) {
				// entity is close enough, set target and stop
				if(e instanceof Player){
					return (Player)e;
				}
			}
		}
	}
	return null;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:38,代码来源:Character.java

示例13: getTargetEntity

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
public Entity getTargetEntity(int range) {
	ConfigManager.load("blacklist.yml", "");
	List<String> blacklist = ConfigManager.get("blacklist.yml").getStringList("list");
	List<Material> materials = new ArrayList<Material>();
	for(String s : blacklist){
		materials.add(Material.valueOf(s));
	}
	BlockIterator bItr = new BlockIterator(player, range);
	Block block;
	Location loc;
	int bx, by, bz;
	double ex, ey, ez;
	// loop through player's line of sight
	while (bItr.hasNext()) {
		block = bItr.next();
		if(materials.contains(block.getType()))
			bItr.next();
		bx = block.getX();
		by = block.getY();
		bz = block.getZ();
		// check for entities near this block in the line of sight
		for (Entity e : player.getNearbyEntities(range, range, range)) {
			loc = e.getLocation();
			ex = loc.getX();
			ey = loc.getY();
			ez = loc.getZ();
			if ((bx - .75 <= ex && ex <= bx + 1.75) && (bz - .75 <= ez && ez <= bz + 1.75)
					&& (by - 1 <= ey && ey <= by + 2.5)) {
				// entity is close enough, set target and stop
				return e;
			}
		}
	}
	return null;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:36,代码来源:Character.java

示例14: sell

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
@SubCommand(value = "sell", permission = "heh.signshop.sell")
public void sell(CommandSender sender, CommandHandler.Arguments args) {
    if (args.length() != 3) {
        msg(sender, "manual.shop.sell.usage");
        return;
    }
    Player player = asPlayer(sender);
    BlockIterator blockIterator = new BlockIterator(player, 5);
    while (blockIterator.hasNext()) {
        Block block = blockIterator.next();
        if (SignShopManager.isSign(block)) {
            Sign sign = plugin.signShopManager.getSign(block);
            if (sign != null && player.getUniqueId().equals(sign.getOwner())) {
                if (plugin.signShopManager.getItemCount(player) >= plugin.signShopManager.getSlotLimit(player)) {
                    player.sendMessage(I18n.format("user.signshop.not_enough_slot"));
                    return;
                }
                ItemStack itemStack = getItemInHand(sender).clone();
                double unitPrice = args.nextDouble("#.##");
                if (!(unitPrice >= 0.01)) {
                    msg(sender, "user.error.not_double");
                    return;
                }
                if(MarketManager.containsBook(itemStack)){
                    msg(sender,"user.error.shulker_box_contains_book");
                    return;
                }
                if (itemStack.getAmount() > 0) {
                    plugin.signShopManager.addItemToShop(player.getUniqueId(), itemStack.clone(),
                            itemStack.getAmount(), unitPrice, ShopMode.SELL);
                    player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
                    player.sendMessage(I18n.format("user.signshop.buy.add"));
                    plugin.signShopManager.updateGUI(player.getUniqueId(), ShopMode.SELL);
                }
                return;
            }
        }
    }
    player.sendMessage(I18n.format("user.signshop.not_sign"));
}
 
开发者ID:NyaaCat,项目名称:HamsterEcoHelper,代码行数:41,代码来源:SignShopCommands.java

示例15: getTargetBlock

import org.bukkit.util.BlockIterator; //导入方法依赖的package包/类
public static Block getTargetBlock(Player player, int maxDistance, Set<Material> transparentMaterials) {
	final BlockIterator iterator = new BlockIterator(player.getLocation(), player.getEyeHeight(), maxDistance);
	Block result = player.getLocation().getBlock().getRelative(BlockFace.UP);
	while (iterator.hasNext()) {
		result = iterator.next();
		if (result.getType() != Material.AIR && !transparentMaterials.contains(result.getType())) {
			return result;
		}
	}

	return result;
}
 
开发者ID:KaiKikuchi,项目名称:BetterKits,代码行数:13,代码来源:Utils.java


注:本文中的org.bukkit.util.BlockIterator.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。