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;
}
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class ShrinkHandler method onEntityLiving.
@SubscribeEvent
public void onEntityLiving(LivingEvent event) {
if (!(event.entityLiving instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink")))
return;
ExtendedProperties exProps = null;
try {
exProps = ExtendedProperties.For(player);
} catch (Throwable t) {
return;
}
if (exProps.originalSize == null) {
exProps.originalSize = new AMVector2(player.width, player.height);
}
boolean shrunk = exProps.getIsShrunk();
if (!player.worldObj.isRemote && shrunk && !player.isPotionActive(BuffList.shrink)) {
exProps.setIsShrunk(false);
shrunk = false;
player.yOffset = (float) exProps.getOriginalSize().y * 0.9f;
} else if (!player.worldObj.isRemote && !shrunk && player.isPotionActive(BuffList.shrink)) {
exProps.setIsShrunk(true);
shrunk = true;
player.yOffset = 0.0F;
}
float shrinkPct = exProps.getShrinkPct();
if (shrunk && shrinkPct < 1f) {
shrinkPct = Math.min(1f, shrinkPct + 0.005f);
} else if (!shrunk && shrinkPct > 0f) {
shrinkPct = Math.max(0f, shrinkPct - 0.005f);
}
exProps.setShrinkPct(shrinkPct);
if (exProps.getShrinkPct() > 0f) {
if (//shrink hasn't yet been applied
exProps.shrinkAmount == 0f || //width has changed through other means
exProps.getOriginalSize().x * 0.5 != player.width || exProps.getOriginalSize().y * 0.5 != player.height) {
//height has changed through other means
exProps.setOriginalSize(new AMVector2(player.width, player.height));
exProps.shrinkAmount = 0.5f;
EntityUtilities.setSize(player, player.width * exProps.shrinkAmount, player.height * exProps.shrinkAmount);
player.eyeHeight = player.getDefaultEyeHeight() * exProps.shrinkAmount;
player.yOffset = 0.0f;
}
} else {
if (exProps.shrinkAmount != 0f) {
AMVector2 size = ExtendedProperties.For(player).getOriginalSize();
EntityUtilities.setSize(player, (float) (size.x), (float) (size.y));
exProps.shrinkAmount = 0f;
player.eyeHeight = player.getDefaultEyeHeight();
player.yOffset = 0.0f;
if (exProps.getIsFlipped()) {
event.entityLiving.moveEntity(0, -1, 0);
}
}
}
// update Y offset
if (player.worldObj.isRemote && exProps.getPrevShrinkPct() != exProps.getShrinkPct()) {
// Vanilla player is 1.8f height with 1.62f yOffset => 0.9f
player.yOffset = (float) exProps.getOriginalSize().y * 0.9f * (1f - 0.5f * exProps.getShrinkPct());
}
}
use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.
the class RenderUtilities method setupShrinkRender.
public static void setupShrinkRender(EntityLivingBase entity) {
if (entity == null)
return;
ExtendedProperties exProps = ExtendedProperties.For(entity);
if (exProps.getShrinkPct() > 0f) {
float amt = 0.5f * exProps.getShrinkPct();
GL11.glScalef(1 - amt, 1 - amt, 1 - amt);
}
}
Aggregations