本文整理匯總了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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
}
}
示例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());
}
}
}
示例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);
}
}
}
示例8: setRandomPlayerAsTarget
import org.bukkit.entity.Monster; //導入方法依賴的package包/類
private void setRandomPlayerAsTarget(Monster m) {
if (_possibleTarget != null) {
m.setTarget(_possibleTarget.get(RandomUtil.getRandomInt(_possibleTarget.size())));
}
}