Search in sources :

Example 21 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project Wizardry by TeamWizardry.

the class EntityAINearestAttackableTargetFiltered method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
@SuppressWarnings("unchecked")
public boolean shouldExecute() {
    if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) {
        return false;
    } else if (this.targetClass != EntityPlayer.class && this.targetClass != EntityPlayerMP.class) {
        List<T> list = this.taskOwner.world.getEntitiesWithinAABB(this.targetClass, this.getTargetableArea(this.getTargetDistance()), this.targetEntitySelector);
        if (list.isEmpty()) {
            return false;
        } else {
            list.sort(this.sorter);
            this.targetEntity = list.get(0);
            return true;
        }
    } else {
        this.targetEntity = (T) this.taskOwner.world.getNearestAttackablePlayer(this.taskOwner.posX, this.taskOwner.posY + (double) this.taskOwner.getEyeHeight(), this.taskOwner.posZ, this.getTargetDistance(), this.getTargetDistance(), new Function<EntityPlayer, Double>() {

            @Nullable
            public Double apply(@Nullable EntityPlayer p_apply_1_) {
                ItemStack itemstack = p_apply_1_.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
                if (itemstack.getItem() == Items.SKULL) {
                    int i = itemstack.getItemDamage();
                    boolean flag = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntitySkeleton && i == 0;
                    boolean flag1 = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntityZombie && i == 2;
                    boolean flag2 = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntityCreeper && i == 4;
                    if (flag || flag1 || flag2) {
                        return Double.valueOf(0.5D);
                    }
                }
                return Double.valueOf(1.0D);
            }
        }, (Predicate<EntityPlayer>) this.targetEntitySelector);
        return this.targetEntity != null;
    }
}
Also used : Function(com.google.common.base.Function) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable) Predicate(com.google.common.base.Predicate)

Example 22 with EntityZombie

use of net.minecraft.entity.monster.EntityZombie in project BloodMagic by WayofTime.

the class ImperfectRitualZombie method onActivate.

@Override
public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) {
    EntityZombie zombie = new EntityZombie(imperfectRitualStone.getRitualWorld());
    zombie.setPosition(imperfectRitualStone.getRitualPos().getX() + 0.5, imperfectRitualStone.getRitualPos().getY() + 2.1, imperfectRitualStone.getRitualPos().getZ() + 0.5);
    zombie.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 2000));
    zombie.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 20000, 7));
    zombie.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 20000, 3));
    if (!imperfectRitualStone.getRitualWorld().isRemote)
        imperfectRitualStone.getRitualWorld().spawnEntity(zombie);
    return true;
}
Also used : EntityZombie(net.minecraft.entity.monster.EntityZombie) PotionEffect(net.minecraft.potion.PotionEffect)

Aggregations

EntityZombie (net.minecraft.entity.monster.EntityZombie)22 EntityLivingBase (net.minecraft.entity.EntityLivingBase)7 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)7 BlockPos (net.minecraft.util.math.BlockPos)6 EntityVillager (net.minecraft.entity.passive.EntityVillager)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 Zombie (org.spongepowered.api.entity.living.monster.Zombie)4 EntityLiving (net.minecraft.entity.EntityLiving)3 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)3 EntityPig (net.minecraft.entity.passive.EntityPig)3 Entity (org.spongepowered.api.entity.Entity)3 Player (org.spongepowered.api.entity.living.player.Player)3 Vector3d (com.flowpowered.math.vector.Vector3d)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Entity (net.minecraft.entity.Entity)2 PotionEffect (net.minecraft.potion.PotionEffect)2 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)2 Living (org.spongepowered.api.entity.living.Living)2