Fixed the Hellfire Forge filling the Tartaric Gem with the incorrect Will from the Demon Aura, without actually adding to the gem

This commit is contained in:
WayofTime 2016-07-09 21:45:35 -04:00
parent c34bd48aa5
commit b8745e34ee
5 changed files with 20 additions and 25 deletions

View file

@ -26,7 +26,7 @@ public interface IDemonWillGem
int getMaxWill(EnumDemonWillType type, ItemStack willGemStack); int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount); double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount, boolean doDrain);
double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount); double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill);
} }

View file

@ -119,7 +119,7 @@ public class PlayerDemonWillHandler
inventory[i] = null; inventory[i] = null;
} else if (stack.getItem() instanceof IDemonWillGem) } else if (stack.getItem() instanceof IDemonWillGem)
{ {
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed); consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
} }
} }
} }
@ -180,7 +180,7 @@ public class PlayerDemonWillHandler
{ {
if (stack != null && stack.getItem() instanceof IDemonWillGem) if (stack != null && stack.getItem() instanceof IDemonWillGem)
{ {
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
if (remaining <= 0) if (remaining <= 0)
break; break;
} }
@ -213,7 +213,7 @@ public class PlayerDemonWillHandler
{ {
if (stack != null && !stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) if (stack != null && !stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem)
{ {
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
if (remaining <= 0) if (remaining <= 0)
break; break;

View file

@ -57,7 +57,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10); double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack); double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
this.drainWill(type, stack, filled); this.drainWill(type, stack, filled, true);
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack); return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
} }
@ -196,7 +196,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
} }
@Override @Override
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount) public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain)
{ {
EnumDemonWillType currentType = this.getCurrentType(soulGemStack); EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
if (currentType != type) if (currentType != type)
@ -206,7 +206,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
double souls = getWill(type, soulGemStack); double souls = getWill(type, soulGemStack);
double soulsDrained = Math.min(drainAmount, souls); double soulsDrained = Math.min(drainAmount, souls);
setWill(type, soulGemStack, souls - soulsDrained);
if (!doDrain)
{
setWill(type, soulGemStack, souls - soulsDrained);
}
return soulsDrained; return soulsDrained;
} }
@ -271,7 +275,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
} }
@Override @Override
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount) public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill)
{ {
if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0) if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0)
{ {
@ -283,12 +287,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
double filled = Math.min(fillAmount, maxWill - current); double filled = Math.min(fillAmount, maxWill - current);
if (filled > 0) if (filled > 0 && doFill)
{ {
this.setWill(type, stack, filled + current); this.setWill(type, stack, filled + current);
return filled;
} }
return 0; return filled;
} }
} }

View file

@ -54,7 +54,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
double fillAmount = Math.min(gemDrainRate, current); double fillAmount = Math.min(gemDrainRate, current);
if (fillAmount > 0) if (fillAmount > 0)
{ {
fillAmount = gemItem.fillWill(type, stack, fillAmount); fillAmount = gemItem.fillWill(type, stack, fillAmount, true);
if (willMap.get(type) - fillAmount <= 0) if (willMap.get(type) - fillAmount <= 0)
{ {
willMap.remove(type); willMap.remove(type);
@ -80,7 +80,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type);
double drainAmount = Math.min(maxWill - currentAmount, gemDrainRate); double drainAmount = Math.min(maxWill - currentAmount, gemDrainRate);
double filled = WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, drainAmount, maxWill, false); double filled = WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, drainAmount, maxWill, false);
filled = gemItem.drainWill(type, stack, filled); filled = gemItem.drainWill(type, stack, filled, true);
if (filled > 0) if (filled > 0)
{ {
WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true); WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true);

View file

@ -231,7 +231,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
if (soulStack.getItem() instanceof IDemonWillGem) if (soulStack.getItem() instanceof IDemonWillGem)
{ {
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
return soul.drainWill(EnumDemonWillType.DEFAULT, soulStack, requested); return soul.drainWill(EnumDemonWillType.DEFAULT, soulStack, requested, true);
} }
} }
@ -288,15 +288,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
IDemonWillGem willGem = (IDemonWillGem) stack.getItem(); IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
double maxWill = willGem.getMaxWill(type, stack); double filled = willGem.fillWill(type, stack, amount, doFill);
double current = willGem.getWill(type, stack);
if (!doFill)
{
return Math.min(maxWill - current, amount);
}
double filled = willGem.fillWill(type, stack, amount);
return filled; return filled;
} }
@ -321,7 +313,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
if (doDrain) if (doDrain)
{ {
drained = willGem.drainWill(type, stack, drained); drained = willGem.drainWill(type, stack, drained, true);
} }
return drained; return drained;