Search in sources :

Example 1 with OmegaArmour

use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.

the class AlchemicalWizardryEventHooks method omegaUpdateReagentAndHpEvent.

@SubscribeEvent
public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) {
    if (event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        Reagent reagent = APISpellHelper.getPlayerReagentType(player);
        float reagentAmount = APISpellHelper.getPlayerCurrentReagentAmount(player);
        boolean hasReagentChanged = false;
        if (reagentAmount > 0 && OmegaRegistry.hasParadigm(reagent)) {
            int cooldown = APISpellHelper.getPlayerReagentRegenCooldownTag(player);
            boolean canHealHPBar = true;
            if (cooldown > 0) {
                float extra = 0;
                if (player.isPotionActive(AlchemicalWizardry.customPotionSoulHarden)) {
                    extra += 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulHarden).getAmplifier());
                }
                if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) {
                    extra -= 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulFray).getAmplifier());
                }
                int deduction = -1 - (extra >= 0 ? (rand.nextFloat() < extra ? 1 : 0) : (rand.nextFloat() < -extra / 2 ? -1 : 0));
                APISpellHelper.setPlayerReagentRegenCooldownTag(player, Math.max(cooldown + deduction, 0));
                canHealHPBar = false;
            }
            OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
            ReagentRegenConfiguration config = parad.getRegenConfig(player);
            if (parad.isPlayerWearingFullSet(player)) {
                if (canHealHPBar) {
                    int tickRate = config.tickRate;
                    if (player.isPotionActive(Potion.regeneration)) {
                        int i = player.getActivePotionEffect(Potion.regeneration).getAmplifier();
                        double factor = Math.pow(1.5, i + 1);
                        tickRate = Math.max((int) (tickRate / factor), 1);
                    }
                    if (event.entityLiving.worldObj.getWorldTime() % tickRate == 0) {
                        boolean hasHealthChanged = false;
                        int maxHealth = parad.getMaxAdditionalHealth();
                        float health = APISpellHelper.getCurrentAdditionalHP(player);
                        if (health > maxHealth) {
                            health = maxHealth;
                            hasHealthChanged = true;
                        } else if (health < maxHealth) {
                            float addedAmount = Math.min(Math.min((reagentAmount / config.costPerPoint), config.healPerTick), maxHealth - health);
                            float drain = addedAmount * config.costPerPoint;
                            reagentAmount -= drain;
                            hasReagentChanged = true;
                            health += addedAmount;
                            hasHealthChanged = true;
                        }
                        if (player instanceof EntityPlayerMP) {
                            if (hasHealthChanged) {
                                APISpellHelper.setCurrentAdditionalHP(player, health);
                                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(health, maxHealth), (EntityPlayerMP) player);
                            }
                        }
                    }
                }
            } else {
                reagentAmount = 0;
                APISpellHelper.setPlayerMaxReagentAmount(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(null, 0, 0), (EntityPlayerMP) player);
                APISpellHelper.setCurrentAdditionalHP(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
            }
            // Consumes the amount
            float costPerTick = parad.getCostPerTickOfUse(player);
            if (parad.doDrainReagent(player)) {
                if (reagentAmount > costPerTick) {
                    hasReagentChanged = true;
                    reagentAmount = Math.max(0, reagentAmount - costPerTick);
                } else {
                    hasReagentChanged = true;
                    reagentAmount = 0;
                }
            }
            hasReagentChanged = true;
        }
        if (reagentAmount <= 0) {
            boolean hasRevertedArmour = false;
            ItemStack[] armourInventory = player.inventory.armorInventory;
            for (ItemStack stack : armourInventory) {
                if (stack != null && stack.getItem() instanceof OmegaArmour) {
                    ((OmegaArmour) stack.getItem()).revertArmour(player, stack);
                    hasRevertedArmour = true;
                }
            }
            if (hasRevertedArmour) {
                APISpellHelper.setCurrentAdditionalHP(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
            }
        }
        if (player instanceof EntityPlayerMP) {
            if (hasReagentChanged) {
                APISpellHelper.setPlayerCurrentReagentAmount(player, reagentAmount);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(reagent, reagentAmount, APISpellHelper.getPlayerMaxReagentAmount(player)), (EntityPlayerMP) player);
            }
        }
    }
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) OmegaParadigm(WayofTime.alchemicalWizardry.common.omega.OmegaParadigm) ItemStack(net.minecraft.item.ItemStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) ReagentRegenConfiguration(WayofTime.alchemicalWizardry.common.omega.ReagentRegenConfiguration) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with OmegaArmour

use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.

the class OmegaParadigm method setOmegaStalling.

public boolean setOmegaStalling(EntityPlayer player, int duration) {
    ItemStack[] armours = player.inventory.armorInventory;
    ItemStack chestStack = armours[2];
    if (chestStack != null && chestStack.getItem() == this.chestPiece) {
        ((OmegaArmour) chestStack.getItem()).setOmegaStallingDuration(chestStack, duration);
        return true;
    }
    return false;
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) ItemStack(net.minecraft.item.ItemStack)

Example 3 with OmegaArmour

use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.

the class OmegaRegistry method getOmegaParadigmOfWeilder.

public static OmegaParadigm getOmegaParadigmOfWeilder(EntityPlayer player) {
    ItemStack[] armours = player.inventory.armorInventory;
    ItemStack chestStack = armours[2];
    if (chestStack != null && chestStack.getItem() instanceof OmegaArmour) {
        return ((OmegaArmour) chestStack.getItem()).getOmegaParadigm();
    }
    return null;
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) ItemStack(net.minecraft.item.ItemStack)

Example 4 with OmegaArmour

use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.

the class AlchemicalWizardry method initReagentRegistries.

public static void initReagentRegistries() {
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.sanctus), new ReagentStack(ReagentRegistry.sanctusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.incendium), new ReagentStack(ReagentRegistry.incendiumReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aquasalus), new ReagentStack(ReagentRegistry.aquasalusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.magicales), new ReagentStack(ReagentRegistry.magicalesReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aether), new ReagentStack(ReagentRegistry.aetherReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crepitous), new ReagentStack(ReagentRegistry.crepitousReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crystallos), new ReagentStack(ReagentRegistry.crystallosReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.terrae), new ReagentStack(ReagentRegistry.terraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.tennebrae), new ReagentStack(ReagentRegistry.tenebraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 0), new ReagentStack(ReagentRegistry.offensaReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 1), new ReagentStack(ReagentRegistry.praesidiumReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 2), new ReagentStack(ReagentRegistry.orbisTerraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 6), new ReagentStack(ReagentRegistry.virtusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 7), new ReagentStack(ReagentRegistry.reductusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 8), new ReagentStack(ReagentRegistry.potentiaReagent, 1000));
    OmegaRegistry.registerParadigm(ReagentRegistry.aquasalusReagent, new OmegaParadigmWater((OmegaArmour) ModItems.boundHelmetWater, (OmegaArmour) ModItems.boundPlateWater, (OmegaArmour) ModItems.boundLeggingsWater, (OmegaArmour) ModItems.boundBootsWater));
    OmegaRegistry.registerParadigm(ReagentRegistry.terraeReagent, new OmegaParadigmEarth((OmegaArmour) ModItems.boundHelmetEarth, (OmegaArmour) ModItems.boundPlateEarth, (OmegaArmour) ModItems.boundLeggingsEarth, (OmegaArmour) ModItems.boundBootsEarth));
    OmegaRegistry.registerParadigm(ReagentRegistry.aetherReagent, new OmegaParadigmWind((OmegaArmour) ModItems.boundHelmetWind, (OmegaArmour) ModItems.boundPlateWind, (OmegaArmour) ModItems.boundLeggingsWind, (OmegaArmour) ModItems.boundBootsWind));
    OmegaRegistry.registerParadigm(ReagentRegistry.incendiumReagent, new OmegaParadigmFire((OmegaArmour) ModItems.boundHelmetFire, (OmegaArmour) ModItems.boundPlateFire, (OmegaArmour) ModItems.boundLeggingsFire, (OmegaArmour) ModItems.boundBootsFire));
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) OmegaParadigmWind(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWind) OmegaParadigmWater(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWater) OmegaParadigmEarth(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmEarth) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ItemStack(net.minecraft.item.ItemStack) OmegaParadigmFire(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmFire)

Example 5 with OmegaArmour

use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.

the class RenderHelper method onTickInGame.

public static boolean onTickInGame(Minecraft mc) {
    if (enabled && (mc.inGameHasFocus || mc.currentScreen == null || (mc.currentScreen instanceof GuiChat && showInChat)) && !mc.gameSettings.showDebugInfo) {
        EntityPlayer player = mc.thePlayer;
        player.getEntityData();
        if (SpellHelper.canPlayerSeeAlchemy(player)) {
            GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
            displayArmorStatus(mc);
            GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        }
        ItemStack stack = player.inventory.armorItemInSlot(2);
        if (stack != null && stack.getItem() instanceof OmegaArmour) {
            int maxAmount = (int) APISpellHelper.getPlayerMaxReagentAmount(player);
            if (maxAmount > 0) {
                float val = APISpellHelper.getPlayerCurrentReagentAmount(player);
                ReagentStack reagentStack = new ReagentStack(APISpellHelper.getPlayerReagentType(player), (int) val);
                if (reagentStack != null && reagentStack.amount > 0) {
                    renderTestHUD(mc, reagentStack, maxAmount);
                }
            }
        }
        if (SpellHelper.canPlayerSeeLPBar(player)) {
            int max = APISpellHelper.getPlayerMaxLPTag(player);
            if (max > 1) {
                renderLPHUD(mc, APISpellHelper.getPlayerLPTag(player), max);
            }
        }
        float maxHP = APISpellHelper.getCurrentAdditionalMaxHP(player);
        // System.out.println("MaxHP: " + maxHP);
        if (maxHP > 0) {
            renderHPHUD(mc, APISpellHelper.getCurrentAdditionalHP(player), maxHP);
        }
    }
    return true;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GuiChat(net.minecraft.client.gui.GuiChat) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

OmegaArmour (WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour)6 ItemStack (net.minecraft.item.ItemStack)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)2 ReagentStack (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)2 OmegaParadigm (WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 OmegaParadigmEarth (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmEarth)1 OmegaParadigmFire (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmFire)1 OmegaParadigmWater (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWater)1 OmegaParadigmWind (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWind)1 ReagentRegenConfiguration (WayofTime.alchemicalWizardry.common.omega.ReagentRegenConfiguration)1 GuiChat (net.minecraft.client.gui.GuiChat)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1