Added infrastructure and rendering for the Soul Arrow.
This commit is contained in:
parent
22a0e2b8a9
commit
1d6edae50e
11 changed files with 300 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue