Search in sources :

Example 21 with EnumDemonWillType

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

the class ItemSentientAxe 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 22 with EnumDemonWillType

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

the class ItemSentientPickaxe method onLeftClickEntity.

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    recalculatePowers(stack, player.getEntityWorld(), player);
    double drain = this.getDrainOfActivatedSword(stack);
    if (drain > 0) {
        EnumDemonWillType type = getCurrentType(stack);
        double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
        if (drain > soulsRemaining) {
            return false;
        } else {
            PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
        }
    }
    return super.onLeftClickEntity(stack, player, entity);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 23 with EnumDemonWillType

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

the class ItemSentientSword method onLeftClickEntity.

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    recalculatePowers(stack, player.getEntityWorld(), player);
    double drain = this.getDrainOfActivatedSword(stack);
    if (drain > 0) {
        EnumDemonWillType type = getCurrentType(stack);
        double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
        if (drain > soulsRemaining) {
            return false;
        } else {
            PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
        }
    }
    return super.onLeftClickEntity(stack, player, entity);
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 24 with EnumDemonWillType

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

the class ItemSoulGem method gatherVariants.

@Override
public void gatherVariants(Consumer<String> variants) {
    for (EnumDemonWillType type : EnumDemonWillType.values()) {
        variants.accept("type=petty_" + type.getName().toLowerCase());
        variants.accept("type=lesser_" + type.getName().toLowerCase());
        variants.accept("type=common_" + type.getName().toLowerCase());
        variants.accept("type=greater_" + type.getName().toLowerCase());
        variants.accept("type=grand_" + type.getName().toLowerCase());
    }
}
Also used : EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 25 with EnumDemonWillType

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

the class ItemSoulGem method fillDemonWillGem.

@Override
public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack) {
    if (soulStack != null && soulStack.getItem() instanceof IDemonWill) {
        EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
        if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack)) {
            return soulStack;
        }
        IDemonWill soul = (IDemonWill) soulStack.getItem();
        double soulsLeft = getWill(thisType, soulGemStack);
        if (soulsLeft < getMaxWill(thisType, soulGemStack)) {
            double newSoulsLeft = Math.min(soulsLeft + soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack));
            soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft);
            setWill(thisType, soulGemStack, newSoulsLeft);
            if (soul.getWill(thisType, soulStack) <= 0) {
                return ItemStack.EMPTY;
            }
        }
    }
    return soulStack;
}
Also used : IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) 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