Search in sources :

Example 11 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class IllEffectDrainMana method ApplyIllEffect.

@Override
public Map<EntityPlayer, Object> ApplyIllEffect(World world, int x, int y, int z) {
    HashMap<EntityPlayer, Object> toReturn = new HashMap<EntityPlayer, Object>();
    if (world.isRemote)
        return toReturn;
    List<EntityPlayer> located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3));
    EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]);
    if (players.length == 0)
        return toReturn;
    for (EntityPlayer player : players) {
        ExtendedProperties props = ExtendedProperties.For(player);
        props.setCurrentMana(0);
        props.forceSync();
        toReturn.put(player, null);
    }
    return toReturn;
}
Also used : HashMap(java.util.HashMap) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 12 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class Recall method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase)) {
        return false;
    }
    if (caster.isPotionActive(BuffList.astralDistortion.id) || ((EntityLivingBase) target).isPotionActive(BuffList.astralDistortion.id)) {
        if (caster instanceof EntityPlayer)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.cantTeleport")));
        return false;
    }
    int x = (int) Math.floor(target.posX);
    int y = (int) Math.floor(target.posY);
    int z = (int) Math.floor(target.posZ);
    ItemStack[] ritualRunes = RitualShapeHelper.instance.checkForRitual(this, world, x, y, z, false);
    if (ritualRunes != null) {
        return handleRitualReagents(ritualRunes, world, x, y, z, caster, target);
    }
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    if (!casterProperties.getMarkSet()) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark")));
        return false;
    } else if (casterProperties.getMarkDimension() != caster.dimension) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark")));
        return false;
    }
    if (!world.isRemote) {
        ((EntityLivingBase) target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ());
    }
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) ParticleExpandingCollapsingRingAtPoint(am2.particles.ParticleExpandingCollapsingRingAtPoint) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 13 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class ManaDrain method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase))
        return false;
    double manaStolen = 250;
    ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase) target);
    if (manaStolen > targetProperties.getCurrentMana()) {
        manaStolen = targetProperties.getCurrentMana();
    }
    targetProperties.setCurrentMana((float) (targetProperties.getCurrentMana() - manaStolen));
    targetProperties.forceSync();
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    casterProperties.setCurrentMana((float) (casterProperties.getCurrentMana() + manaStolen));
    casterProperties.forceSync();
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 14 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderMagicXP.

public void RenderMagicXP(int i, int j) {
    ExtendedProperties props = ExtendedProperties.For(Minecraft.getMinecraft().thePlayer);
    if (props.getMagicLevel() > 0) {
        AMVector2 position = getShiftedVector(AMCore.config.getXPBarPosition(), i, j);
        AMVector2 dimensions = new AMVector2(182, 5);
        Minecraft.getMinecraft().renderEngine.bindTexture(mc_gui);
        GL11.glColor4f(0.5f, 0.5f, 1.0f, AMCore.config.showXPAlways() ? 1.0f : AMGuiHelper.instance.getMagicXPBarAlpha());
        //base XP bar
        drawTexturedModalRect_Classic(position.iX, position.iY, 0, 64, dimensions.iX, dimensions.iY, dimensions.iX, dimensions.iY);
        if (props.getMagicXP() > 0) {
            float pctXP = props.getMagicXP() / props.getXPToNextLevel();
            if (pctXP > 1)
                pctXP = 1;
            int width = (int) ((dimensions.iX + 1) * pctXP);
            drawTexturedModalRect_Classic(position.iX, position.iY, 0, 69, width, dimensions.iY, width, dimensions.iY);
        }
        if (AMCore.config.getShowNumerics() && (AMCore.config.showXPAlways() || AMGuiHelper.instance.getMagicXPBarAlpha() > 0)) {
            String xpStr = StatCollector.translateToLocal("am2.gui.xp") + ": " + +(int) (props.getMagicXP() * 100) + "/" + (int) (props.getXPToNextLevel() * 100);
            AMVector2 numericPos = getShiftedVector(AMCore.config.getXPNumericPosition(), i, j);
            Minecraft.getMinecraft().fontRenderer.drawString(xpStr, numericPos.iX, numericPos.iY, 0x999999);
        }
    }
}
Also used : AMVector2(am2.api.math.AMVector2) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 15 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderManaBar.

private void RenderManaBar(int i, int j, FontRenderer fontRenderer) {
    int barWidth = i / 8;
    AMVector2 fatigue_hud = getShiftedVector(AMCore.config.getBurnoutHudPosition(), i, j);
    AMVector2 mana_hud = getShiftedVector(AMCore.config.getManaHudPosition(), i, j);
    float green = 0.5f;
    float blue = 1.0f;
    float red = 0.126f;
    ExtendedProperties props = ExtendedProperties.For(mc.thePlayer);
    //mana bar
    float mana = props.getCurrentMana();
    float bonusMana = props.getBonusCurrentMana();
    float maxMana = props.getMaxMana();
    float fatigueBarWidth = barWidth;
    float fatigue = props.getCurrentFatigue();
    float maxFatigue = props.getMaxFatigue();
    if (mana + bonusMana > maxMana)
        mana = maxMana;
    float progressScaled = (mana / (maxMana + 0.01f));
    if (AMCore.config.showHudBars()) {
        //handle flashing of mana bar
        float flashTimer = AMGuiHelper.instance.getFlashTimer(MANA_BAR_FLASH_SLOT);
        if (flashTimer > 0) {
            green = 0.0f;
            float redShift = 1.0f - red;
            float halfFlash = AMGuiHelper.instance.flashDuration / 2;
            if (flashTimer > halfFlash) {
                float pct = (flashTimer - halfFlash) / halfFlash;
                red += redShift - (redShift * pct);
            } else {
                float pct = flashTimer / halfFlash;
                red += (redShift * pct);
            }
            GL11.glColor3f(red, green, blue);
        } else {
            if (bonusMana > 0)
                GL11.glColor3f(0.2f, 0.9f, 0.6f);
        }
        ItemStack curItem = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
        if (curItem != null && (curItem.getItem() == ItemsCommonProxy.spell || curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook)) {
            ItemStack spellStack = curItem.getItem() == ItemsCommonProxy.spell ? curItem : ((ItemSpellBook) curItem.getItem()).GetActiveItemStack(curItem);
            if (spellStack != null) {
                int[] parts = SpellUtils.instance.getShapeGroupParts(spellStack);
                int sx = mana_hud.iX - 2 * parts.length / 2;
                int sy = mana_hud.iY - 2 * parts.length / 2;
                for (int p : parts) {
                    IIcon icon = SpellIconManager.instance.getIcon(SkillManager.instance.getSkillName(SkillManager.instance.getSkill(p)));
                    if (icon != null) {
                        DrawIconAtXY(icon, "items", sx, sy, false);
                        sx += 3;
                        sy += 3;
                    }
                }
            }
        }
        DrawPartialIconAtXY(AMGuiIcons.manaLevel, progressScaled, 1, mana_hud.iX + 16, mana_hud.iY + 1f, (int) (barWidth * 0.97f), 40, false);
        DrawIconAtXY(AMGuiIcons.manaBar, "items", mana_hud.iX + 15, mana_hud.iY + 3, barWidth, 50, false);
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        progressScaled = (fatigue / (maxFatigue + 0.01f));
        DrawIconAtXY(AMGuiIcons.fatigueIcon, "items", fatigue_hud.iX + barWidth, fatigue_hud.iY, false);
        DrawPartialIconAtXY(AMGuiIcons.fatigueLevel, progressScaled, 1, fatigue_hud.iX, fatigue_hud.iY + 3f, fatigueBarWidth, 40, false);
        DrawIconAtXY(AMGuiIcons.fatigueBar, "items", fatigue_hud.iX, fatigue_hud.iY + 4, barWidth, 48, false);
        green = 0.5f;
        blue = 1.0f;
        red = 0.126f;
        //magic level
        int manaBarColor = Math.round(red * 255);
        manaBarColor = (manaBarColor << 8) + Math.round(green * 255);
        manaBarColor = (manaBarColor << 8) + Math.round(blue * 255);
        String magicLevel = (new StringBuilder()).append("").append(ExtendedProperties.For(mc.thePlayer).getMagicLevel()).toString();
        AMVector2 magicLevelPos = getShiftedVector(AMCore.config.getLevelPosition(), i, j);
        magicLevelPos.iX -= Minecraft.getMinecraft().fontRenderer.getStringWidth(magicLevel) / 2;
        fontRenderer.drawStringWithShadow(magicLevel, magicLevelPos.iX, magicLevelPos.iY, manaBarColor);
        if (flashTimer > 0) {
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
        }
    }
    if (AMCore.config.getShowNumerics()) {
        String manaStr = StatCollector.translateToLocal("am2.gui.mana") + ": " + (int) (mana + bonusMana) + "/" + (int) maxMana;
        String burnoutStr = StatCollector.translateToLocal("am2.gui.burnout") + ": " + (int) props.getCurrentFatigue() + "/" + (int) props.getMaxFatigue();
        AMVector2 manaNumericPos = getShiftedVector(AMCore.config.getManaNumericPosition(), i, j);
        AMVector2 burnoutNumericPos = getShiftedVector(AMCore.config.getBurnoutNumericPosition(), i, j);
        fontRenderer.drawString(manaStr, manaNumericPos.iX, manaNumericPos.iY, bonusMana > 0 ? 0xeae31c : 0x2080FF);
        fontRenderer.drawString(burnoutStr, burnoutNumericPos.iX + 25 - fontRenderer.getStringWidth(burnoutStr), burnoutNumericPos.iY, 0xFF2020);
    }
}
Also used : IIcon(net.minecraft.util.IIcon) AMVector2(am2.api.math.AMVector2) ItemStack(net.minecraft.item.ItemStack) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

ExtendedProperties (am2.playerextensions.ExtendedProperties)26 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 EntityLivingBase (net.minecraft.entity.EntityLivingBase)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 AMVector2 (am2.api.math.AMVector2)3 ItemStack (net.minecraft.item.ItemStack)3 IArmorImbuement (am2.api.items.armor.IArmorImbuement)1 BuffEffectSlowfall (am2.buffs.BuffEffectSlowfall)1 ItemSpellBook (am2.items.ItemSpellBook)1 AMDataWriter (am2.network.AMDataWriter)1 ParticleExpandingCollapsingRingAtPoint (am2.particles.ParticleExpandingCollapsingRingAtPoint)1 AffinityData (am2.playerextensions.AffinityData)1 RiftStorage (am2.playerextensions.RiftStorage)1 SkillData (am2.playerextensions.SkillData)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Minecraft (net.minecraft.client.Minecraft)1 EntityRenderer (net.minecraft.client.renderer.EntityRenderer)1 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)1 EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)1