use of org.bukkit.entity.LivingEntity in project EliteMobs by MagmaGuy.
the class MobScanner method scanMobs.
public void scanMobs(int passiveStackAmount) {
for (World world : worldList) {
Iterator<LivingEntity> iterator = world.getLivingEntities().iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
if (ValidAgressiveMobFilter.ValidAgressiveMobFilter(entity)) {
//scan for naturally/command/plugin spawned EliteMobs
if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() != 1 && ((Damageable) entity).getMaxHealth() == DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity)) {
HealthHandler.naturalAgressiveHealthHandler(entity, entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt());
customAggressiveName(entity);
PowerHandler.powerHandler(entity);
ArmorHandler.ArmorHandler(entity);
}
//scan for stacked EliteMobs
if (ConfigValues.defaultConfig.getBoolean("Allow aggressive EliteMobs") && ConfigValues.defaultConfig.getBoolean("Aggressive mob stacking") && !entity.hasMetadata(MetadataHandler.FORBIDDEN_MD)) {
if (!(entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() >= ConfigValues.defaultConfig.getInt("Aggressive mob stacking cap")) && !entity.hasMetadata(MetadataHandler.FORBIDDEN_MD)) {
scanValidAggressiveLivingEntity(entity);
}
if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
PowerHandler.powerHandler(entity);
ArmorHandler.ArmorHandler(entity);
}
}
}
//scan for passive mobs
if (ConfigValues.defaultConfig.getBoolean("Allow Passive EliteMobs")) {
//scan for passive mobs that might have lost their metadata
if (ValidPassiveMobFilter.ValidPassiveMobFilter(entity) && ((LivingEntity) entity).getMaxHealth() != DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity) && ((LivingEntity) entity).getMaxHealth() == DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity) * ConfigValues.defaultConfig.getInt("Passive EliteMob stack amount")) {
customPassiveName(entity, plugin);
}
//scan for new passive supermobs
if (ValidPassiveMobFilter.ValidPassiveMobFilter(entity) && !entity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
scanValidPassiveLivingEntity(entity);
}
//spawn chicken eggs, really wish there were an event for this
ChickenHandler.superEggs(entity, passiveStackAmount);
}
//scan for iron golems with missing metadata
if (!entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity instanceof IronGolem && ((IronGolem) entity).getMaxHealth() != DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity)) {
entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, ScalingFormula.reversePowerFormula(((IronGolem) entity).getMaxHealth(), DefaultMaxHealthGuesser.defaultMaxHealthGuesser(entity))));
customAggressiveName(entity);
}
}
}
}
use of org.bukkit.entity.LivingEntity in project EliteMobs by MagmaGuy.
the class MovementSpeed method applyPowers.
@Override
public void applyPowers(Entity entity) {
entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
MinorPowerPowerStance minorPowerPowerStance = new MinorPowerPowerStance();
minorPowerPowerStance.itemEffect(entity);
}
use of org.bukkit.entity.LivingEntity in project InfernalMobs by NyaaCat.
the class AbilityArcher method perCycleEffect.
@Override
public void perCycleEffect(LivingEntity mobEntity, Mob mob) {
if (Helper.possibility(0.8))
return;
List<Player> candidates = new ArrayList<>();
for (Entity e : mobEntity.getNearbyEntities(16, 16, 16)) {
if (!(e instanceof Player))
continue;
Player p = (Player) e;
if (p.getGameMode() == GameMode.CREATIVE)
return;
if (mobEntity.hasLineOfSight(p))
candidates.add(p);
}
Player victim = Helper.randomItem(candidates);
if (victim == null)
return;
Vector v = Helper.unitDirectionVector(mobEntity.getEyeLocation().toVector(), victim.getEyeLocation().toVector());
for (int i = 0; i < 1; i++) {
mobEntity.launchProjectile(Arrow.class, v);
}
// TODO homing
}
use of org.bukkit.entity.LivingEntity in project InfernalMobs by NyaaCat.
the class AbilityMounted method onMobSpawn.
@Override
public void onMobSpawn(InfernalMobSpawnEvent ev) {
if (!ConfigReader.isEnabledRider(ev.mobEntity.getType()) && ev.reason != InfernalSpawnReason.COMMAND)
return;
EntityType mounteeType = Helper.randomItem(ConfigReader.getMounteeTypes());
LivingEntity mounteeEntity = (LivingEntity) ev.mobEntity.getWorld().spawn(ev.mobEntity.getLocation(), mounteeType.getEntityClass());
InfernalMobs.instance.mobManager.unnaturallySpawned.put(mounteeEntity.getUniqueId(), true);
mounteeEntity.addPassenger(ev.mobEntity);
if (mounteeEntity instanceof Horse) {
((Horse) mounteeEntity).setColor(Helper.randomItem(Arrays.asList(Horse.Color.values())));
((Horse) mounteeEntity).setStyle(Helper.randomItem(Arrays.asList(Horse.Style.values())));
((Horse) mounteeEntity).setTamed(true);
if (ConfigReader.isHorseMounteeNeedSaddle()) {
((Horse) mounteeEntity).getInventory().setSaddle(new ItemStack(Material.SADDLE));
}
if (ev.mob.abilityList.contains(EnumAbilities.ARMOURED) && ConfigReader.isArmouredMounteeNeedArmour()) {
((Horse) mounteeEntity).getInventory().setArmor(new ItemStack(Material.DIAMOND_BARDING));
}
}
}
use of org.bukkit.entity.LivingEntity in project InfernalMobs by NyaaCat.
the class AbilityNecromancer method perCycleEffect.
@Override
public void perCycleEffect(LivingEntity mobEntity, Mob mob) {
if (Helper.possibility(0.9))
return;
Location mobLoc = mobEntity.getLocation();
List<Player> players = mobLoc.getWorld().getPlayers().stream().filter(p -> p.getLocation().distanceSquared(mobLoc) <= EFFECTIVE_RANGE_SQUARED).filter(p -> p.getGameMode() != GameMode.CREATIVE).collect(Collectors.toList());
Player victim = Helper.randomItem(players);
if (victim == null)
return;
WitherSkull w = mobEntity.launchProjectile(WitherSkull.class, Helper.unitDirectionVector(mobEntity.getEyeLocation().toVector(), victim.getEyeLocation().toVector()));
Helper.removeEntityLater(w, 30);
// TODO WitherSkull tracing player
}
Aggregations