use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.
the class ModCapabilities method onRespawn.
@SubscribeEvent
public static void onRespawn(PlayerEvent.PlayerRespawnEvent event) {
if (event.player.world.isRemote)
return;
IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
if (manaCap != null)
manaCap.dataChanged(event.player);
IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
if (miscCap != null)
miscCap.dataChanged(event.player);
}
use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.
the class ModCapabilities method onDimChange.
@SubscribeEvent
public static void onDimChange(PlayerEvent.PlayerChangedDimensionEvent event) {
if (event.player.world.isRemote)
return;
IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
if (manaCap != null)
manaCap.dataChanged(event.player);
IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
if (miscCap != null)
miscCap.dataChanged(event.player);
}
use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.
the class SpellRing method taxCaster.
// TODO: orb holders
public boolean taxCaster(@Nonnull World world, SpellData data, double multiplier, boolean failSound) {
if (data.getData(SpellData.DefaultKeys.CASTER) == null)
return true;
Entity caster = world.getEntityByID(data.getData(SpellData.DefaultKeys.CASTER));
if (caster == null) {
Wizardry.LOGGER.warn("Caster was null!");
return true;
}
IManaCapability cap = ManaCapabilityProvider.getCap(caster);
if (cap == null)
return false;
double manaDrain = getManaDrain(data) * multiplier;
double burnoutFill = getBurnoutFill(data) * multiplier;
boolean fail = false;
try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(cap)) {
if (mgr.getMana() < manaDrain)
fail = true;
mgr.removeMana(manaDrain);
mgr.addBurnout(burnoutFill);
}
if (fail && failSound) {
Vec3d origin = data.getOriginWithFallback(world);
if (origin != null)
world.playSound(null, new BlockPos(origin), ModSounds.SPELL_FAIL, SoundCategory.NEUTRAL, 1f, 1f);
}
return !fail;
}
use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.
the class ItemJar method addInformation.
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
if (stack.getItemDamage() == 2) {
FairyData fairy = FairyData.deserialize(NBTHelper.getCompound(stack, "fairy"));
if (fairy == null)
return;
IManaCapability cap = fairy.handler;
double mana = ManaManager.getMana(cap) / ManaManager.getMaxMana(cap);
boolean dulled = fairy.isDepressed;
if (dulled) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.dulled.info").trim());
} else if (mana > 0.25 && mana < 0.5) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.barely_excited.info").trim());
} else if (mana >= 0.5 && mana < 0.75) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.moderately_excited.info").trim());
} else if (mana > 0.75 && mana < 1) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.very_excited.info").trim());
} else if (mana >= 1) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.overloaded.info").trim());
} else
super.addInformation(stack, worldIn, tooltip, flagIn);
} else
super.addInformation(stack, worldIn, tooltip, flagIn);
}
Aggregations