Search in sources :

Example 1 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData 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 2 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData in project ArsMagica2 by Mithion.

the class Appropriation method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (target instanceof EntityPlayer || target instanceof IBossDisplayData)
        return false;
    if (!(target instanceof EntityLivingBase))
        return false;
    for (Class clazz : AMCore.config.getAppropriationMobBlacklist()) if (target.getClass() == clazz)
        return false;
    if (!(caster instanceof EntityPlayer))
        return false;
    ItemStack originalSpellStack = getOriginalSpellStack((EntityPlayer) caster);
    if (originalSpellStack == null)
        return false;
    if (!world.isRemote) {
        if (originalSpellStack.stackTagCompound.hasKey(storageKey)) {
            restore((EntityPlayer) caster, world, originalSpellStack, (int) target.posX, (int) target.posY, (int) target.posZ, target.posX, target.posY + target.getEyeHeight(), target.posZ);
        } else {
            NBTTagCompound data = new NBTTagCompound();
            data.setString("class", target.getClass().getName());
            data.setString(storageType, "ent");
            NBTTagCompound targetData = new NBTTagCompound();
            target.writeToNBT(targetData);
            data.setTag("targetNBT", targetData);
            originalSpellStack.stackTagCompound.setTag(storageKey, data);
            setOriginalSpellStackData((EntityPlayer) caster, originalSpellStack);
            target.setDead();
        }
    }
    return true;
}
Also used : IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DummyEntityPlayer(am2.utility.DummyEntityPlayer) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_PlayerFaction.

public static void makeSummon_PlayerFaction(EntityCreature entityliving, EntityPlayer player, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData) && ExtendedProperties.For(player).getCanHaveMoreSummons()) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        boolean addMeleeAttack = false;
        ArrayList<EntityAITaskEntry> toRemove = new ArrayList<EntityAITaskEntry>();
        for (Object task : entityliving.tasks.taskEntries) {
            EntityAITaskEntry base = (EntityAITaskEntry) task;
            if (base.action instanceof EntityAIAttackOnCollide) {
                toRemove.add(base);
                addMeleeAttack = true;
            }
        }
        entityliving.tasks.taskEntries.removeAll(toRemove);
        if (storeForRevert)
            storedAITasks.put(entityliving.getEntityId(), toRemove);
        if (addMeleeAttack) {
            float speed = entityliving.getAIMoveSpeed();
            if (speed <= 0)
                speed = 1.0f;
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntityMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, IMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntitySlime.class, speed, true));
        }
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityMob.class, 0, true, false, SummonEntitySelector.instance));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntitySlime.class, 0, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityGhast.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityPlayer)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        if (entityliving instanceof EntityTameable) {
            ((EntityTameable) entityliving).setTamed(true);
            ((EntityTameable) entityliving).func_152115_b(player.getCommandSenderName());
        }
        entityliving.getEntityData().setBoolean(isSummonKey, true);
        ExtendedProperties.For(player).addSummon(entityliving);
    }
}
Also used : EntitySlime(net.minecraft.entity.monster.EntitySlime) ArrayList(java.util.ArrayList) EntityGhast(net.minecraft.entity.monster.EntityGhast) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget) EntityMob(net.minecraft.entity.monster.EntityMob) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) IMob(net.minecraft.entity.monster.IMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 4 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData in project ArsMagica2 by Mithion.

the class TileEntityBlackAurem method updateNearbyEntities.

private void updateNearbyEntities() {
    ArrayList<EntityLivingBase> toRemove = new ArrayList<EntityLivingBase>();
    List<EntityLivingBase> nearbyEntities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(this.xCoord - 10, this.yCoord, this.zCoord - 10, this.xCoord + 10, this.yCoord + 4, this.zCoord + 10));
    for (EntityLivingBase entity : nearbyEntities) {
        if (entity.isEntityInvulnerable() || entity instanceof IBossDisplayData || entity instanceof EntityDarkling || entity instanceof EntityPlayer || entity instanceof EntityAirSled || entity instanceof EntityWinterGuardianArm || entity instanceof EntityThrownSickle || entity instanceof EntityFlicker || entity instanceof EntityShadowHelper)
            continue;
        if (!cachedEntities.contains(entity))
            cachedEntities.add(entity);
    }
    ticksSinceLastEntityScan = 0;
}
Also used : ArrayList(java.util.ArrayList) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 5 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_MonsterFaction.

public static void makeSummon_MonsterFaction(EntityCreature entityliving, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData)) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityPlayer.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityMob)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        entityliving.getEntityData().setBoolean(isSummonKey, true);
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) ArrayList(java.util.ArrayList) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget)

Aggregations

IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ArrayList (java.util.ArrayList)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityAIHurtByTarget (net.minecraft.entity.ai.EntityAIHurtByTarget)2 EntityAINearestAttackableTarget (net.minecraft.entity.ai.EntityAINearestAttackableTarget)2 EntityMob (net.minecraft.entity.monster.EntityMob)2 BuffEffect (am2.buffs.BuffEffect)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 EntityCreature (net.minecraft.entity.EntityCreature)1 EntityEggInfo (net.minecraft.entity.EntityList.EntityEggInfo)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 IMob (net.minecraft.entity.monster.IMob)1 EntityTameable (net.minecraft.entity.passive.EntityTameable)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 PotionEffect (net.minecraft.potion.PotionEffect)1