use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class Recall method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityLivingBase)) {
return false;
}
if (caster.isPotionActive(BuffList.astralDistortion.id) || ((EntityLivingBase) target).isPotionActive(BuffList.astralDistortion.id)) {
if (caster instanceof EntityPlayer)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.cantTeleport")));
return false;
}
int x = (int) Math.floor(target.posX);
int y = (int) Math.floor(target.posY);
int z = (int) Math.floor(target.posZ);
ItemStack[] ritualRunes = RitualShapeHelper.instance.checkForRitual(this, world, x, y, z, false);
if (ritualRunes != null) {
return handleRitualReagents(ritualRunes, world, x, y, z, caster, target);
}
ExtendedProperties casterProperties = ExtendedProperties.For(caster);
if (!casterProperties.getMarkSet()) {
if (caster instanceof EntityPlayer && !world.isRemote)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark")));
return false;
} else if (casterProperties.getMarkDimension() != caster.dimension) {
if (caster instanceof EntityPlayer && !world.isRemote)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark")));
return false;
}
if (!world.isRemote) {
((EntityLivingBase) target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ());
}
return true;
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ManaDrain method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityLivingBase))
return false;
double manaStolen = 250;
ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase) target);
if (manaStolen > targetProperties.getCurrentMana()) {
manaStolen = targetProperties.getCurrentMana();
}
targetProperties.setCurrentMana((float) (targetProperties.getCurrentMana() - manaStolen));
targetProperties.forceSync();
ExtendedProperties casterProperties = ExtendedProperties.For(caster);
casterProperties.setCurrentMana((float) (casterProperties.getCurrentMana() + manaStolen));
casterProperties.forceSync();
return true;
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityConstructing.
@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
if (event.entity instanceof EntityLivingBase) {
event.entity.registerExtendedProperties(ExtendedProperties.identifier, new ExtendedProperties());
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxManaBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxBurnoutBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.xpGainModifier);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.burnoutReductionRate);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.manaRegenTimeModifier);
if (event.entity instanceof EntityPlayer) {
event.entity.registerExtendedProperties(RiftStorage.identifier, new RiftStorage());
event.entity.registerExtendedProperties(AffinityData.identifier, new AffinityData());
event.entity.registerExtendedProperties(SkillData.identifier, new SkillData((EntityPlayer) event.entity));
}
} else if (event.entity instanceof EntityItemFrame) {
AMCore.proxy.itemFrameWatcher.startWatchingFrame((EntityItemFrame) event.entity);
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityHurt.
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
if (event.source.isFireDamage() && event.entityLiving instanceof EntityPlayer && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3] != null && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3].getItem() == ItemsCommonProxy.fireEars) {
event.setCanceled(true);
return;
}
if (event.entityLiving.isPotionActive(BuffList.magicShield))
event.ammount *= 0.25f;
if (event.entityLiving.isPotionActive(BuffList.manaShield)) {
float manaToTake = Math.min(ExtendedProperties.For(event.entityLiving).getCurrentMana(), event.ammount * 250f);
event.ammount -= manaToTake / 250f;
ExtendedProperties.For(event.entityLiving).deductMana(manaToTake);
ExtendedProperties.For(event.entityLiving).forceSync();
for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1);
event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f);
if (event.ammount <= 0) {
event.setCanceled(true);
return;
}
}
Entity entitySource = event.source.getSourceOfDamage();
if (entitySource instanceof EntityPlayer && ((EntityPlayer) entitySource).inventory.armorInventory[2] != null && ((EntityPlayer) entitySource).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor && ((EntityPlayer) entitySource).getCurrentEquippedItem() == null) {
event.ammount += 4;
double deltaZ = event.entityLiving.posZ - entitySource.posZ;
double deltaX = event.entityLiving.posX - entitySource.posX;
double angle = Math.atan2(deltaZ, deltaX);
double speed = ((EntityPlayer) entitySource).isSprinting() ? 3 : 2;
double vertSpeed = ((EntityPlayer) entitySource).isSprinting() ? 0.5 : 0.325;
if (event.entityLiving instanceof EntityPlayer) {
AMNetHandler.INSTANCE.sendVelocityAddPacket(event.entityLiving.worldObj, event.entityLiving, speed * Math.cos(angle), vertSpeed, speed * Math.sin(angle));
} else {
event.entityLiving.motionX += (speed * Math.cos(angle));
event.entityLiving.motionZ += (speed * Math.sin(angle));
event.entityLiving.motionY += vertSpeed;
}
event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:spell.cast.earth", 0.4f, event.entityLiving.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
ExtendedProperties extendedProperties = ExtendedProperties.For(event.entityLiving);
EntityLivingBase ent = event.entityLiving;
if (extendedProperties.getContingencyType() == ContingencyTypes.DAMAGE_TAKEN) {
extendedProperties.procContingency();
}
if (extendedProperties.getContingencyType() == ContingencyTypes.HEALTH_LOW && ent.getHealth() <= ent.getMaxHealth() / 3) {
extendedProperties.procContingency();
}
if (ent.isPotionActive(BuffList.fury.id))
event.ammount /= 2;
if (entitySource instanceof EntityLivingBase && ((EntityLivingBase) entitySource).isPotionActive(BuffList.shrink))
event.ammount /= 2;
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ArmorHelper method HandleArmorInfusion.
//======================================================================================================
// Infusion
//======================================================================================================
public static void HandleArmorInfusion(EntityPlayer player) {
ExtendedProperties extendedProperties = ExtendedProperties.For(player);
float infusionCost = 0.0f;
boolean bFullSet = getFullArsMagicaArmorSet(player) != -1;
for (int i = 0; i < 4; ++i) {
infusionCost += GetArsMagicaArmorInfusionCostFromSlot(player, i);
}
if (bFullSet) {
infusionCost *= 0.75;
}
if (infusionCost > 0 && extendedProperties.getCurrentMana() > infusionCost) {
//deduct mana
extendedProperties.setCurrentMana(extendedProperties.getCurrentMana() - infusionCost);
//bank infusion
extendedProperties.bankedInfusionHelm += GetArsMagicaArmorRepairAmountFromSlot(player, 3);
extendedProperties.bankedInfusionChest += GetArsMagicaArmorRepairAmountFromSlot(player, 2);
extendedProperties.bankedInfusionLegs += GetArsMagicaArmorRepairAmountFromSlot(player, 1);
extendedProperties.bankedInfusionBoots += GetArsMagicaArmorRepairAmountFromSlot(player, 0);
//repair armor if infusion bank is above 1
if (extendedProperties.bankedInfusionHelm > 1) {
int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionHelm);
RepairEquippedArsMagicaArmorItem(player, repairAmount, 3);
extendedProperties.bankedInfusionHelm -= repairAmount;
}
if (extendedProperties.bankedInfusionChest > 1) {
int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionChest);
RepairEquippedArsMagicaArmorItem(player, repairAmount, 2);
extendedProperties.bankedInfusionChest -= repairAmount;
}
if (extendedProperties.bankedInfusionLegs > 1) {
int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionLegs);
RepairEquippedArsMagicaArmorItem(player, repairAmount, 1);
extendedProperties.bankedInfusionLegs -= repairAmount;
}
if (extendedProperties.bankedInfusionBoots > 1) {
int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionBoots);
RepairEquippedArsMagicaArmorItem(player, repairAmount, 0);
extendedProperties.bankedInfusionBoots -= repairAmount;
}
}
}
Aggregations