Made the aspected Sentient Tools drop their corresponding Will type on killing enemies. #753
This commit is contained in:
parent
6c4fe34152
commit
655c2880dc
13 changed files with 103 additions and 42 deletions
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.soul;
|
|||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
|
@ -13,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -21,7 +23,7 @@ import java.util.List;
|
|||
|
||||
public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider
|
||||
{
|
||||
public static String[] names = { "base" };
|
||||
public static String[] names = { "base", "corrosive", "destructive", "vengeful", "steadfast" };
|
||||
|
||||
public ItemMonsterSoul()
|
||||
{
|
||||
|
@ -53,14 +55,25 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(stack)));
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(getType(stack), stack)));
|
||||
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(ItemStack soulStack)
|
||||
public EnumDemonWillType getType(ItemStack stack)
|
||||
{
|
||||
return EnumDemonWillType.values()[stack.getItemDamage() % 5];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulStack)
|
||||
{
|
||||
if (type != this.getType(soulStack))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
NBTTagCompound tag = soulStack.getTagCompound();
|
||||
|
@ -69,22 +82,24 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setWill(ItemStack soulStack, double souls)
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls)
|
||||
{
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
NBTTagCompound tag = soulStack.getTagCompound();
|
||||
|
||||
soulStack.setItemDamage(type.ordinal());
|
||||
|
||||
tag.setDouble(Constants.NBT.SOULS, souls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(ItemStack soulStack, double drainAmount)
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount)
|
||||
{
|
||||
double souls = getWill(soulStack);
|
||||
double souls = getWill(type, soulStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
setWill(soulStack, souls - soulsDrained);
|
||||
setWill(type, soulStack, souls - soulsDrained);
|
||||
|
||||
return soulsDrained;
|
||||
}
|
||||
|
@ -92,8 +107,8 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
@Override
|
||||
public ItemStack createWill(int meta, double number)
|
||||
{
|
||||
ItemStack soulStack = new ItemStack(this, 1, meta);
|
||||
setWill(soulStack, number);
|
||||
ItemStack soulStack = new ItemStack(this, 1, meta % 5);
|
||||
setWill(getType(soulStack), soulStack, number);
|
||||
return soulStack;
|
||||
}
|
||||
|
||||
|
@ -101,7 +116,11 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=monstersoul"));
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
String name = names[i];
|
||||
ret.add(new ImmutablePair<Integer, String>(i, "type=" + name));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,11 +374,13 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
|
||||
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
|
||||
{
|
||||
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,11 +374,13 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
|
||||
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
|
||||
{
|
||||
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,11 +374,13 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
|
||||
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
|
||||
{
|
||||
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,11 +346,13 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
|
||||
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
|
||||
{
|
||||
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
|
||||
{
|
||||
EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
|
||||
if (thisType != EnumDemonWillType.DEFAULT)
|
||||
if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack))
|
||||
{
|
||||
return soulStack;
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
|
||||
if (soulsLeft < getMaxWill(thisType, soulGemStack))
|
||||
{
|
||||
double newSoulsLeft = Math.min(soulsLeft + soul.getWill(soulStack), getMaxWill(thisType, soulGemStack));
|
||||
soul.drainWill(soulStack, newSoulsLeft - soulsLeft);
|
||||
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(soulStack) <= 0)
|
||||
if (soul.getWill(thisType, soulStack) <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue