Search in sources :

Example 11 with LivingEntity

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);
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Damageable(org.bukkit.entity.Damageable) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) IronGolem(org.bukkit.entity.IronGolem) World(org.bukkit.World)

Example 12 with LivingEntity

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);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MinorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)

Example 13 with LivingEntity

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
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) Vector(org.bukkit.util.Vector)

Example 14 with LivingEntity

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));
        }
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) Horse(org.bukkit.entity.Horse) ItemStack(org.bukkit.inventory.ItemStack)

Example 15 with LivingEntity

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
}
Also used : Helper(com.jacob_vejvoda.infernal_mobs.Helper) GameMode(org.bukkit.GameMode) List(java.util.List) Location(org.bukkit.Location) Mob(com.jacob_vejvoda.infernal_mobs.persist.Mob) Fireball(org.bukkit.entity.Fireball) Player(org.bukkit.entity.Player) LivingEntity(org.bukkit.entity.LivingEntity) WitherSkull(org.bukkit.entity.WitherSkull) Collectors(java.util.stream.Collectors) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) Player(org.bukkit.entity.Player) WitherSkull(org.bukkit.entity.WitherSkull) Location(org.bukkit.Location)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)324 Entity (org.bukkit.entity.Entity)170 Player (org.bukkit.entity.Player)123 Location (org.bukkit.Location)72 EventHandler (org.bukkit.event.EventHandler)64 Vector (org.bukkit.util.Vector)60 ItemStack (org.bukkit.inventory.ItemStack)47 ArrayList (java.util.ArrayList)41 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)37 PotionEffect (org.bukkit.potion.PotionEffect)34 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)30 Block (org.bukkit.block.Block)24 Mage (com.elmakers.mine.bukkit.api.magic.Mage)22 Projectile (org.bukkit.entity.Projectile)20 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)18 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)17 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)16 Target (com.elmakers.mine.bukkit.utility.Target)15 World (org.bukkit.World)14 Creature (org.bukkit.entity.Creature)14