Search in sources :

Example 6 with IManaCapability

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);
}
Also used : IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with IManaCapability

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);
}
Also used : IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with IManaCapability

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;
}
Also used : Entity(net.minecraft.entity.Entity) BlockPos(net.minecraft.util.math.BlockPos) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability) ManaManager(com.teamwizardry.wizardry.api.capability.player.mana.ManaManager) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with IManaCapability

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);
}
Also used : FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)

Aggregations

IManaCapability (com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)9 IMiscCapability (com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 FairyData (com.teamwizardry.wizardry.api.entity.fairy.FairyData)2 EnumBloodType (com.teamwizardry.wizardry.api.capability.player.mana.EnumBloodType)1 ManaManager (com.teamwizardry.wizardry.api.capability.player.mana.ManaManager)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1