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


Java Monster.setTarget方法代码示例

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


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

示例1: timeHasCome

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
@Override
public void timeHasCome(long time) {
	if (_monsterSpawned.size() < _maxMonster) {
		Location random = _spawningZone.getRandomLocation(_spawningLocation.getWorld());
		EntityType creature = EntityUtilities.getEntityType(_monsters[RandomUtil.getRandomInt(_monsters.length)]);
		Monster m = (Monster)ScenarioService.getInstance().spawnCreature(_spawningLocation.getWorld(), random, creature, _healthModifier, _burn);
		m.setTarget(_players.get(RandomUtil.getRandomInt(_players.size())));
		
		ScenarioPlugin.logger.fine("Spawner at: " + _spawningLocation.getX() + "," + _spawningLocation.getZ() + " high: " + _spawningLocation.getY() + " - " + creature.toString() + " -> " + m.getTarget().getEntityId());
		
		_monsterSpawned.add(m);
		TimeServer.getInstance().addListener(this, _delayBetweenMonster);
	}
	
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:17,代码来源:FixedSpawner.java

示例2: spawnWave

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
@Override
public void spawnWave() {
	if (_scenario.isActive() && _locations != null && _locations.size() > 0 && 
		_arrayPossibleMonster.length > 0 && getNbOfEntities() < _maxMonster) {
		
		for (Location l : _locations) {
			
			if (getNbOfEntities() < _maxMonster) {
				EntityType c = EntityUtilities.getEntityType(_arrayPossibleMonster[RandomUtil.getRandomInt(_arrayPossibleMonster.length)]);
				Entity e = ScenarioService.getInstance().spawnCreature(l.getWorld(), l, c, _healthModifier, false);
				_monsters.add(e);
				if (e instanceof Monster) {
					Monster m = (Monster)e;
					m.setTarget(_scenario.pickRandomPlayer());
				}
			}
		}
		
		if (_timeBetweenSpawn > 50) {
			TimeServer.getInstance().addListener(this, _timeBetweenSpawn);
		}
		
	}
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:26,代码来源:RegularSpawnWave.java

示例3: spawnWave

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
public void spawnWave() {
	if (_scenario.isActive()) {
		for (int i = 0; i < _nbMonsters; i++) {
			// creation de la location et du monstre
			Location loc = _scenario.getWorldZone().getRandomLocationOutsideThisZone(_scenario.getWorld(), _exclude);
			EntityType type = EntityUtilities.getEntityType(possibleMonsters[RandomUtil.getRandomInt(possibleMonsters.length)]);			
			Entity living = _scenario.getWorld().spawnEntity(loc, type);
			
			if (living instanceof Monster) {
				Monster m = (Monster)living;
				m.setTarget(_scenario.pickRandomPlayer());
			}
			
			// adding to the table
			_monstersTable.add(living);
		}
	}
	
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:21,代码来源:BasicMonsterWave.java

示例4: onCast

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
@Override
public CastResult onCast(User user, int power, String[] args) {
	int radius = this.radius * power;
	List<Entity> entityList = user.getPlayer().getNearbyEntities(radius, radius, radius);
	List<Monster> monsterList = new ArrayList<Monster>();
	for (Entity entity : entityList) {
		if (entity instanceof Monster) {
			monsterList.add((Monster) entity);
		}
	}
	for (int i = 0; i < monsterList.size(); i++) {
		int targetIndex = i + 1;
		if (targetIndex >= monsterList.size()) {
			targetIndex = 0;
		}
		Monster monster = monsterList.get(i);
		Monster target = monsterList.get(targetIndex);
		monster.setTarget(target);
		Object monsterHandle = NMSUtils.getHandle(monster);
		Object targetHandle = NMSUtils.getHandle(target);
		ReflectionUtils.invokeMethod(monsterHandle, "setGoalTarget", targetHandle);
		ParticleEffects.sendParticle(Particle.ANGRY_VILLAGER, monster.getTarget().getLocation().add(0, 1, 0),
				0.25F, 0.25F, 0.25F, 5, 5);
	}
	return CastResult.SUCCESS;
}
 
开发者ID:mcardy,项目名称:Zephyrus-II,代码行数:27,代码来源:ConfuseSpell.java

示例5: onEntityDamage

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
void onEntityDamage(EntityDamageEvent event) {
	Entity entity = event.getEntity();
	// block damaging of shopkeepers
	if (plugin.isShopkeeper(entity)) {
		event.setCancelled(true);
		if (event instanceof EntityDamageByEntityEvent) {
			EntityDamageByEntityEvent evt = (EntityDamageByEntityEvent) event;
			if (evt.getDamager() instanceof Monster) {
				Monster monster = (Monster) evt.getDamager();
				// reset target, future targeting should get prevented somewhere else:
				if (entity.equals(monster.getTarget())) {
					monster.setTarget(null);
				}
			}
		}
	}
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:19,代码来源:LivingEntityShopListener.java

示例6: onBlockDamage

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
public void onBlockDamage(BlockDamageEvent event) {
	if (event.getBlock().getLocation().equals(_locations)) {
		for (Monster m : _spawnedMonsters) {
			m.setTarget(event.getPlayer());
		}
	}
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:9,代码来源:BreakBlockSession.java

示例7: run

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
@Override
public void run() {
	
	_player.sendMessage(ChatColor.YELLOW + "The monster are getting closer...");
	
	WorldZone exclusion = new WorldZone(_player.getLocation(), 7.0);
	WorldZone area = new WorldZone(_player.getLocation(), _radius);
	
	for (int i = 0; i < _numberMonster; i++) {
		int maxTry = 0;
		Location newLoc = area.getRandomLocationOutsideThisZone(_player.getLocation().getWorld(), exclusion);
		
		while (maxTry < 3 && !validLocationForMonster(newLoc)) {
			newLoc = area.getRandomLocationOutsideThisZone(_player.getLocation().getWorld(), exclusion);
			maxTry++;
		}
		
		if (maxTry < 3) {
			EntityType creature = EntityUtilities.getEntityType(_monstersArray[RandomUtil.getRandomInt(_monstersArray.length)]);
			double health = Frontier.getInstance().calculateGlobalModifier(newLoc);
			LivingEntity living = (LivingEntity)ScenarioService.getInstance().spawnCreature(_world, newLoc, creature, health, false);
						
			// set le monster avec le target et les potions
			List<PotionEffect> effects = this.getRandomPotions(health);
			Monster m = (Monster)living;
			m.addPotionEffects(effects);
			m.setTarget(_player);
		}	
	}
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:32,代码来源:MercenaryAmbush.java

示例8: setRandomPlayerAsTarget

import org.bukkit.entity.Monster; //导入方法依赖的package包/类
private void setRandomPlayerAsTarget(Monster m) {
	if (_possibleTarget != null) {
		m.setTarget(_possibleTarget.get(RandomUtil.getRandomInt(_possibleTarget.size())));
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:6,代码来源:InfiniteSpawner.java


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