Search in sources :

Example 11 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class StatTrackerHandler method onExperiencePickup.

// Tracks: Experienced
@SubscribeEvent(priority = EventPriority.LOW)
public static void onExperiencePickup(PlayerPickupXpEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.experienced", chestStack);
            if (upgrade instanceof LivingArmourUpgradeExperience) {
                double modifier = ((LivingArmourUpgradeExperience) upgrade).getExperienceModifier();
                double exp = event.getOrb().xpValue * (1 + modifier);
                event.getOrb().xpValue = (int) Math.floor(exp) + (Math.random() < exp % 1 ? 1 : 0);
            }
            StatTrackerExperience.incrementCounter(armour, event.getOrb().xpValue);
        }
    }
}
Also used : LivingArmourUpgradeExperience(WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 12 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class RitualFeatheredKnife method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    BlockPos pos = masterRitualStone.getBlockPos();
    List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
    double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
    double destructiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DESTRUCTIVE, willConfig);
    double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
    double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
    double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
    refreshTime = getRefreshTimeForRawWill(rawWill);
    boolean consumeRawWill = rawWill >= rawWillDrain && refreshTime != defaultRefreshTime;
    int maxEffects = currentEssence / getRefreshCost();
    int totalEffects = 0;
    BlockPos altarPos = pos.add(altarOffsetPos);
    TileEntity tile = world.getTileEntity(altarPos);
    AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE);
    if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof IBloodAltar)) {
        for (BlockPos newPos : altarRange.getContainedPositions(pos)) {
            TileEntity nextTile = world.getTileEntity(newPos);
            if (nextTile instanceof IBloodAltar) {
                tile = nextTile;
                altarOffsetPos = newPos.subtract(pos);
                altarRange.resetCache();
                break;
            }
        }
    }
    boolean useIncense = corrosiveWill >= corrosiveWillThreshold;
    if (tile instanceof IBloodAltar) {
        IBloodAltar tileAltar = (IBloodAltar) tile;
        AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE);
        AxisAlignedBB range = damageRange.getAABB(pos);
        double destructiveDrain = 0;
        List<EntityPlayer> entities = world.getEntitiesWithinAABB(EntityPlayer.class, range);
        for (EntityPlayer player : entities) {
            float healthThreshold = steadfastWill >= steadfastWillThreshold ? 0.7f : 0.3f;
            if (vengefulWill >= vengefulWillThreshold && !player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
                healthThreshold = 0.1f;
            }
            float health = player.getHealth();
            float maxHealth = player.getMaxHealth();
            float sacrificedHealth = 1;
            double lpModifier = 1;
            if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(RegistrarBloodMagic.SOUL_FRAY))) {
                if (useIncense) {
                    double incenseAmount = PlayerSacrificeHelper.getPlayerIncense(player);
                    sacrificedHealth = health - maxHealth * healthThreshold;
                    lpModifier *= PlayerSacrificeHelper.getModifier(incenseAmount);
                    PlayerSacrificeHelper.setPlayerIncense(player, 0);
                    player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, PlayerSacrificeHelper.soulFrayDuration));
                }
                if (destructiveWill >= destructiveWillDrain * sacrificedHealth) {
                    lpModifier *= getLPModifierForWill(destructiveWill);
                    destructiveWill -= destructiveWillDrain * sacrificedHealth;
                    destructiveDrain += destructiveWillDrain * sacrificedHealth;
                }
                if (LivingArmour.hasFullSet(player)) {
                    ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
                    LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
                    if (armour != null) {
                        LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack);
                        if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) {
                            double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
                            lpModifier *= (1 + modifier);
                        }
                    }
                }
                player.setHealth(health - sacrificedHealth);
                tileAltar.sacrificialDaggerCall((int) (ConfigHandler.values.sacrificialDaggerConversion * lpModifier * sacrificedHealth), false);
                totalEffects++;
                if (totalEffects >= maxEffects) {
                    break;
                }
            }
        }
        if (destructiveDrain > 0) {
            WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, destructiveDrain, true);
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
    if (totalEffects > 0 && consumeRawWill) {
        WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingArmourUpgradeSelfSacrifice(WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) PotionEffect(net.minecraft.potion.PotionEffect) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) World(net.minecraft.world.World) IBloodAltar(WayofTime.bloodmagic.altar.IBloodAltar) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) ItemStack(net.minecraft.item.ItemStack)

Example 13 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class RitualArmourEvolve method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    if (world.isRemote) {
        return;
    }
    BlockPos pos = masterRitualStone.getBlockPos();
    AreaDescriptor checkRange = getBlockRange(CHECK_RANGE);
    List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos));
    for (EntityPlayer player : playerList) {
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                if (armour.maxUpgradePoints < 300) {
                    armour.maxUpgradePoints = 300;
                    ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
                    masterRitualStone.setActive(false);
                    world.spawnEntity(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true));
                }
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 14 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class GenericHandler method selfSacrificeEvent.

@SubscribeEvent
public static void selfSacrificeEvent(SacrificeKnifeUsedEvent event) {
    EntityPlayer player = event.player;
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            StatTrackerSelfSacrifice.incrementCounter(armour, event.healthDrained / 2);
            LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack);
            if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) {
                double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
                event.lpAdded = (int) (event.lpAdded * (1 + modifier));
            }
        }
    }
}
Also used : LivingArmourUpgradeSelfSacrifice(WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 15 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class StatTrackerHandler method entityHurt.

// Tracks: Fall Protect, Arrow Protect, Physical Protect, Grave Digger, Sprint Attack, Critical Strike, Nocturnal Prowess
@SubscribeEvent
public static void entityHurt(LivingHurtEvent event) {
    DamageSource source = event.getSource();
    Entity sourceEntity = event.getSource().getTrueSource();
    EntityLivingBase attackedEntity = event.getEntityLiving();
    if (attackedEntity instanceof EntityPlayer) {
        EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity;
        // Living Armor Handling
        if (LivingArmour.hasFullSet(attackedPlayer)) {
            float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.getSource(), event.getAmount()), attackedPlayer.getHealth());
            ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile())
                    StatTrackerPhysicalProtect.incrementCounter(armour, amount);
                if (source.equals(DamageSource.FALL))
                    StatTrackerFallProtect.incrementCounter(armour, amount);
                if (source.isProjectile())
                    StatTrackerArrowProtect.incrementCounter(armour, amount);
            }
        } else {
            ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            if (chestStack.getItem() instanceof ItemSentientArmour) {
                ItemSentientArmour armour = (ItemSentientArmour) chestStack.getItem();
                armour.onPlayerAttacked(chestStack, source, attackedPlayer);
            }
        }
    }
    if (sourceEntity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sourceEntity;
        // Living Armor Handling
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                ItemStack mainWeapon = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
                event.setAmount((float) (event.getAmount() + lastPlayerSwingStrength * armour.getAdditionalDamageOnHit(event.getAmount(), player, attackedEntity, mainWeapon)));
                float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.getSource(), event.getAmount()), attackedEntity.getHealth());
                if (!source.isProjectile()) {
                    StatTrackerMeleeDamage.incrementCounter(armour, amount);
                    if (player.getEntityWorld().getLight(player.getPosition()) <= 9)
                        StatTrackerNightSight.incrementCounter(armour, amount);
                    if (mainWeapon.getItem() instanceof ItemSpade)
                        StatTrackerGraveDigger.incrementCounter(armour, amount);
                    if (player.isSprinting())
                        StatTrackerSprintAttack.incrementCounter(armour, amount);
                    boolean isCritical = lastPlayerSwingStrength > 0.9 && player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(MobEffects.BLINDNESS) && !player.isRiding() && !player.isSprinting();
                    if (isCritical)
                        StatTrackerCriticalStrike.incrementCounter(armour, amount);
                    double kb = armour.getKnockbackOnHit(player, attackedEntity, mainWeapon);
                    if (kb > 0)
                        attackedEntity.knockBack(player, (float) kb * 0.5F, (double) MathHelper.sin(player.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(player.rotationYaw * 0.017453292F)));
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) DamageSource(net.minecraft.util.DamageSource) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemSpade(net.minecraft.item.ItemSpade) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ItemSentientArmour(WayofTime.bloodmagic.item.armour.ItemSentientArmour) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)25 ItemStack (net.minecraft.item.ItemStack)22 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)20 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)18 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 World (net.minecraft.world.World)5 BlockPos (net.minecraft.util.math.BlockPos)4 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)3 StatTracker (WayofTime.bloodmagic.livingArmour.StatTracker)2 StatTrackerGrimReaperSprint (WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint)2 LivingArmourUpgradeSelfSacrifice (WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityArrow (net.minecraft.entity.projectile.EntityArrow)2 PotionEffect (net.minecraft.potion.PotionEffect)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IBloodAltar (WayofTime.bloodmagic.altar.IBloodAltar)1 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 ItemSentientArmour (WayofTime.bloodmagic.item.armour.ItemSentientArmour)1