use of am2.api.events.ManaCostEvent 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"));
}
}
use of am2.api.events.ManaCostEvent in project ArsMagica2 by Mithion.
the class SpellHelper method preSpellCast.
private SpellCastingEvent.Pre preSpellCast(ItemStack stack, EntityLivingBase caster, boolean isChanneled) {
SpellRequirements reqs = SpellUtils.instance.getSpellRequirements(stack, caster);
float manaCost = reqs.manaCost;
float burnout = reqs.burnout;
ArrayList<ItemStack> reagents = reqs.reagents;
ManaCostEvent mce = new ManaCostEvent(stack, caster, manaCost, burnout);
MinecraftForge.EVENT_BUS.post(mce);
manaCost = mce.manaCost;
burnout = mce.burnout;
SpellCastingEvent.Pre event = new SpellCastingEvent().new Pre(stack, (ItemSpellBase) stack.getItem(), caster, manaCost, burnout, isChanneled);
if (MinecraftForge.EVENT_BUS.post(event)) {
event.castResult = SpellCastResult.EFFECT_FAILED;
return event;
}
event.castResult = SpellCastResult.SUCCESS;
if (!SpellUtils.instance.casterHasAllReagents(caster, reagents))
event.castResult = SpellCastResult.REAGENTS_MISSING;
if (!SpellUtils.instance.casterHasMana(caster, manaCost))
event.castResult = SpellCastResult.NOT_ENOUGH_MANA;
return event;
}
Aggregations