Created fillWill method for the tartaric gem.
This commit is contained in:
parent
b818939a9c
commit
a88d7f43b8
|
@ -27,4 +27,6 @@ public interface IDemonWillGem
|
||||||
public int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
|
public int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||||
|
|
||||||
public double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount);
|
public double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount);
|
||||||
|
|
||||||
|
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,10 +154,7 @@ public class PlayerDemonWillHandler
|
||||||
{
|
{
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
double souls = ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining);
|
||||||
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(type, stack) - souls, remaining);
|
|
||||||
((IDemonWillGem) stack.getItem()).setWill(type, stack, fill + souls);
|
|
||||||
remaining -= fill;
|
|
||||||
|
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
{
|
{
|
||||||
|
@ -182,10 +179,7 @@ public class PlayerDemonWillHandler
|
||||||
{
|
{
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
double souls = ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining);
|
||||||
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(type, stack) - souls, remaining);
|
|
||||||
((IDemonWillGem) stack.getItem()).setWill(type, stack, fill + souls);
|
|
||||||
remaining -= fill;
|
|
||||||
|
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,4 +200,26 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
|
|
||||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount)
|
||||||
|
{
|
||||||
|
if (!type.equals(getCurrentType(stack)))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double current = this.getWill(type, stack);
|
||||||
|
double maxWill = this.getMaxWill(type, stack);
|
||||||
|
|
||||||
|
double filled = Math.min(fillAmount, maxWill - current);
|
||||||
|
|
||||||
|
if (filled > 0)
|
||||||
|
{
|
||||||
|
this.setWill(type, stack, filled + current);
|
||||||
|
return filled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,10 +81,10 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
|
||||||
if (willMap.containsKey(type))
|
if (willMap.containsKey(type))
|
||||||
{
|
{
|
||||||
double current = willMap.get(type);
|
double current = willMap.get(type);
|
||||||
double fillAmount = Math.min(gemDrainRate, Math.min(current, gemItem.getMaxWill(type, stack) - gemItem.getWill(type, stack)));
|
double fillAmount = Math.min(gemDrainRate, current);
|
||||||
if (fillAmount > 0)
|
if (fillAmount > 0)
|
||||||
{
|
{
|
||||||
gemItem.setWill(type, stack, fillAmount + gemItem.getWill(type, stack));
|
fillAmount = gemItem.fillWill(type, stack, fillAmount);
|
||||||
if (willMap.get(type) - fillAmount <= 0)
|
if (willMap.get(type) - fillAmount <= 0)
|
||||||
{
|
{
|
||||||
willMap.remove(type);
|
willMap.remove(type);
|
||||||
|
|
|
@ -266,16 +266,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
return Math.min(maxWill - current, amount);
|
return Math.min(maxWill - current, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
double filled = maxWill - current;
|
double filled = willGem.fillWill(type, stack, amount);
|
||||||
|
|
||||||
if (amount < filled)
|
|
||||||
{
|
|
||||||
willGem.setWill(type, stack, current + amount);
|
|
||||||
filled = amount;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
willGem.setWill(type, stack, maxWill);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filled;
|
return filled;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue