Search in sources :

Example 46 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class ItemSoulGem method getDurabilityForDisplay.

@Override
public double getDurabilityForDisplay(ItemStack stack) {
    EnumDemonWillType type = this.getCurrentType(stack);
    double maxWill = getMaxWill(type, stack);
    if (maxWill <= 0) {
        return 1;
    }
    return 1.0 - (getWill(type, stack) / maxWill);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 47 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class ItemSoulGem method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    EnumDemonWillType type = this.getCurrentType(stack);
    double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
    double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
    this.drainWill(type, stack, filled, true);
    return new ActionResult<>(EnumActionResult.PASS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 48 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class ItemSentientSword method hitEntity.

@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
    if (super.hitEntity(stack, target, attacker)) {
        if (attacker instanceof EntityPlayer) {
            EntityPlayer attackerPlayer = (EntityPlayer) attacker;
            this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
            EnumDemonWillType type = this.getCurrentType(stack);
            double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer);
            int willBracket = this.getLevel(stack, will);
            applyEffectToEntity(type, willBracket, target, attackerPlayer);
            ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
            if (offStack.getItem() instanceof ISentientSwordEffectProvider) {
                ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
                if (provider.providesEffectForWill(type)) {
                    provider.applyOnHitEffect(type, stack, offStack, attacker, target);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISentientSwordEffectProvider(WayofTime.bloodmagic.iface.ISentientSwordEffectProvider) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) ItemStack(net.minecraft.item.ItemStack)

Example 49 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType 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 50 with EnumDemonWillType

use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.

the class TileMasterRitualStone method serialize.

@Override
public NBTTagCompound serialize(NBTTagCompound tag) {
    String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
    if (owner != null)
        tag.setUniqueId("owner", owner);
    tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
    if (currentRitual != null) {
        NBTTagCompound ritualTag = new NBTTagCompound();
        currentRitual.writeToNBT(ritualTag);
        tag.setTag(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag);
    }
    tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
    tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
    tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
    tag.setBoolean(Constants.NBT.IS_REDSTONED, redstoned);
    for (EnumDemonWillType type : currentActiveWillConfig) {
        tag.setBoolean("EnumWill" + type, true);
    }
    return tag;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Aggregations

EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)65 ItemStack (net.minecraft.item.ItemStack)21 BlockPos (net.minecraft.util.math.BlockPos)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 World (net.minecraft.world.World)13 PotionEffect (net.minecraft.potion.PotionEffect)6 TileEntity (net.minecraft.tileentity.TileEntity)6 EntitySentientSpecter (WayofTime.bloodmagic.entity.mob.EntitySentientSpecter)5 IDemonWill (WayofTime.bloodmagic.soul.IDemonWill)5 IBlockState (net.minecraft.block.state.IBlockState)5 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 ISentientSwordEffectProvider (WayofTime.bloodmagic.iface.ISentientSwordEffectProvider)4 DemonWillHolder (WayofTime.bloodmagic.soul.DemonWillHolder)4 EntitySlime (net.minecraft.entity.monster.EntitySlime)4 IMob (net.minecraft.entity.monster.IMob)4 ArrayList (java.util.ArrayList)3 EntitySentientArrow (WayofTime.bloodmagic.entity.projectile.EntitySentientArrow)2 IDiscreteDemonWill (WayofTime.bloodmagic.soul.IDiscreteDemonWill)2 List (java.util.List)2