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);
}
}
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;
}
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();
}
}
}
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;
}
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;
}
Aggregations