本文整理汇总了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())));
}
}