Search in sources :

Example 1 with EntityLightMage

use of am2.entities.EntityLightMage in project ArsMagica2 by Mithion.

the class RenderMage method getEntityTexture.

@Override
protected ResourceLocation getEntityTexture(Entity ent) {
    String tex = "unknown";
    if (ent instanceof EntityLightMage) {
        tex = ((EntityLightMage) ent).getTexture();
    } else if (ent instanceof EntityDarkMage) {
        tex = ((EntityDarkMage) ent).getTexture();
    }
    if (resourceLocations.containsKey(tex)) {
        return resourceLocations.get(tex);
    } else {
        ResourceLocation rLoc = new ResourceLocation("arsmagica2", tex);
        resourceLocations.put(tex, rLoc);
        return rLoc;
    }
}
Also used : EntityLightMage(am2.entities.EntityLightMage) EntityDarkMage(am2.entities.EntityDarkMage) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with EntityLightMage

use of am2.entities.EntityLightMage in project ArsMagica2 by Mithion.

the class SpellHelper method attackTargetSpecial.

public boolean attackTargetSpecial(ItemStack spellStack, Entity target, DamageSource damagesource, float magnitude) {
    if (target.worldObj.isRemote)
        return true;
    EntityPlayer dmgSrcPlayer = null;
    if (damagesource.getSourceOfDamage() != null) {
        if (damagesource.getSourceOfDamage() instanceof EntityLivingBase) {
            EntityLivingBase source = (EntityLivingBase) damagesource.getSourceOfDamage();
            if ((source instanceof EntityLightMage || source instanceof EntityDarkMage) && target.getClass() == EntityCreeper.class) {
                return false;
            } else if (source instanceof EntityLightMage && target instanceof EntityLightMage) {
                return false;
            } else if (source instanceof EntityDarkMage && target instanceof EntityDarkMage) {
                return false;
            } else if (source instanceof EntityPlayer && target instanceof EntityPlayer && !target.worldObj.isRemote && (!MinecraftServer.getServer().isPVPEnabled() || ((EntityPlayer) target).capabilities.isCreativeMode)) {
                return false;
            }
            if (source.isPotionActive(BuffList.fury))
                magnitude += 4;
        }
        if (damagesource.getSourceOfDamage() instanceof EntityPlayer) {
            dmgSrcPlayer = (EntityPlayer) damagesource.getSourceOfDamage();
            int armorSet = ArmorHelper.getFullArsMagicaArmorSet(dmgSrcPlayer);
            if (armorSet == ArsMagicaArmorMaterial.MAGE.getMaterialID()) {
                magnitude *= 1.05f;
            } else if (armorSet == ArsMagicaArmorMaterial.BATTLEMAGE.getMaterialID()) {
                magnitude *= 1.025f;
            } else if (armorSet == ArsMagicaArmorMaterial.ARCHMAGE.getMaterialID()) {
                magnitude *= 1.1f;
            }
            ItemStack equipped = (dmgSrcPlayer).getCurrentEquippedItem();
            if (equipped != null && equipped.getItem() == ItemsCommonProxy.arcaneSpellbook) {
                magnitude *= 1.1f;
            }
        }
    }
    if (target instanceof EntityLivingBase) {
        if (EntityUtilities.isSummon((EntityLivingBase) target) && damagesource.damageType.equals("magic")) {
            magnitude *= 3.0f;
        }
    }
    magnitude *= AMCore.config.getDamageMultiplier();
    ItemStack oldItemStack = null;
    boolean success = false;
    if (target instanceof EntityDragon) {
        success = ((EntityDragon) target).attackEntityFromPart(((EntityDragon) target).dragonPartBody, damagesource, magnitude);
    } else {
        success = target.attackEntityFrom(damagesource, magnitude);
    }
    if (dmgSrcPlayer != null) {
        if (spellStack != null && target instanceof EntityLivingBase) {
            if (!target.worldObj.isRemote && ((EntityLivingBase) target).getHealth() <= 0 && SpellUtils.instance.modifierIsPresent(SpellModifiers.DISMEMBERING_LEVEL, spellStack, 0)) {
                double chance = SpellUtils.instance.getModifiedDouble_Add(0, spellStack, dmgSrcPlayer, target, dmgSrcPlayer.worldObj, 0, SpellModifiers.DISMEMBERING_LEVEL);
                if (dmgSrcPlayer.worldObj.rand.nextDouble() <= chance) {
                    dropHead(target, dmgSrcPlayer.worldObj);
                }
            }
        }
    }
    return success;
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityLightMage(am2.entities.EntityLightMage) EntityDarkMage(am2.entities.EntityDarkMage) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EntityLightMage

use of am2.entities.EntityLightMage in project ArsMagica2 by Mithion.

the class Disarm method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (target instanceof EntityLightMage || target instanceof EntityDarkMage)
        return false;
    if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || (!world.isRemote && !MinecraftServer.getServer().isPVPEnabled())))
        return false;
    if (target instanceof EntityPlayer && ((EntityPlayer) target).getHeldItem() != null && !target.worldObj.isRemote) {
        if (EnchantmentHelper.getEnchantmentLevel(AMEnchantments.soulbound.effectId, ((EntityPlayer) target).getHeldItem()) > 0)
            return true;
        ((EntityPlayer) target).dropOneItem(true);
        return true;
    } else if (target instanceof EntityMob && ((EntityMob) target).getHeldItem() != null) {
        if (EnchantmentHelper.getEnchantmentLevel(AMEnchantments.soulbound.effectId, ((EntityMob) target).getHeldItem()) > 0)
            return true;
        if (!world.isRemote) {
            EntityItem item = new EntityItem(world);
            ItemStack dropstack = ((EntityMob) target).getHeldItem().copy();
            if (dropstack.getMaxDamage() > 0)
                dropstack.setItemDamage((int) Math.floor(dropstack.getMaxDamage() * (0.8f + (world.rand.nextFloat() * 0.19f))));
            item.setEntityItemStack(dropstack);
            item.setPosition(target.posX, target.posY, target.posZ);
            world.spawnEntityInWorld(item);
        }
        ((EntityMob) target).setCurrentItemOrArmor(0, null);
        ((EntityMob) target).setAttackTarget(caster);
        Iterator it = ((EntityMob) target).tasks.taskEntries.iterator();
        boolean removed = false;
        while (it.hasNext()) {
            EntityAITaskEntry task = (EntityAITaskEntry) it.next();
            if (task.action instanceof EntityAIArrowAttack) {
                it.remove();
                removed = true;
                break;
            }
        }
        if (removed) {
            ((EntityMob) target).tasks.addTask(5, new EntityAIAttackOnCollide((EntityCreature) target, 0.5, true));
            ((EntityMob) target).setCanPickUpLoot(true);
        }
    } else if (target instanceof EntityEnderman) {
        int blockID = ((EntityEnderman) target).getCarryingData();
        int meta = ((EntityEnderman) target).getCarryingData();
        if (blockID > 0) {
            ((EntityEnderman) target).setCarryingData(0);
            ItemStack dropstack = new ItemStack(Block.getBlockById(blockID), 1, meta);
            EntityItem item = new EntityItem(world);
            item.setEntityItemStack(dropstack);
            item.setPosition(target.posX, target.posY, target.posZ);
            world.spawnEntityInWorld(item);
        }
        ((EntityMob) target).setAttackTarget(caster);
    }
    return false;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) EntityLightMage(am2.entities.EntityLightMage) EntityDarkMage(am2.entities.EntityDarkMage) EntityAIArrowAttack(net.minecraft.entity.ai.EntityAIArrowAttack) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityItem(net.minecraft.entity.item.EntityItem) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)

Aggregations

EntityDarkMage (am2.entities.EntityDarkMage)3 EntityLightMage (am2.entities.EntityLightMage)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 Iterator (java.util.Iterator)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityAIArrowAttack (net.minecraft.entity.ai.EntityAIArrowAttack)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 ResourceLocation (net.minecraft.util.ResourceLocation)1