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;
}
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);
}
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);
}
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());
}
}
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;
}
Aggregations