Search in sources :

Example 61 with EnumDemonWillType

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

the class ItemSentientShovel method recalculatePowers.

public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
    EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
    double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
    this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT);
    int level = getLevel(stack, soulsRemaining);
    double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
    double extraDamage = getExtraDamage(type, level);
    setDrainOfActivatedSword(stack, drain);
    setDamageOfActivatedSword(stack, baseAttackDamage + extraDamage);
    setStaticDropOfActivatedSword(stack, level >= 0 ? staticDrop[level] : 1);
    setDropOfActivatedSword(stack, level >= 0 ? soulDrop[level] : 0);
    setAttackSpeedOfSword(stack, level >= 0 ? getAttackSpeed(type, level) : baseAttackSpeed);
    setHealthBonusOfSword(stack, level >= 0 ? getHealthBonus(type, level) : 0);
    setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0);
    setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 62 with EnumDemonWillType

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

the class RitualLava method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    timer++;
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    int lpDrain = 0;
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    BlockPos pos = masterRitualStone.getBlockPos();
    List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
    double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
    double rawDrained = 0;
    DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
    AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE);
    int maxLavaVolume = getMaxVolumeForRange(LAVA_RANGE, willConfig, holder);
    if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume)) {
        return;
    }
    for (BlockPos newPos : lavaRange.getContainedPositions(pos)) {
        IBlockState state = world.getBlockState(newPos);
        if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state)) {
            int lpCost = getLPCostForRawWill(rawWill);
            if (currentEssence < lpCost) {
                break;
            }
            world.setBlockState(newPos, Blocks.FLOWING_LAVA.getDefaultState());
            currentEssence -= lpCost;
            lpDrain += lpCost;
            if (rawWill > 0) {
                double drain = getWillCostForRawWill(rawWill);
                rawWill -= drain;
                rawDrained += drain;
            }
        }
    }
    if (rawWill > 0) {
        AreaDescriptor chestRange = getBlockRange(LAVA_TANK_RANGE);
        TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0));
        double drain = getWillCostForRawWill(rawWill);
        int lpCost = getLPCostForRawWill(rawWill);
        if (rawWill >= drain && currentEssence >= lpCost) {
            if (tile != null) {
                if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
                    IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
                    double filled = handler.fill(new FluidStack(FluidRegistry.LAVA, 1000), true);
                    double ratio = filled / 1000;
                    rawWill -= drain * ratio;
                    rawDrained += drain * ratio;
                    currentEssence -= Math.ceil(lpCost * ratio);
                    lpDrain += Math.ceil(lpCost * ratio);
                }
            }
        }
    }
    double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
    double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
    double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
    if (vengefulWill >= vengefulWillDrain) {
        double vengefulDrained = 0;
        AreaDescriptor fuseRange = getBlockRange(FIRE_FUSE_RANGE);
        AxisAlignedBB fuseArea = fuseRange.getAABB(pos);
        List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, fuseArea);
        for (EntityLivingBase entity : entities) {
            if (vengefulWill < vengefulWillDrain) {
                break;
            }
            if (entity instanceof EntityPlayer) {
                continue;
            }
            if (!entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) {
                entity.addPotionEffect(new PotionEffect(RegistrarBloodMagic.FIRE_FUSE, 100, 0));
                vengefulDrained += vengefulWillDrain;
                vengefulWill -= vengefulWillDrain;
            }
        }
        if (vengefulDrained > 0) {
            WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrained, true);
        }
    }
    if (steadfastWill >= steadfastWillDrain) {
        double steadfastDrained = 0;
        AreaDescriptor resistRange = getBlockRange(FIRE_RESIST_RANGE);
        int duration = getFireResistForWill(steadfastWill);
        AxisAlignedBB resistArea = resistRange.getAABB(pos);
        List<EntityPlayer> entities = world.getEntitiesWithinAABB(EntityPlayer.class, resistArea);
        for (EntityPlayer entity : entities) {
            if (steadfastWill < steadfastWillDrain) {
                break;
            }
            if (!entity.isPotionActive(MobEffects.FIRE_RESISTANCE) || (entity.getActivePotionEffect(MobEffects.FIRE_RESISTANCE).getDuration() < 2)) {
                entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 100, 0));
                steadfastDrained += steadfastWillDrain;
                steadfastWill -= steadfastWillDrain;
            }
        }
        if (steadfastDrained > 0) {
            WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrained, true);
        }
    }
    if (timer % corrosiveRefreshTime == 0 && corrosiveWill >= corrosiveWillDrain) {
        double corrosiveDrained = 0;
        AreaDescriptor resistRange = getBlockRange(FIRE_DAMAGE_RANGE);
        float damage = getCorrosiveDamageForWill(corrosiveWill);
        AxisAlignedBB damageArea = resistRange.getAABB(pos);
        List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, damageArea);
        for (EntityLivingBase entity : entities) {
            if (corrosiveWill < corrosiveWillDrain) {
                break;
            }
            if (!entity.isDead && entity.hurtTime <= 0 && Utils.isImmuneToFireDamage(entity)) {
                if (entity.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, damage)) {
                    corrosiveDrained += corrosiveWillDrain;
                    corrosiveWill -= corrosiveWillDrain;
                }
            }
        }
        if (corrosiveDrained > 0) {
            WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrained, true);
        }
    }
    if (rawDrained > 0) {
        WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true);
    }
    masterRitualStone.getOwnerNetwork().syphon(lpDrain);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) FluidStack(net.minecraftforge.fluids.FluidStack) World(net.minecraft.world.World) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) DemonWillHolder(WayofTime.bloodmagic.soul.DemonWillHolder) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 63 with EnumDemonWillType

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

the class TileMasterRitualStone method deserialize.

@Override
public void deserialize(NBTTagCompound tag) {
    owner = tag.hasUniqueId("owner") ? tag.getUniqueId("owner") : null;
    if (owner != null)
        cachedNetwork = NetworkHelper.getSoulNetwork(owner);
    currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
    if (currentRitual != null) {
        NBTTagCompound ritualTag = tag.getCompoundTag(Constants.NBT.CURRENT_RITUAL_TAG);
        if (!ritualTag.hasNoTags()) {
            currentRitual.readFromNBT(ritualTag);
        }
    }
    active = tag.getBoolean(Constants.NBT.IS_RUNNING);
    activeTime = tag.getInteger(Constants.NBT.RUNTIME);
    direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
    redstoned = tag.getBoolean(Constants.NBT.IS_REDSTONED);
    for (EnumDemonWillType type : EnumDemonWillType.values()) {
        if (tag.getBoolean("EnumWill" + type)) {
            currentActiveWillConfig.add(type);
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 64 with EnumDemonWillType

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

the class TileDemonPylon method onUpdate.

@Override
public void onUpdate() {
    if (getWorld().isRemote) {
        return;
    }
    for (EnumDemonWillType type : EnumDemonWillType.values()) {
        double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
        for (EnumFacing side : EnumFacing.HORIZONTALS) {
            BlockPos offsetPos = pos.offset(side, 16);
            double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type);
            if (sideAmount > currentAmount) {
                double drainAmount = Math.min((sideAmount - currentAmount) / 2, drainRate);
                double drain = WorldDemonWillHandler.drainWill(getWorld(), offsetPos, type, drainAmount, true);
                WorldDemonWillHandler.fillWill(getWorld(), pos, type, drain, true);
            }
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 65 with EnumDemonWillType

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

the class TileDemonCrystallizer method onUpdate.

@Override
public void onUpdate() {
    if (getWorld().isRemote) {
        return;
    }
    BlockPos offsetPos = pos.offset(EnumFacing.UP);
    if (// Room for a crystal to grow
    getWorld().isAirBlock(offsetPos)) {
        EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(getWorld(), pos);
        double amount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, highestType);
        if (amount >= willToFormCrystal) {
            internalCounter += getCrystalFormationRate(amount);
            if (internalCounter >= totalFormationTime) {
                if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) {
                    if (highestType == EnumDemonWillType.DEFAULT && formRandomSpecialCrystal(offsetPos) || formCrystal(highestType, offsetPos)) {
                        WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, true);
                        internalCounter = 0;
                    }
                }
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) 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