Search in sources :

Example 51 with EntityLivingBase

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

the class ExtendedProperties method setEntityReference.

//=======================================================================================
// Utility Methods
//=======================================================================================
public void setEntityReference(EntityLivingBase entity) {
    this.entity = entity;
    setOriginalSize(new AMVector2(entity.width, entity.height));
    hasInitialized = true;
    isCritical = entity instanceof EntityPlayerMP;
    yOffsetOrig = entity.yOffset;
    if (isCritical)
        ticksToRegen = 5;
    else
        ticksToRegen = 20;
    if (isCritical) {
        if (armorProcCooldowns[3] > 0) {
            AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 3, armorProcCooldowns[3]);
        }
        if (armorProcCooldowns[1] > 0) {
            AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 1, armorProcCooldowns[1]);
        }
        if (armorProcCooldowns[2] > 0) {
            AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 2, armorProcCooldowns[2]);
        }
        if (armorProcCooldowns[0] > 0) {
            AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 0, armorProcCooldowns[0]);
        }
    }
    if (entity.worldObj != null && entity.worldObj.isRemote && entity instanceof EntityPlayer && AMCore.proxy.playerTracker.hasAA((EntityPlayer) entity)) {
        EntityLivingBase localPlayer = AMCore.instance.proxy.getLocalPlayer();
        if (entity != localPlayer)
            AMNetHandler.INSTANCE.requestAuras((EntityPlayer) entity);
    }
}
Also used : AMVector2(am2.api.math.AMVector2) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 52 with EntityLivingBase

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

the class ExtendedProperties method handleDataPacket.

public boolean handleDataPacket(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    int entID = rdr.getInt();
    if (entID != this.entity.getEntityId()) {
        return false;
    }
    int flags = rdr.getInt();
    if ((flags & UPD_BITFLAG) == UPD_BITFLAG) {
        this.bitFlag = rdr.getByte();
    }
    if ((flags & UPD_CURRENT_MANA_FATIGUE) == UPD_CURRENT_MANA_FATIGUE) {
        this.currentMana = rdr.getFloat();
        this.currentFatigue = rdr.getFloat();
    }
    if ((flags & UPD_MAGIC_LEVEL) == UPD_MAGIC_LEVEL) {
        this.magicLevel = rdr.getInt();
        float newMagicXP = rdr.getFloat();
        if (entity.worldObj.isRemote && newMagicXP != magicXP) {
            AMGuiHelper.instance.showMagicXPBar();
        }
        this.magicXP = newMagicXP;
    }
    if ((flags & UPD_MARK) == UPD_MARK) {
        this.markX = rdr.getDouble();
        this.markY = rdr.getDouble();
        this.markZ = rdr.getDouble();
        this.markDimension = rdr.getInt();
        this.setMarkSet(rdr.getBoolean());
    }
    if ((flags & UPD_MAX_MANA_FATIGUE) == UPD_MAX_MANA_FATIGUE) {
        this.maxMana = rdr.getFloat();
        this.maxFatigue = rdr.getFloat();
    }
    if ((flags & UPD_NUM_SUMMONS) == UPD_NUM_SUMMONS) {
        this.numSummons = rdr.getInt();
    }
    if ((flags & UPD_BETA_PARTICLES) == UPD_BETA_PARTICLES && entity instanceof EntityPlayer && AMCore.proxy.playerTracker.hasAA((EntityPlayer) entity)) {
        this.AuraIndex = rdr.getInt();
        this.AuraBehaviour = rdr.getInt();
        this.AuraScale = rdr.getFloat();
        this.AuraAlpha = rdr.getFloat();
        this.AuraColorRandomize = rdr.getBoolean();
        this.AuraColorDefault = rdr.getBoolean();
        this.AuraColor = rdr.getInt();
        this.AuraDelay = rdr.getInt();
        this.AuraQuantity = rdr.getInt();
        this.AuraSpeed = rdr.getFloat();
    }
    if ((flags & UPD_CONTINGENCY) == UPD_CONTINGENCY) {
        this.contingencyType = ContingencyTypes.values()[rdr.getInt()];
        if (this.contingencyType != ContingencyTypes.NONE) {
            this.contingencyStack = rdr.getItemStack();
        }
    }
    if ((flags & UPD_MANALINK) == UPD_MANALINK) {
        this.manaLinks.clear();
        int numLinks = rdr.getInt();
        for (int i = 0; i < numLinks; ++i) {
            Entity e = entity.worldObj.getEntityByID(rdr.getInt());
            if (e != null && e instanceof EntityLivingBase)
                updateManaLink((EntityLivingBase) e);
        }
    }
    if ((flags & UPD_DISABLE_GRAVITY) == UPD_DISABLE_GRAVITY) {
        this.disableGravity = rdr.getBoolean();
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) AMDataReader(am2.network.AMDataReader)

Example 53 with EntityLivingBase

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

the class ExtendedProperties method verifySummons.

private void verifySummons() {
    for (int i = 0; i < summon_ent_ids.size(); ++i) {
        int id = summon_ent_ids.get(i);
        Entity e = entity.worldObj.getEntityByID(id);
        if (e == null || !(e instanceof EntityLivingBase)) {
            summon_ent_ids.remove(i);
            i--;
            removeSummon();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 54 with EntityLivingBase

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

the class Knockback method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (target instanceof EntityLivingBase) {
        double speed = 1.5;
        speed = SpellUtils.instance.getModifiedDouble_Add(speed, stack, caster, target, world, 0, SpellModifiers.VELOCITY_ADDED);
        double vertSpeed = 0.325;
        EntityLivingBase curEntity = (EntityLivingBase) target;
        double deltaZ = curEntity.posZ - caster.posZ;
        double deltaX = curEntity.posX - caster.posX;
        double angle = Math.atan2(deltaZ, deltaX);
        double radians = angle;
        if (curEntity instanceof EntityPlayer) {
            AMNetHandler.INSTANCE.sendVelocityAddPacket(world, curEntity, speed * Math.cos(radians), vertSpeed, speed * Math.sin(radians));
        } else {
            curEntity.motionX += (speed * Math.cos(radians));
            curEntity.motionZ += (speed * Math.sin(radians));
            curEntity.motionY += vertSpeed;
        }
        return true;
    }
    return false;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 55 with EntityLivingBase

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

the class LifeTap method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase))
        return false;
    if (!world.isRemote) {
        double damage = SpellUtils.instance.getModifiedDouble_Mul(2, stack, caster, target, world, 0, SpellModifiers.DAMAGE);
        ExtendedProperties casterProperties = ExtendedProperties.For(caster);
        float manaRefunded = (float) (((damage * 0.01)) * casterProperties.getMaxMana());
        if ((caster).attackEntityFrom(DamageSource.outOfWorld, (int) Math.floor(damage))) {
            casterProperties.setCurrentMana(casterProperties.getCurrentMana() + manaRefunded);
            casterProperties.forceSync();
        } else {
            return false;
        }
    }
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)270 EntityPlayer (net.minecraft.entity.player.EntityPlayer)100 Entity (net.minecraft.entity.Entity)72 PotionEffect (net.minecraft.potion.PotionEffect)43 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)39 ItemStack (net.minecraft.item.ItemStack)36 Vec3d (net.minecraft.util.math.Vec3d)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 BlockPos (net.minecraft.util.math.BlockPos)24 TileEntity (net.minecraft.tileentity.TileEntity)23 World (net.minecraft.world.World)20 IBlockState (net.minecraft.block.state.IBlockState)19 AMVector3 (am2.api.math.AMVector3)15 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)15 ArrayList (java.util.ArrayList)15 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)15 Block (net.minecraft.block.Block)12 EntityItem (net.minecraft.entity.item.EntityItem)11 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10