當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。