Search in sources :

Example 1 with IManaCapability

use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.

the class TileManaNode method drainMana.

public double drainMana(double mana) {
    if (!world.isBlockLoaded(pos))
        return -1;
    IManaCapability cap = getWizardryCap();
    if (cap == null)
        return -1;
    double amount = MathHelper.clamp(cap.getMana(), 0, mana);
    ManaManager.forObject(cap).removeMana(amount).close();
    return amount;
}
Also used : IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)

Example 2 with IManaCapability

use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.

the class BloodRenderLayer method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    if (Minecraft.getMinecraft().player == null || Minecraft.getMinecraft().world == null)
        return;
    IManaCapability cap = ManaCapabilityProvider.getCap(entity);
    if (cap != null) {
        EnumBloodType type = cap.getBloodType();
        if (type != null && type != EnumBloodType.NONE) {
            render.bindTexture(EnumBloodType.getResourceLocation(type));
            ClientUtilMethods.glColor(type.color);
            setModelVisibilities(entity);
            GlStateManager.enableBlendProfile(Profile.PLAYER_SKIN);
            GlStateManager.disableLighting();
            ShaderHelper.INSTANCE.useShader(Shaders.rawColor);
            render.getMainModel().render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
            GlStateManager.enableLighting();
            ShaderHelper.INSTANCE.releaseShader();
            GlStateManager.disableBlendProfile(Profile.PLAYER_SKIN);
            GlStateManager.color(1.0F, 1.0F, 1.0F);
        }
    }
}
Also used : EnumBloodType(com.teamwizardry.wizardry.api.capability.player.mana.EnumBloodType) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)

Example 3 with IManaCapability

use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.

the class ItemJar method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack stack) {
    if (stack.getItemDamage() == 2) {
        FairyData fairy = FairyData.deserialize(NBTHelper.getCompound(stack, "fairy"));
        if (fairy == null)
            return super.getItemStackDisplayName(stack);
        IManaCapability cap = fairy.handler;
        double mana = ManaManager.getMana(cap) / ManaManager.getMaxMana(cap);
        boolean dulled = fairy.isDepressed;
        if (dulled) {
            return I18n.translateToLocal("item.wizardry.fairy_jar.dulled.name").trim();
        } else if (mana > 0.25 && mana < 0.5) {
            return I18n.translateToLocal("item.wizardry.fairy_jar.barely_excited.name").trim();
        } else if (mana >= 0.5 && mana < 0.75) {
            return I18n.translateToLocal("item.wizardry.fairy_jar.moderately_excited.name").trim();
        } else if (mana > 0.75 && mana < 1) {
            return I18n.translateToLocal("item.wizardry.fairy_jar.very_excited.name").trim();
        } else if (mana >= 1) {
            return I18n.translateToLocal("item.wizardry.fairy_jar.overloaded.name").trim();
        } else
            return super.getItemStackDisplayName(stack);
    } else
        return super.getItemStackDisplayName(stack);
}
Also used : FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)

Example 4 with IManaCapability

use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.

the class PacketUpdateManaCap method handle.

@Override
public void handle(@Nonnull MessageContext ctx) {
    if (ctx.side.isServer())
        return;
    EntityPlayer player = LibrarianLib.PROXY.getClientPlayer();
    IManaCapability cap = ManaCapabilityProvider.getCap(player);
    if (cap != null) {
        cap.deserializeNBT(tags);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability)

Example 5 with IManaCapability

use of com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability in project Wizardry by TeamWizardry.

the class ModCapabilities method onLogin.

@SubscribeEvent
public static void onLogin(PlayerEvent.PlayerLoggedInEvent 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)

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