Search in sources :

Example 1 with IDemonWill

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

the class ItemSentientPickaxe method getRandomDemonWillDrop.

@Override
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
    List<ItemStack> soulList = new ArrayList<>();
    if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
        return soulList;
    }
    double willModifier = killedEntity instanceof EntitySlime ? 0.67 : 1;
    IDemonWill soul = ((IDemonWill) RegistrarBloodMagicItems.MONSTER_SOUL);
    EnumDemonWillType type = this.getCurrentType(stack);
    for (int i = 0; i <= looting; i++) {
        if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
            ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
            soulList.add(soulStack);
        }
    }
    return soulList;
}
Also used : IMob(net.minecraft.entity.monster.IMob) EntitySlime(net.minecraft.entity.monster.EntitySlime) IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 2 with IDemonWill

use of WayofTime.bloodmagic.soul.IDemonWill 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)

Example 3 with IDemonWill

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

the class TileSoulForge method consumeSouls.

public double consumeSouls(EnumDemonWillType type, double requested) {
    ItemStack soulStack = getStackInSlot(soulSlot);
    if (soulStack != null) {
        if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) {
            IDemonWill soul = (IDemonWill) soulStack.getItem();
            double souls = soul.drainWill(type, soulStack, requested);
            if (soul.getWill(type, soulStack) <= 0) {
                setInventorySlotContents(soulSlot, ItemStack.EMPTY);
            }
            return souls;
        }
        if (soulStack.getItem() instanceof IDemonWillGem) {
            IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
            return soul.drainWill(type, soulStack, requested, true);
        }
    }
    return 0;
}
Also used : IDemonWillGem(WayofTime.bloodmagic.soul.IDemonWillGem) IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IDemonWill

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

the class ItemSentientAxe method getRandomDemonWillDrop.

@Override
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
    List<ItemStack> soulList = new ArrayList<>();
    if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
        return soulList;
    }
    double willModifier = killedEntity instanceof EntitySlime ? 0.67 : 1;
    IDemonWill soul = ((IDemonWill) RegistrarBloodMagicItems.MONSTER_SOUL);
    EnumDemonWillType type = this.getCurrentType(stack);
    for (int i = 0; i <= looting; i++) {
        if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
            ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
            soulList.add(soulStack);
        }
    }
    return soulList;
}
Also used : IMob(net.minecraft.entity.monster.IMob) EntitySlime(net.minecraft.entity.monster.EntitySlime) IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 5 with IDemonWill

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

the class ItemSentientSword method getRandomDemonWillDrop.

@Override
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
    List<ItemStack> soulList = new ArrayList<>();
    if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
        return soulList;
    }
    double willModifier = killedEntity instanceof EntitySlime ? 0.67 : 1;
    IDemonWill soul = ((IDemonWill) RegistrarBloodMagicItems.MONSTER_SOUL);
    EnumDemonWillType type = this.getCurrentType(stack);
    for (int i = 0; i <= looting; i++) {
        if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
            ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
            soulList.add(soulStack);
        }
    }
    return soulList;
}
Also used : IMob(net.minecraft.entity.monster.IMob) EntitySlime(net.minecraft.entity.monster.EntitySlime) IDemonWill(WayofTime.bloodmagic.soul.IDemonWill) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Aggregations

IDemonWill (WayofTime.bloodmagic.soul.IDemonWill)7 ItemStack (net.minecraft.item.ItemStack)6 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)5 EntitySlime (net.minecraft.entity.monster.EntitySlime)4 IMob (net.minecraft.entity.monster.IMob)4 IDemonWillGem (WayofTime.bloodmagic.soul.IDemonWillGem)2 Slot (net.minecraft.inventory.Slot)1