Search in sources :

Example 1 with IBloodAltar

use of WayofTime.bloodmagic.altar.IBloodAltar in project BloodMagic by WayofTime.

the class ItemPackSacrifice method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (world.isRemote)
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    RayTraceResult rayTrace = this.rayTrace(world, player, false);
    if (rayTrace == null) {
        return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
    } else {
        if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
            TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
            if (!(tile instanceof IBloodAltar))
                return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
            LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, rayTrace.getBlockPos());
        }
    }
    return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) IBloodAltar(WayofTime.bloodmagic.altar.IBloodAltar)

Example 2 with IBloodAltar

use of WayofTime.bloodmagic.altar.IBloodAltar in project BloodMagic by WayofTime.

the class PlayerSacrificeHelper method findAndFillAltar.

/**
 * Finds the nearest {@link IBloodAltar} and attempts to fill it
 *
 * @param world             - The world
 * @param sacrificingEntity - The entity having the sacrifice done on (can be
 *                          {@link EntityPlayer} for self-sacrifice)
 * @param amount            - The amount of which the altar should be filled
 * @param isSacrifice       - Whether this is a Sacrifice or a Self-Sacrifice
 * @return Whether the altar is found and (attempted) filled
 */
public static boolean findAndFillAltar(World world, EntityLivingBase sacrificingEntity, int amount, boolean isSacrifice) {
    IBloodAltar altarEntity = getAltar(world, sacrificingEntity.getPosition());
    if (altarEntity == null)
        return false;
    altarEntity.sacrificialDaggerCall(amount, isSacrifice);
    altarEntity.startCycle();
    return true;
}
Also used : IBloodAltar(WayofTime.bloodmagic.altar.IBloodAltar)

Example 3 with IBloodAltar

use of WayofTime.bloodmagic.altar.IBloodAltar in project BloodMagic by WayofTime.

the class ItemPackSelfSacrifice method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (world.isRemote)
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    RayTraceResult position = this.rayTrace(world, player, false);
    if (position == null) {
        return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
    } else {
        if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
            TileEntity tile = world.getTileEntity(position.getBlockPos());
            if (!(tile instanceof IBloodAltar))
                return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
            LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos());
        }
    }
    return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) IBloodAltar(WayofTime.bloodmagic.altar.IBloodAltar)

Example 4 with IBloodAltar

use of WayofTime.bloodmagic.altar.IBloodAltar 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)

Aggregations

IBloodAltar (WayofTime.bloodmagic.altar.IBloodAltar)4 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)1 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)1 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)1 LivingArmourUpgradeSelfSacrifice (WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice)1 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1