Search in sources :

Example 1 with EntityAnimal

use of net.minecraft.entity.passive.EntityAnimal in project ArsMagica2 by Mithion.

the class FlickerOperatorButchery method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
    HashMap<Class, Integer> entityCount = new HashMap<Class, Integer>();
    int radius = 6;
    List<EntityAnimal> creatures = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
    for (EntityAnimal creature : creatures) {
        Class clazz = creature.getClass();
        if (!SpawnBlacklists.canButcheryAffect(clazz))
            continue;
        Integer count = entityCount.get(clazz);
        if (count == null)
            count = 0;
        if (!creature.isChild())
            count++;
        entityCount.put(clazz, count);
        if (count > 2) {
            if (worldObj.isRemote) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ghost", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 0.7, ((TileEntity) habitat).zCoord + 0.5);
                if (particle != null) {
                    particle.setMaxAge(20);
                    particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.05f, 1, false));
                }
            } else {
                creature.attackEntityFrom(DamageSource.generic, 500);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) HashMap(java.util.HashMap) ParticleFloatUpward(am2.particles.ParticleFloatUpward) EntityAnimal(net.minecraft.entity.passive.EntityAnimal)

Example 2 with EntityAnimal

use of net.minecraft.entity.passive.EntityAnimal in project ArsMagica2 by Mithion.

the class FlickerOperatorProgeny method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
    HashMap<Class, Integer> entityCount = new HashMap<Class, Integer>();
    int radius = 8;
    int diameter = radius * 2 + 1;
    List<EntityAnimal> creatures = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
    for (EntityAnimal creature : creatures) {
        Class clazz = creature.getClass();
        if (!SpawnBlacklists.canProgenyAffect(clazz))
            continue;
        Integer count = entityCount.get(clazz);
        if (count == null)
            count = 0;
        if (!creature.isInLove() && creature.getGrowingAge() == 0)
            count++;
        entityCount.put(clazz, count);
        if (count == 2) {
            if (worldObj.isRemote) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "heart", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 0.7, ((TileEntity) habitat).zCoord + 0.5);
                if (particle != null) {
                    particle.setMaxAge(20);
                    particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.05f, 1, false));
                }
            } else {
                creatures = worldObj.getEntitiesWithinAABB(clazz, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
                count = 0;
                for (EntityAnimal animal : creatures) {
                    if (!animal.isChild()) {
                        animal.func_146082_f(null);
                        count++;
                        if (count == 2)
                            break;
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) HashMap(java.util.HashMap) ParticleFloatUpward(am2.particles.ParticleFloatUpward) EntityAnimal(net.minecraft.entity.passive.EntityAnimal)

Example 3 with EntityAnimal

use of net.minecraft.entity.passive.EntityAnimal in project ArsMagica2 by Mithion.

the class Charm method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityCreature) || ((EntityCreature) target).isPotionActive(BuffList.charmed) || EntityUtilities.isSummon((EntityCreature) target)) {
        return false;
    }
    int duration = SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration, stack, caster, target, world, 0, SpellModifiers.DURATION);
    duration = SpellUtils.instance.modifyDurationBasedOnArmor(caster, duration);
    int x = (int) Math.floor(target.posX);
    int y = (int) Math.floor(target.posY);
    int z = (int) Math.floor(target.posZ);
    if (RitualShapeHelper.instance.checkForRitual(this, world, x, y, z) != null) {
        duration += (3600 * (SpellUtils.instance.countModifiers(SpellModifiers.BUFF_POWER, stack, 0) + 1));
        RitualShapeHelper.instance.consumeRitualReagents(this, world, x, y, z);
    }
    if (target instanceof EntityAnimal) {
        ((EntityAnimal) target).func_146082_f(null);
        return true;
    }
    if (ExtendedProperties.For(caster).getCanHaveMoreSummons()) {
        if (caster instanceof EntityPlayer) {
            if (target instanceof EntityCreature) {
                BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_PLAYER);
                charmBuff.setCharmer(caster);
                ((EntityCreature) target).addPotionEffect(charmBuff);
            }
            return true;
        } else if (caster instanceof EntityLiving) {
            if (target instanceof EntityCreature) {
                BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_MONSTER);
                charmBuff.setCharmer(caster);
                ((EntityCreature) target).addPotionEffect(charmBuff);
            }
            return true;
        }
    } else {
        if (caster instanceof EntityPlayer) {
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText("You cannot have any more summons."));
        }
        return true;
    }
    return false;
}
Also used : BuffEffectCharmed(am2.buffs.BuffEffectCharmed) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) ChatComponentText(net.minecraft.util.ChatComponentText) EntityCreature(net.minecraft.entity.EntityCreature)

Example 4 with EntityAnimal

use of net.minecraft.entity.passive.EntityAnimal in project ConvenientAdditions by Necr0.

the class BehaviourAutoFeed method onItemEntityUpdate.

@Override
public void onItemEntityUpdate(EntityItem item) {
    World w = item.getEntityWorld();
    if (w.isRemote)
        return;
    List<EntityAnimal> l = w.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(item.posX - 1, item.posY - 1, item.posZ - 1, item.posX + 1, item.posY + 1, item.posZ + 1));
    if (!item.getEntityItem().isEmpty()) {
        for (EntityAnimal a : l) {
            if (Arrays.asList(ModConfigMisc.seedBox_autoFeedBlacklist).contains(EntityRegistry.getEntry(a.getClass()).getRegistryName().toString()))
                continue;
            if (a.getGrowingAge() == 0 && !a.isInLove() && a.isBreedingItem(item.getEntityItem())) {
                item.getEntityItem().shrink(1);
                a.setInLove(null);
            } else if (a.isChild() && a.isBreedingItem(item.getEntityItem())) {
                item.getEntityItem().shrink(1);
                a.ageUp((int) ((float) (-a.getGrowingAge() / 20) * 0.1F), true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) World(net.minecraft.world.World) EntityAnimal(net.minecraft.entity.passive.EntityAnimal)

Example 5 with EntityAnimal

use of net.minecraft.entity.passive.EntityAnimal in project OpenModularTurrets by OpenModularTurretsTeam.

the class TurretHeadUtil method getTarget.

@SuppressWarnings("ConstantConditions")
public static Entity getTarget(TurretBase base, World worldObj, BlockPos pos, int turretRange, TurretHead turret) {
    Entity target = null;
    if (!worldObj.isRemote && base != null && base.getOwner() != null) {
        AxisAlignedBB axis = new AxisAlignedBB(pos.getX() - turretRange - 1, pos.getY() - turretRange - 1, pos.getZ() - turretRange - 1, pos.getX() + turretRange + 1, pos.getY() + turretRange + 1, pos.getZ() + turretRange + 1);
        List<EntityLivingBase> targets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
        for (EntityLivingBase target1 : targets) {
            if (target1 != null && EntityList.getEntityString(target1) != null) {
                if (ConfigHandler.validMobBlacklist.contains(EntityList.getEntityString(target1)))
                    continue;
            }
            if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
                if (target1 instanceof EntityAnimal && !target1.isDead) {
                    target = target1;
                }
            }
            if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
                if (target1 instanceof EntityAmbientCreature && !target1.isDead) {
                    target = target1;
                }
            }
            if (base.isAttacksMobs() && ConfigHandler.globalCanTargetMobs) {
                if (target1.isCreatureType(EnumCreatureType.MONSTER, false) && !target1.isDead) {
                    target = target1;
                }
            }
            if (base.isAttacksPlayers() && ConfigHandler.globalCanTargetPlayers) {
                if (target1 instanceof EntityPlayerMP && !target1.isDead) {
                    EntityPlayerMP entity = (EntityPlayerMP) target1;
                    if (!isPlayerOwner(entity, base) && !isPlayerTrusted(entity, base) && !entity.capabilities.isCreativeMode) {
                        target = target1;
                    }
                }
            }
            if (target != null && turret != null) {
                if (base.isMultiTargeting() && isTargetAlreadyTargeted(base, target)) {
                    continue;
                }
                EntityLivingBase targetELB = (EntityLivingBase) target;
                if (canTurretSeeTarget(turret, targetELB) && targetELB.getHealth() > 0.0F) {
                    return target;
                }
            }
        }
    }
    return null;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) EntityAmbientCreature(net.minecraft.entity.passive.EntityAmbientCreature)

Aggregations

EntityAnimal (net.minecraft.entity.passive.EntityAnimal)14 Entity (net.minecraft.entity.Entity)7 EntityLivingBase (net.minecraft.entity.EntityLivingBase)7 TileEntity (net.minecraft.tileentity.TileEntity)7 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 EntityAmbientCreature (net.minecraft.entity.passive.EntityAmbientCreature)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 AMParticle (am2.particles.AMParticle)2 ParticleFloatUpward (am2.particles.ParticleFloatUpward)2 HashMap (java.util.HashMap)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EntityLiving (net.minecraft.entity.EntityLiving)2 IMob (net.minecraft.entity.monster.IMob)2 Vector (ValkyrienWarfareBase.API.Vector)1 Quaternion (ValkyrienWarfareBase.Math.Quaternion)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 BuffEffectCharmed (am2.buffs.BuffEffectCharmed)1