Search in sources :

Example 1 with EntityCreature

use of net.minecraft.entity.EntityCreature in project PneumaticCraft by MineMaarten.

the class PacketSetMobTarget method handleClientSide.

@Override
public void handleClientSide(PacketSetMobTarget message, EntityPlayer player) {
    Entity mob = player.worldObj.getEntityByID(message.mobId);
    Entity target = player.worldObj.getEntityByID(message.targetId);
    if (mob instanceof EntityCreature) {
        ((EntityCreature) mob).setAttackTarget(target instanceof EntityLivingBase ? (EntityLivingBase) target : null);
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityCreature(net.minecraft.entity.EntityCreature)

Example 2 with EntityCreature

use of net.minecraft.entity.EntityCreature in project MineFactoryReloaded by powercrystals.

the class EntitySafariNet method onImpact.

@Override
protected void onImpact(MovingObjectPosition mop) {
    ItemStack storedEntity = dataWatcher.getWatchableObjectItemStack(13);
    if (mop.typeOfHit == EnumMovingObjectType.TILE) {
        if (ItemSafariNet.isEmpty(storedEntity)) {
            dropAsStack(storedEntity);
        } else {
            ItemSafariNet.releaseEntity(storedEntity, worldObj, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit);
            if (ItemSafariNet.isSingleUse(storedEntity)) {
                dropAsStack(null);
            } else {
                dropAsStack(storedEntity);
            }
        }
    } else {
        if (ItemSafariNet.isEmpty(storedEntity) && mop.entityHit instanceof EntityLiving) {
            ItemSafariNet.captureEntity(storedEntity, (EntityLiving) mop.entityHit);
            dropAsStack(storedEntity);
        } else {
            if (!ItemSafariNet.isEmpty(storedEntity)) {
                Entity releasedEntity = ItemSafariNet.releaseEntity(storedEntity, worldObj, (int) mop.entityHit.posX, (int) mop.entityHit.posY, (int) mop.entityHit.posZ, 1);
                if (mop.entityHit instanceof EntityLiving) {
                    if (releasedEntity instanceof EntityLiving) {
                        //Functional for skeletons.
                        ((EntityLiving) releasedEntity).setAttackTarget((EntityLiving) mop.entityHit);
                    }
                    if (releasedEntity instanceof EntityCreature) {
                        //functional for mobs that extend EntityCreature (everything but Ghasts) and not Skeletons.
                        ((EntityCreature) releasedEntity).setTarget(mop.entityHit);
                    }
                }
                if (ItemSafariNet.isSingleUse(storedEntity)) {
                    dropAsStack(null);
                    return;
                }
            }
            dropAsStack(storedEntity);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack) EntityCreature(net.minecraft.entity.EntityCreature)

Example 3 with EntityCreature

use of net.minecraft.entity.EntityCreature in project ArsMagica2 by Mithion.

the class ItemCrystalPhylactery method getSpawnableEntities.

public void getSpawnableEntities(World world) {
    for (Object clazz : EntityList.classToStringMapping.keySet()) {
        if (EntityCreature.class.isAssignableFrom((Class) clazz)) {
            try {
                EntityCreature temp = (EntityCreature) ((Class) clazz).getConstructor(World.class).newInstance(world);
                if (EntityUtilities.isAIEnabled(temp) && !(temp instanceof IBossDisplayData)) {
                    int color = 0;
                    boolean found = false;
                    //look for entity egg
                    for (Object info : EntityList.entityEggs.values()) {
                        EntityEggInfo eei = (EntityEggInfo) info;
                        Class spawnClass = EntityList.getClassFromID(eei.spawnedID);
                        if (spawnClass == (Class) clazz) {
                            color = eei.primaryColor;
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        //no spawn egg...pick random color?
                        color = world.rand.nextInt();
                    }
                    spawnableEntities.put((String) EntityList.classToStringMapping.get(clazz), color);
                }
            } catch (Throwable e) {
            //e.printStackTrace();
            }
        }
    }
}
Also used : EntityEggInfo(net.minecraft.entity.EntityList.EntityEggInfo) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityCreature(net.minecraft.entity.EntityCreature)

Example 4 with EntityCreature

use of net.minecraft.entity.EntityCreature 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 5 with EntityCreature

use of net.minecraft.entity.EntityCreature in project ArsMagica2 by Mithion.

the class EntityAISummonAllies method updateTask.

@Override
public void updateTask() {
    if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.CASTING)
        ((IArsMagicaBoss) host).setCurrentAction(BossActions.CASTING);
    actionTicks++;
    if (actionTicks == 16) {
        if (!host.worldObj.isRemote)
            host.worldObj.playSoundAtEntity(host, "arsmagica2:mob.lifeguardian.summon", 1.0f, host.getRNG().nextFloat() * 0.5f + 0.5f);
        int numAllies = 3;
        for (int i = 0; i < numAllies; ++i) {
            Class summon = mobs[host.worldObj.rand.nextInt(mobs.length)];
            try {
                Constructor ctor = summon.getConstructor(World.class);
                EntityCreature mob = (EntityCreature) ctor.newInstance(host.worldObj);
                mob.setPosition(host.posX + host.worldObj.rand.nextDouble() * 2 - 1, host.posY, host.posZ + host.worldObj.rand.nextDouble() * 2 - 1);
                mob.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.regeneration.id, 99999, 1));
                mob.addPotionEffect(new BuffEffectMagicShield(99999, 1));
                if (host.getHealth() < host.getMaxHealth() / 2) {
                    mob.addPotionEffect(new BuffEffectShrink(99999, 1));
                }
                EntityUtilities.makeSummon_MonsterFaction(mob, false);
                EntityUtilities.setOwner(mob, host);
                EntityUtilities.setSummonDuration(mob, 1800);
                host.worldObj.spawnEntityInWorld(mob);
                host.queued_minions.add(mob);
            } catch (Throwable e) {
                e.printStackTrace();
                return;
            }
        }
    }
    if (actionTicks >= 23) {
        resetTask();
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Constructor(java.lang.reflect.Constructor) BuffEffectShrink(am2.buffs.BuffEffectShrink) BuffEffectMagicShield(am2.buffs.BuffEffectMagicShield) EntityCreature(net.minecraft.entity.EntityCreature)

Aggregations

EntityCreature (net.minecraft.entity.EntityCreature)9 Entity (net.minecraft.entity.Entity)3 EntityLiving (net.minecraft.entity.EntityLiving)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 PotionEffect (net.minecraft.potion.PotionEffect)2 BuffEffectCharmed (am2.buffs.BuffEffectCharmed)1 BuffEffectMagicShield (am2.buffs.BuffEffectMagicShield)1 BuffEffectShrink (am2.buffs.BuffEffectShrink)1 EntityAISummonFollowOwner (am2.entities.ai.EntityAISummonFollowOwner)1 Summon (am2.spell.components.Summon)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 GameProfile (com.mojang.authlib.GameProfile)1 ItemMobCatcher (convenientadditions.item.tools.mobCatcher.ItemMobCatcher)1 Constructor (java.lang.reflect.Constructor)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 EntityEggInfo (net.minecraft.entity.EntityList.EntityEggInfo)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1 IMob (net.minecraft.entity.monster.IMob)1