From 7491ba5762978c1bf536f9a8c5f58960ae1451e1 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sun, 17 Jan 2021 15:19:34 -0500 Subject: [PATCH] Changed the Hellfire Forge so that it can use the Tartaric Gem in the crafting grid, and moves the remaining Will into the crafted gem --- .../bloodmagic/tile/TileSoulForge.java | 108 +++++++++++++----- 1 file changed, 79 insertions(+), 29 deletions(-) diff --git a/src/main/java/wayoftime/bloodmagic/tile/TileSoulForge.java b/src/main/java/wayoftime/bloodmagic/tile/TileSoulForge.java index f67389e2..76c8aee2 100644 --- a/src/main/java/wayoftime/bloodmagic/tile/TileSoulForge.java +++ b/src/main/java/wayoftime/bloodmagic/tile/TileSoulForge.java @@ -215,6 +215,8 @@ public class TileSoulForge extends TileInventory implements ITickableTileEntity, currentOutputStack.grow(event.getOutput().getCount()); } + moveRemainingWillInConsumedInv(); + consumeInventory(); } } @@ -234,13 +236,16 @@ public class TileSoulForge extends TileInventory implements ITickableTileEntity, public boolean hasSoulGemOrSoul() { - ItemStack soulStack = getStackInSlot(soulSlot); - - if (!soulStack.isEmpty()) + for (int i = 0; i <= 4; i++) { - if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem) + ItemStack soulStack = getStackInSlot(i); + + if (!soulStack.isEmpty()) { - return true; + if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem) + { + return true; + } } } @@ -254,51 +259,96 @@ public class TileSoulForge extends TileInventory implements ITickableTileEntity, public double getWill(EnumDemonWillType type) { - ItemStack soulStack = getStackInSlot(soulSlot); - - if (soulStack != null) + double will = 0; + for (int i = 0; i <= 4; i++) { - if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) - { - IDemonWill soul = (IDemonWill) soulStack.getItem(); - return soul.getWill(type, soulStack); - } + ItemStack soulStack = getStackInSlot(i); - if (soulStack.getItem() instanceof IDemonWillGem) + if (soulStack != null) { - IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); - return soul.getWill(type, soulStack); + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) + { + IDemonWill soul = (IDemonWill) soulStack.getItem(); + will += soul.getWill(type, soulStack); + } + + if (soulStack.getItem() instanceof IDemonWillGem) + { + IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); + will += soul.getWill(type, soulStack); + } } } - return 0; + return will; + } + + public void moveRemainingWillInConsumedInv() + { + ItemStack outputStack = getStackInSlot(outputSlot); + if (outputStack != null) + { + if (outputStack.getItem() instanceof IDemonWillGem) + { + IDemonWillGem filledGem = (IDemonWillGem) outputStack.getItem(); + for (int i = 0; i < 4; i++) + { + ItemStack soulStack = getStackInSlot(i); + if (soulStack != null && soulStack.getItem() instanceof IDemonWillGem) + { + IDemonWillGem syphonedGem = (IDemonWillGem) soulStack.getItem(); + for (EnumDemonWillType type : EnumDemonWillType.values()) + { + // Skipped a few possibly redundant checks. Also could blow up in my face rooVV + double willInGem = syphonedGem.getWill(type, soulStack); + if (willInGem > 0) + { + filledGem.fillWill(type, outputStack, willInGem, true); + } + } + } + + } + } + } } public double consumeSouls(EnumDemonWillType type, double requested) { - ItemStack soulStack = getStackInSlot(soulSlot); + double consumed = 0; - if (soulStack != null) + for (int i = 0; i <= 4; i++) { - if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) + ItemStack soulStack = getStackInSlot(i); + if (soulStack != null) { - IDemonWill soul = (IDemonWill) soulStack.getItem(); - double souls = soul.drainWill(type, soulStack, requested); - if (soul.getWill(type, soulStack) <= 0) + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) { - setInventorySlotContents(soulSlot, ItemStack.EMPTY); + IDemonWill soul = (IDemonWill) soulStack.getItem(); + double souls = soul.drainWill(type, soulStack, requested - consumed); + if (soul.getWill(type, soulStack) <= 0) + { + setInventorySlotContents(i, ItemStack.EMPTY); + } + consumed += souls; +// return souls; + } + + if (soulStack.getItem() instanceof IDemonWillGem) + { + IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); + double souls = soul.drainWill(type, soulStack, requested - consumed, true); + consumed += souls; } - return souls; } - if (soulStack.getItem() instanceof IDemonWillGem) + if (consumed >= requested) { - IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); - return soul.drainWill(type, soulStack, requested, true); + return consumed; } } - return 0; + return consumed; } public void consumeInventory()