From b8745e34ee6c14a8c5458ad63928b146adaed064 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 9 Jul 2016 21:45:35 -0400 Subject: [PATCH] Fixed the Hellfire Forge filling the Tartaric Gem with the incorrect Will from the Demon Aura, without actually adding to the gem --- .../bloodmagic/api/soul/IDemonWillGem.java | 4 ++-- .../api/soul/PlayerDemonWillHandler.java | 6 +++--- .../bloodmagic/item/soul/ItemSoulGem.java | 17 ++++++++++------- .../bloodmagic/tile/TileDemonCrucible.java | 4 ++-- .../bloodmagic/tile/TileSoulForge.java | 14 +++----------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java index d470f66f..cebfe039 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java @@ -26,7 +26,7 @@ public interface IDemonWillGem 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); } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java index e6e27bbe..fe3b6a26 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java @@ -119,7 +119,7 @@ public class PlayerDemonWillHandler inventory[i] = null; } 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) { - remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); + remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true); if (remaining <= 0) break; } @@ -213,7 +213,7 @@ public class PlayerDemonWillHandler { 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) break; diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java index f64a0f43..9e25e1c8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java @@ -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 filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack); - this.drainWill(type, stack, filled); + this.drainWill(type, stack, filled, true); return new ActionResult(EnumActionResult.PASS, stack); } @@ -196,7 +196,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @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); if (currentType != type) @@ -206,7 +206,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I double souls = getWill(type, soulGemStack); double soulsDrained = Math.min(drainAmount, souls); - setWill(type, soulGemStack, souls - soulsDrained); + + if (!doDrain) + { + setWill(type, soulGemStack, souls - soulsDrained); + } return soulsDrained; } @@ -271,7 +275,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @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) { @@ -283,12 +287,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I double filled = Math.min(fillAmount, maxWill - current); - if (filled > 0) + if (filled > 0 && doFill) { this.setWill(type, stack, filled + current); - return filled; } - return 0; + return filled; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java index 0c7f0931..0af7a64e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java @@ -54,7 +54,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo double fillAmount = Math.min(gemDrainRate, current); if (fillAmount > 0) { - fillAmount = gemItem.fillWill(type, stack, fillAmount); + fillAmount = gemItem.fillWill(type, stack, fillAmount, true); if (willMap.get(type) - fillAmount <= 0) { willMap.remove(type); @@ -80,7 +80,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); double drainAmount = Math.min(maxWill - currentAmount, gemDrainRate); 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) { WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java index f901fa06..cc039400 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java @@ -231,7 +231,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil if (soulStack.getItem() instanceof IDemonWillGem) { 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(); - double maxWill = willGem.getMaxWill(type, stack); - double current = willGem.getWill(type, stack); - - if (!doFill) - { - return Math.min(maxWill - current, amount); - } - - double filled = willGem.fillWill(type, stack, amount); + double filled = willGem.fillWill(type, stack, amount, doFill); return filled; } @@ -321,7 +313,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil if (doDrain) { - drained = willGem.drainWill(type, stack, drained); + drained = willGem.drainWill(type, stack, drained, true); } return drained;