use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderAffinity.
public void RenderAffinity(int i, int j) {
AMVector2 affinityPos = getShiftedVector(AMCore.config.getAffinityPosition(), i, j);
int x = affinityPos.iX;
int y = affinityPos.iY;
AffinityData ad = AffinityData.For(Minecraft.getMinecraft().thePlayer);
for (Affinity affinity : ad.getHighestAffinities()) {
if (affinity == null || affinity == Affinity.NONE)
continue;
GL11.glColor3f(1.0f, 1.0f, 1.0f);
AMGuiHelper.instance.DrawIconAtXY(affinity.representItem.getIconFromDamage(affinity.representMeta), x, y, j, 12, 12, true);
if (AMCore.config.getShowNumerics()) {
String display = String.format("%.2f%%", AffinityData.For(mc.thePlayer).getAffinityDepth(affinity) * 100);
if (x < i / 2)
Minecraft.getMinecraft().fontRenderer.drawString(display, x + 14, y + 2, affinity.color);
else
Minecraft.getMinecraft().fontRenderer.drawString(display, x - 2 - Minecraft.getMinecraft().fontRenderer.getStringWidth(display), y + 2, affinity.color);
}
y += 15;
}
}
use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.
the class SpellUtils method modifySpellRequirementsByAffinity.
public SpellRequirements modifySpellRequirementsByAffinity(ItemStack stack, EntityLivingBase caster, SpellRequirements reqs) {
HashMap<Affinity, Float> affinities = this.AffinityFor(stack);
AffinityData affData = AffinityData.For(caster);
if (affData == null)
return reqs;
float manaCost = reqs.manaCost;
for (Affinity aff : affinities.keySet()) {
float depth = affData.getAffinityDepth(aff);
// calculate the modifier based on the player's affinity depth as well as how much of the spell is that affinity
// how much does this affinity affect the overall mana cost?
float effectiveness = affinities.get(aff);
// how much will the player's affinity reduce the mana cost? (max 50%)
float multiplier = 0.5f * depth;
float manaMod = manaCost * effectiveness;
manaCost -= manaMod * multiplier;
}
return new SpellRequirements(manaCost, reqs.burnout, reqs.reagents);
}
use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.
the class SpellUtils method doAffinityShift.
public void doAffinityShift(EntityLivingBase caster, ISpellComponent component, ISpellShape governingShape) {
if (!(caster instanceof EntityPlayer))
return;
AffinityData aff = AffinityData.For(caster);
EnumSet<Affinity> affList = component.getAffinity();
for (Affinity affinity : affList) {
float shift = component.getAffinityShift(affinity) * aff.getDiminishingReturnsFactor() * 5;
float xp = 0.05f * aff.getDiminishingReturnsFactor();
if (governingShape.isChanneled()) {
shift /= 4;
xp /= 4;
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AffinityGains")))) {
shift *= 1.1f;
xp *= 0.9f;
}
ItemStack chestArmor = ((EntityPlayer) caster).getCurrentArmor(2);
if (chestArmor != null && ArmorHelper.isInfusionPreset(chestArmor, GenericImbuement.magicXP))
xp *= 1.25f;
}
if (shift > 0) {
AffinityChangingEvent event = new AffinityChangingEvent((EntityPlayer) caster, affinity, shift);
MinecraftForge.EVENT_BUS.post(event);
if (!event.isCanceled())
aff.incrementAffinity(affinity, event.amount);
}
if (xp > 0) {
xp *= caster.getAttributeMap().getAttributeInstance(ArsMagicaApi.xpGainModifier).getAttributeValue();
ExtendedProperties.For(caster).addMagicXP(xp);
}
}
aff.addDiminishingReturns(governingShape.isChanneled());
}
use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.
the class ItemAffinityBook method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (par1ItemStack.getItemDamage() == META_GENERAL) {
AffinityData data = AffinityData.For(par3EntityPlayer);
data.setLocked(false);
for (Affinity aff : Affinity.values()) {
data.setAffinityAndDepth(aff, data.getAffinityDepth(aff) - 20);
}
} else {
AffinityData.For(par3EntityPlayer).incrementAffinity(Affinity.getByID(par1ItemStack.getItemDamage()), 20);
}
if (!par2World.isRemote)
par1ItemStack.stackSize--;
return par1ItemStack;
}
use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.
the class SpellBase method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (!stack.hasTagCompound())
return;
ItemStack legacySpell = SpellUtils.instance.constructSpellStack(stack);
SpellRequirements reqs = SpellUtils.instance.getSpellRequirements(legacySpell, player);
float manaCost = reqs.manaCost;
float burnout = reqs.burnout;
ArrayList<ItemStack> reagents = reqs.reagents;
ManaCostEvent mce = new ManaCostEvent(legacySpell, player, manaCost, 0);
MinecraftForge.EVENT_BUS.post(mce);
manaCost = mce.manaCost;
list.add(String.format("\2477Mana Cost: %.2f", manaCost));
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
HashMap<Affinity, Float> affinityData = SpellUtils.instance.AffinityFor(legacySpell);
for (Affinity aff : affinityData.keySet()) {
list.add(String.format("%s (%.2f%%)", aff.toString(), affinityData.get(aff) * 100));
}
if (stack.stackTagCompound.hasKey("Lore")) {
NBTTagList nbttaglist1 = stack.stackTagCompound.getTagList("Lore", Constants.NBT.TAG_COMPOUND);
if (nbttaglist1.tagCount() > 0) {
for (int j = 0; j < nbttaglist1.tagCount(); ++j) {
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j));
}
}
}
} else {
list.add(StatCollector.translateToLocal("am2.tooltip.shiftForAffinity"));
}
}
Aggregations