Java 类org.bukkit.event.entity.EntityTargetEvent 实例源码

项目:ProjectAres    文件:DamageMatchModule.java   
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
项目:KingdomFactions    文件:EntityTargetListener.java   
@EventHandler
public void onTarget(EntityTargetEvent e) {
    if(!(e.getTarget() instanceof Player)) return;
        KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer((Player) e.getTarget());
        if(MonsterModule.getInstance().isGuard((LivingEntity) e.getEntity())) return;
        if(MonsterModule.getInstance().isGuard((LivingEntity)e.getTarget())) e.setCancelled(true);
        INexus guard = MonsterModule.getInstance().getGuard((LivingEntity) e.getEntity()).getNexus();
        switch(guard.getType()) {
        case CAPITAL:
            if(player.getKingdom().getType() == ((CapitalNexus) guard).getKingdom()) {
                e.setCancelled(true);
            }
            break;
        case FACTION:
            if(player.getFaction().equals(((Nexus)guard).getOwner())) {
                e.setCancelled(true);
            }
            break;

        }
    }
项目:NavyCraft2-Lite    文件:MoveCraft_EntityListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onEntityTarget(EntityTargetEvent event)
{
    if( event.getEntity() instanceof Skeleton && NavyCraft.aaSkelesList.contains((Skeleton)event.getEntity()) )
    {
        if( event.getTarget() instanceof Player )
        {
            Player target = (Player)event.getTarget();
            Craft skeleCraft = Craft.getCraft(target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
            if( skeleCraft != null && !skeleCraft.crewNames.isEmpty() && skeleCraft.crewNames.contains(target.getName()) )
            {
                event.setCancelled(true);
            }
        }
    }
}
项目:NavyCraft2-Lite    文件:NavyCraft_EntityListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onEntityTarget(EntityTargetEvent event)
{
    if( event.getEntity() instanceof Skeleton && NavyCraft.aaSkelesList.contains((Skeleton)event.getEntity()) )
    {
        if( event.getTarget() instanceof Player )
        {
            Player target = (Player)event.getTarget();
            Craft skeleCraft = Craft.getCraft(target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
            if( skeleCraft != null && !skeleCraft.crewNames.isEmpty() && skeleCraft.crewNames.contains(target.getName()) )
            {
                event.setCancelled(true);
            }
        }
    }
}
项目:mczone    文件:PetEvents.java   
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
    if (event.getReason() == TargetReason.TARGET_DIED)
        return;

    PetInstance pet = null;
    for (PetInstance p : PetInstance.getList()) {
        if (p.getEntity() == null)
            continue;
        if (p.getEntity().getUniqueId().equals(event.getEntity().getUniqueId())) {
            pet = p;
            break;
        }
    }

    if (pet != null)
        event.setCancelled(true);
}
项目:Skript    文件:ExprTarget.java   
@Override
protected Entity[] get(final Event e, final LivingEntity[] source) {
    return get(source, new Converter<LivingEntity, Entity>() {
        @Override
        @Nullable
        public Entity convert(final LivingEntity en) {
            if (getTime() >= 0 && e instanceof EntityTargetEvent && en.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
                final Entity t = ((EntityTargetEvent) e).getTarget();
                if (t == null || type != null && !type.isInstance(t))
                    return null;
                return t;
            }
            return Utils.getTarget(en, type);
        }
    });
}
项目:Skript    文件:ExprTarget.java   
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
    if (mode == ChangeMode.SET || mode == ChangeMode.DELETE) {
        final LivingEntity target = delta == null ? null : (LivingEntity) delta[0];
        for (final LivingEntity entity : getExpr().getArray(e)) {
            if (getTime() >= 0 && e instanceof EntityTargetEvent && entity.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
                ((EntityTargetEvent) e).setTarget(target);
            } else {
                if (entity instanceof Creature)
                    ((Creature) entity).setTarget(target);
            }
        }
    } else {
        super.change(e, delta, mode);
    }
}
项目:GriefPreventionFlags    文件:FlagDef_NoMonsterSpawns.java   
@EventHandler(ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event)
{
    Entity target = event.getTarget();
    if(target == null) return;

    Entity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    if(entity.hasMetadata(this.ALLOW_TARGET_TAG)) return;

    Flag flag = this.GetFlagInstanceAtLocation(target.getLocation(), null);
    if(flag == null) return;

    event.setCancelled(true);
    entity.remove();
}
项目:CraftBukkit    文件:EntityPigZombie.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else {
        Entity entity = damagesource.getEntity();

        if (entity instanceof EntityHuman) {
            List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D));

            for (int i = 0; i < list.size(); ++i) {
                Entity entity1 = (Entity) list.get(i);

                if (entity1 instanceof EntityPigZombie) {
                    EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;

                    entitypigzombie.c(entity, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
                }
            }

            this.c(entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
        }

        return super.damageEntity(damagesource, f);
    }
}
项目:CraftBukkit    文件:EntityPigZombie.java   
private void c(Entity entity, EntityTargetEvent.TargetReason reason) { // add TargetReason
    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), entity.getBukkitEntity(), reason);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
项目:vanillacraft    文件:God.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event)
{
    if (!event.isCancelled())
    {
        if (event.getTarget() instanceof Player)
        {
            Player player = (Player) event.getTarget();
            PlayerProfile profile = CoreData.getProfile(player);
            Long timeLeft = profile.getData("Godmode", Long.class);

            if (timeLeft != null && timeLeft > System.currentTimeMillis())
            {
                event.setCancelled(true);
            }
        }
    }
}
项目:defend-the-village    文件:Main.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onTarget(EntityTargetEvent ev) {
    if ((ev.getTarget() instanceof Player)) {
        Player pl = (Player)ev.getTarget();

        // Is the player in game?
        if (this.am.isInGame(pl)) {
            for (Arena a : this.am.arenas) {
                if ((a.deadPlayers.contains(pl.getName())) || (a.notStarted) || (a.waitingNextWave)) {
                    // If the player is dead, cancel the targetting
                    ev.setCancelled(true);
                }
            }
        }
    }
}
项目:civcraft    文件:CommonCustomMob.java   
public void onTarget(EntityTargetEvent event) {
    if (event.isCancelled()) {
        return;
    }

    if ((event.getReason().equals(TargetReason.CLOSEST_PLAYER) ||
            event.getReason().equals(TargetReason.OWNER_ATTACKED_TARGET)) &&
            (event.getTarget() instanceof Player)) {

        double followRange = this.getFollowRange();
        double distance = event.getEntity().getLocation().distance(event.getTarget().getLocation());
        if ((distance-0.5) <= followRange) {
            this.targetName = ((Player)event.getTarget()).getName();
            this.lastLocation = event.getEntity().getLocation();
        }
    } else {
        this.targetName = null;
        this.lastLocation = null;
    }
}
项目:civcraft    文件:MobListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event) {
    if (!(event.getEntity() instanceof LivingEntity)) {
        return;
    }

    if (!MobLib.isMobLibEntity((LivingEntity) event.getEntity())) {
        return;
    }

    CommonCustomMob mob = CommonCustomMob.getCCM(event.getEntity());
    if (mob != null) {
        mob.onTarget(event);
    }

}
项目:Almura-Server    文件:EntityPigZombie.java   
private void c(Entity entity) {
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();

    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
项目:Tweakkit-Server    文件:EntityPigZombie.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else {
        Entity entity = damagesource.getEntity();

        if (entity instanceof EntityHuman) {
            List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D));

            for (int i = 0; i < list.size(); ++i) {
                Entity entity1 = (Entity) list.get(i);

                if (entity1 instanceof EntityPigZombie) {
                    EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;

                    entitypigzombie.c(entity, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
                }
            }

            this.c(entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
        }

        return super.damageEntity(damagesource, f);
    }
}
项目:Tweakkit-Server    文件:EntityPigZombie.java   
private void c(Entity entity, EntityTargetEvent.TargetReason reason) { // add TargetReason
    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), entity.getBukkitEntity(), reason);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
项目:Cauldron    文件:EntityPigZombie.java   
private void becomeAngryAt(Entity p_70835_1_)
{
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = p_70835_1_ == null ? null : p_70835_1_.getBukkitEntity();
    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.worldObj.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled())
    {
        return;
    }

    if (event.getTarget() == null)
    {
        this.entityToAttack = null;
        return;
    }

    p_70835_1_ = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end
    this.entityToAttack = p_70835_1_;
    this.angerLevel = 400 + this.rand.nextInt(400);
    this.randomSoundDelay = this.rand.nextInt(40);
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * Handle EntityTarget events.
 *
 * @param event The event to process
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) {
    Entity entity = event.getEntity();
    Entity target = event.getTarget();

    if (!(entity instanceof Tameable) || !(target instanceof Player)) {
        return;
    }

    Player player = (Player) target;
    Tameable tameable = (Tameable) entity;

    if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
        return;
    }

    // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
    // So we can make some assumptions here, about our casting and our check
    if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
        event.setCancelled(true);
    }
}
项目:SpigotSource    文件:EntityEnderman.java   
@Override
public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
    if (!super.setGoalTarget(entityliving, reason, fireEvent)) {
        return false;
    }
    entityliving = getGoalTarget();
    // CraftBukkit end
    AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);

    if (entityliving == null) {
        this.bz = 0;
        this.datawatcher.set(EntityEnderman.bx, Boolean.valueOf(false));
        attributeinstance.c(EntityEnderman.b);
    } else {
        this.bz = this.ticksLived;
        this.datawatcher.set(EntityEnderman.bx, Boolean.valueOf(true));
        if (!attributeinstance.a(EntityEnderman.b)) {
            attributeinstance.b(EntityEnderman.b);
        }
    }
    return true;

}
项目:simple-survival-games    文件:SSGEntityListener.java   
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
    Entity e = event.getEntity();
    Entity target = event.getTarget();
    ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

    // The entity or the target may not be null
    if(e == null || target == null)
        return;

    // If the target is a player, he may not be targeted if he's in the lobby or when he's a spectator
    if(target instanceof Player) {
        Player p = (Player) target;

        // Is the target player currently in any arena
        if(am.isInArena(p)) {
            ArenaPlayer ap = am.getPlayer(p);

            // The player may not be targeted
            if(ap.isInLobby() || ap.isSpectator())
                event.setCancelled(true);
        }
    }
}
项目:Craft-city    文件:EntityPigZombie.java   
private void p(Entity entity) {
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();

    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
项目:EntityAPI    文件:BehaviourGoalMeleeAttack.java   
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
项目:EntityAPI    文件:BehaviourGoalMeleeAttack.java   
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
项目:EntityAPI    文件:BehaviourGoalMeleeAttack.java   
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
项目:EntityAPI    文件:BehaviourGoalMeleeAttack.java   
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
项目:SkyWarsReloaded    文件:SpectatorListener.java   
@EventHandler
protected void onEntityTarget(EntityTargetEvent e) {
    // On entity target - Stop mobs targeting spectators
    // Check to make sure it isn't an NPC (Citizens NPC's will be detectable using 'entity.hasMetadata("NPC")')
    if (e.getTarget() != null && e.getTarget() instanceof Player && !e.getTarget().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
        e.setCancelled(true);
    }
    if (e.getTarget() instanceof Player && e.getTarget() != null && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
        if (e.getEntity() instanceof ExperienceOrb) {
            repellExpOrb((Player) e.getTarget(), (ExperienceOrb) e.getEntity());
            e.setCancelled(true);
            e.setTarget(null);
        }
    }
}
项目:mczone    文件:Events.java   
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
    if (Scheduler.getState() != State.PVP)
        event.setCancelled(true);
    if (event.getTarget() instanceof Player) {
        Gamer g = Gamer.get(((Player) event.getTarget()).getName());
        if (g == null) {
            ((Player) event.getTarget()).kickPlayer("ERROR");
            return;
        }
        if (g.isInvisible())
            event.setCancelled(true);
    }
}
项目:StaffPlus    文件:EntityTarget.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTarget(EntityTargetEvent event)
{
    if(event.getTarget() instanceof Player)
    {
        Player player = (Player) event.getTarget();

        if(userManager.get(player.getUniqueId()).getVanishType() != VanishType.TOTAL)
        {
            return;
        }

        event.setCancelled(true);
    }
}
项目:Skellett    文件:ExprTargetReason.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (ScriptLoader.isCurrentEvent(EntityTargetEvent.class) || ScriptLoader.isCurrentEvent(EntityTargetNPCEvent.class)) {
        return true;
    } else {
        Skript.error("You can not use TargetReason expression in any event but on on target!");
        return false;
    }
}
项目:UberHardcore    文件:CustomZombie.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if(super.damageEntity(damagesource, f)) {
        EntityLiving entityliving = this.getGoalTarget();
        if(entityliving == null && damagesource.getEntity() instanceof EntityLiving) {
            entityliving = (EntityLiving)damagesource.getEntity();
        }

        if(entityliving != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double)this.random.nextFloat() < this.getAttributeInstance(b).getValue()) {
            int i = MathHelper.floor(this.locX);
            int j = MathHelper.floor(this.locY);
            int k = MathHelper.floor(this.locZ);
            EntityZombie entityzombie = new CustomZombie(this.world);

            for(int l = 0; l < 50; ++l) {
                int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                if(World.a(this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
                    entityzombie.setPosition((double)i1, (double)j1, (double)k1);
                    if(!this.world.isPlayerNearby((double)i1, (double)j1, (double)k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
                        this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
                        entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
                        entityzombie.prepare(this.world.E(new BlockPosition(entityzombie)), (GroupDataEntity)null);
                        this.getAttributeInstance(b).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
                        entityzombie.getAttributeInstance(b).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
                        break;
                    }
                }
            }
        }

        return true;
    } else {
        return false;
    }
}
项目:UberHardcore    文件:CustomZombie.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if(super.damageEntity(damagesource, f)) {
        EntityLiving entityliving = this.getGoalTarget();
        if(entityliving == null && damagesource.getEntity() instanceof EntityLiving) {
            entityliving = (EntityLiving)damagesource.getEntity();
        }

        if(entityliving != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double)this.random.nextFloat() < this.getAttributeInstance(a).getValue()) {
            int i = MathHelper.floor(this.locX);
            int j = MathHelper.floor(this.locY);
            int k = MathHelper.floor(this.locZ);
            EntityZombie entityzombie = new CustomZombie(this.world);

            for(int l = 0; l < 50; ++l) {
                int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                if(World.a(this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
                    entityzombie.setPosition((double)i1, (double)j1, (double)k1);
                    if(!this.world.isPlayerNearby((double)i1, (double)j1, (double)k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
                        this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
                        entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
                        entityzombie.prepare(this.world.E(new BlockPosition(entityzombie)), (GroupDataEntity)null);
                        this.getAttributeInstance(a).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
                        entityzombie.getAttributeInstance(a).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
                        break;
                    }
                }
            }
        }

        return true;
    } else {
        return false;
    }
}
项目:UberHardcore    文件:CustomZombie.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if(super.damageEntity(damagesource, f)) {
        EntityLiving entityliving = this.getGoalTarget();
        if(entityliving == null && damagesource.getEntity() instanceof EntityLiving) {
            entityliving = (EntityLiving)damagesource.getEntity();
        }

        if(entityliving != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double)this.random.nextFloat() < this.getAttributeInstance(a).getValue()) {
            int i = MathHelper.floor(this.locX);
            int j = MathHelper.floor(this.locY);
            int k = MathHelper.floor(this.locZ);
            EntityZombie entityzombie = new CustomZombie(this.world);

            for(int l = 0; l < 50; ++l) {
                int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
                if(World.a(this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
                    entityzombie.setPosition((double)i1, (double)j1, (double)k1);
                    if(!this.world.isPlayerNearby((double)i1, (double)j1, (double)k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
                        this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
                        entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
                        entityzombie.prepare(this.world.E(new BlockPosition(entityzombie)), (GroupDataEntity)null);
                        this.getAttributeInstance(a).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
                        entityzombie.getAttributeInstance(a).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
                        break;
                    }
                }
            }
        }

        return true;
    } else {
        return false;
    }
}
项目:SuperVanish    文件:GeneralEventHandler.java   
@EventHandler(priority = EventPriority.HIGH)
public void onTarget(EntityTargetEvent e) {
    try {
        if (!(e.getTarget() instanceof Player)) return;
        if (!config.getBoolean("InvisibilityFeatures.DisableMobTarget")) return;
        Player p = (Player) e.getTarget();
        if (plugin.getVanishStateMgr().isVanished(p.getUniqueId())) {
            e.setCancelled(true);
        }
    } catch (Exception er) {
        plugin.logException(er);
    }
}
项目:BedwarsRel    文件:TNTSheep.java   
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.b).setValue(128D);
    this.getAttributeInstance(GenericAttributes.d)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
项目:BedwarsRel    文件:TNTSheep.java   
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(128D);
    this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
项目:BedwarsRel    文件:TNTSheep.java   
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.b).setValue(128D);
    this.getAttributeInstance(GenericAttributes.d)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
项目:MyiuLib    文件:MGListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityTarget(EntityTargetEvent e) {
    if (e.getTarget() != null && e.getTarget().getType() == EntityType.PLAYER) {
        for (Minigame mg : Minigame.getMinigameInstances()) {
            MGPlayer mp = mg.getMGPlayer(((Player)e.getTarget()).getName());
            if (mp != null && (!mg.getConfigManager().isEntityTargetingEnabled() || mp.isSpectating())) {
                e.setCancelled(true);
            }
        }
    }
}
项目:CraftBukkit    文件:PathfinderGoalMeleeAttack.java   
public boolean b() {
    EntityLiving entityliving = this.b.getGoalTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.b.getGoalTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.b.getGoalTarget() == null || (this.b.getGoalTarget() != null && !this.b.getGoalTarget().isAlive())) {
        org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(b, null, reason);
    }
    // CraftBukkit end

    return entityliving == null ? false : (!entityliving.isAlive() ? false : (!this.e ? !this.b.getNavigation().g() : this.b.b(MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))));
}
项目:CraftBukkit    文件:PathfinderGoalOcelotAttack.java   
public void d() {
    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.c.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this.c, null, reason);
    // CraftBukkit end
    this.c = null;
    this.b.getNavigation().h();
}