Search in sources :

Example 26 with EnumDemonWillType

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

the class ItemSoulGem method getRGBDurabilityForDisplay.

@Override
public int getRGBDurabilityForDisplay(ItemStack stack) {
    EnumDemonWillType type = this.getCurrentType(stack);
    double maxWill = getMaxWill(type, stack);
    if (maxWill <= 0) {
        return 1;
    }
    return MathHelper.hsvToRGB(Math.max(0.0F, (float) (getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 27 with EnumDemonWillType

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

the class ItemSoulGem method drainWill.

@Override
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain) {
    EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
    if (currentType != type) {
        return 0;
    }
    double souls = getWill(type, soulGemStack);
    double soulsDrained = Math.min(drainAmount, souls);
    if (doDrain) {
        setWill(type, soulGemStack, souls - soulsDrained);
    }
    return soulsDrained;
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 28 with EnumDemonWillType

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

the class ItemSoulGem method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    if (!stack.hasTagCompound())
        return;
    EnumDemonWillType type = this.getCurrentType(stack);
    tooltip.add(TextHelper.localize("tooltip.bloodmagic.soulGem." + names[stack.getItemDamage()]));
    tooltip.add(TextHelper.localize("tooltip.bloodmagic.will", getWill(type, stack)));
    tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentType." + getCurrentType(stack).getName().toLowerCase()));
    super.addInformation(stack, world, tooltip, flag);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 29 with EnumDemonWillType

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

the class ItemSoulGem method getSubItems.

@Override
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
    if (!isInCreativeTab(creativeTab))
        return;
    for (int i = 0; i < names.length; i++) {
        ItemStack emptyStack = new ItemStack(this, 1, i);
        list.add(emptyStack);
    }
    for (EnumDemonWillType type : EnumDemonWillType.values()) {
        for (int i = 0; i < names.length; i++) {
            ItemStack fullStack = new ItemStack(this, 1, i);
            setWill(type, fullStack, getMaxWill(EnumDemonWillType.DEFAULT, fullStack));
            list.add(fullStack);
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 30 with EnumDemonWillType

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

the class RitualGreenGrove method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    BlockPos pos = masterRitualStone.getBlockPos();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    int maxGrowths = currentEssence / getRefreshCost();
    int totalGrowths = 0;
    List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
    DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
    double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, 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);
    double growthChance = getPlantGrowthChanceForWill(vengefulWill);
    boolean consumeRawWill = rawWill >= rawWillDrain && refreshTime != defaultRefreshTime;
    boolean consumeVengefulWill = vengefulWill >= vengefulWillDrain && growthChance != defaultGrowthChance;
    double rawDrain = 0;
    double vengefulDrain = 0;
    AreaDescriptor growingRange = getBlockRange(GROW_RANGE);
    int maxGrowthVolume = getMaxVolumeForRange(GROW_RANGE, willConfig, holder);
    if (!growingRange.isWithinRange(getMaxVerticalRadiusForRange(GROW_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(GROW_RANGE, willConfig, holder)) || (maxGrowthVolume != 0 && growingRange.getVolume() > maxGrowthVolume)) {
        return;
    }
    for (BlockPos newPos : growingRange.getContainedPositions(pos)) {
        IBlockState state = world.getBlockState(newPos);
        if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) {
            if (state.getBlock() instanceof IGrowable) {
                if (world.rand.nextDouble() < growthChance) {
                    state.getBlock().updateTick(world, newPos, state, new Random());
                    IBlockState newState = world.getBlockState(newPos);
                    if (!newState.equals(state)) {
                        totalGrowths++;
                        if (consumeRawWill) {
                            rawWill -= rawWillDrain;
                            rawDrain += rawWillDrain;
                        }
                        if (consumeVengefulWill) {
                            vengefulWill -= vengefulWillDrain;
                            vengefulDrain += vengefulWillDrain;
                        }
                    }
                }
            }
        }
        if (totalGrowths >= maxGrowths || (consumeRawWill && rawWill < rawWillDrain) || (consumeVengefulWill && vengefulWill < vengefulWillDrain)) {
            break;
        }
    }
    if (rawDrain > 0) {
        WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true);
    }
    if (vengefulDrain > 0) {
        WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true);
    }
    AreaDescriptor hydrateRange = getBlockRange(HYDRATE_RANGE);
    double steadfastDrain = 0;
    if (steadfastWill > steadfastWillDrain) {
        AxisAlignedBB aabb = hydrateRange.getAABB(pos);
        steadfastDrain += steadfastWillDrain * Utils.plantSeedsInArea(world, aabb, 2, 1);
        steadfastWill -= steadfastDrain;
        for (BlockPos newPos : hydrateRange.getContainedPositions(pos)) {
            if (steadfastWill < steadfastWillDrain) {
                break;
            }
            IBlockState state = world.getBlockState(newPos);
            Block block = state.getBlock();
            boolean hydratedBlock = false;
            if (block == Blocks.DIRT || block == Blocks.GRASS) {
                world.setBlockState(newPos, farmlandState);
                hydratedBlock = true;
            } else if (block == Blocks.FARMLAND) {
                int meta = block.getMetaFromState(state);
                if (meta < 7) {
                    world.setBlockState(newPos, farmlandState);
                    hydratedBlock = true;
                }
            }
            if (hydratedBlock) {
                steadfastWill -= steadfastWillDrain;
                steadfastDrain += steadfastWillDrain;
            }
        }
    }
    if (steadfastDrain > 0) {
        WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrain, true);
    }
    double corrosiveDrain = 0;
    if (corrosiveWill > corrosiveWillDrain) {
        AreaDescriptor leechRange = getBlockRange(LEECH_RANGE);
        AxisAlignedBB mobArea = leechRange.getAABB(pos);
        List<EntityLivingBase> entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, mobArea);
        for (EntityLivingBase entityLiving : entityList) {
            if (corrosiveWill < corrosiveWillDrain) {
                break;
            }
            if (entityLiving instanceof EntityPlayer) {
                continue;
            }
            if (entityLiving.isPotionActive(RegistrarBloodMagic.PLANT_LEECH) || !entityLiving.isPotionApplicable(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH))) {
                continue;
            }
            entityLiving.addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH, 200, 0));
            corrosiveWill -= corrosiveWillDrain;
            corrosiveDrain += corrosiveWillDrain;
        }
        if (corrosiveDrain > 0) {
            WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost());
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) World(net.minecraft.world.World) Random(java.util.Random) IGrowable(net.minecraft.block.IGrowable) EntityLivingBase(net.minecraft.entity.EntityLivingBase) DemonWillHolder(WayofTime.bloodmagic.soul.DemonWillHolder) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) 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