Added infrastructure and rendering for the Soul Arrow.

This commit is contained in:
WayofTime 2016-01-08 22:20:31 -05:00
parent 22a0e2b8a9
commit 1d6edae50e
11 changed files with 300 additions and 0 deletions

View file

@ -24,6 +24,8 @@ public interface ISoulGem
*/
public double getSouls(ItemStack soulGemStack);
public void setSouls(ItemStack soulGemStack, double amount);
public int getMaxSouls(ItemStack soulGemStack);
public double drainSouls(ItemStack stack, double drainAmount);

View file

@ -112,4 +112,32 @@ public class PlayerSoulHandler
return soulStack;
}
public static double addSouls(EntityPlayer player, double amount)
{
ItemStack[] inventory = player.inventory.mainInventory;
double remaining = amount;
for (int i = 0; i < inventory.length; i++)
{
ItemStack stack = inventory[i];
if (stack != null)
{
if (stack.getItem() instanceof ISoulGem)
{
double souls = ((ISoulGem) stack.getItem()).getSouls(stack);
double fill = Math.min(((ISoulGem) stack.getItem()).getMaxSouls(stack) - souls, remaining);
((ISoulGem) stack.getItem()).setSouls(stack, fill + souls);
remaining -= fill;
if (remaining <= 0)
{
break;
}
}
}
}
return amount - remaining;
}
}