From f1a3c5ee4686fef6755fdc9bd001a67cc382c973 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Tue, 22 Dec 2015 21:03:00 -0500 Subject: [PATCH] Fixed Orb filling and added the Weak Blood Orb as a fillable orb. --- .../bloodmagic/altar/BloodAltar.java | 26 +++++++++---------- .../api/registry/AltarRecipeRegistry.java | 10 +++++++ .../bloodmagic/registry/ModRecipes.java | 1 + 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java index f888c575..c09326d4 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java @@ -21,6 +21,7 @@ import WayofTime.bloodmagic.api.altar.EnumAltarTier; import WayofTime.bloodmagic.api.altar.IAltarComponent; import WayofTime.bloodmagic.api.orb.IBloodOrb; import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; +import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.block.BlockBloodRune; import WayofTime.bloodmagic.block.BlockLifeEssence; @@ -263,19 +264,15 @@ public class BloodAltar { if (tileAltar.getStackInSlot(0) != null) { // Do recipes - for (ItemStack itemStack : AltarRecipeRegistry.getRecipes().keySet()) { - if (tileAltar.getStackInSlot(0).getIsItemStackEqual(AltarRecipeRegistry.getRecipes().get(itemStack).getInput())) { - AltarRecipeRegistry.AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(itemStack); - - if (altarTier.ordinal() >= recipe.getMinTier().ordinal()) { - this.isActive = true; - this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata()); - this.liquidRequired = recipe.getSyphon(); - this.canBeFilled = recipe.isUseTag(); - this.consumptionRate = recipe.getConsumeRate(); - this.drainRate = recipe.getDrainRate(); - return; - } + for (AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) { + if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier)) { + this.isActive = true; + this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata()); + this.liquidRequired = recipe.getSyphon(); + this.canBeFilled = recipe.isUseTag(); + this.consumptionRate = recipe.getConsumeRate(); + this.drainRate = recipe.getDrainRate(); + return; } } } @@ -343,7 +340,7 @@ public class BloodAltar { float f1 = f * 0.6F + 0.4F; float f2 = f * f * 0.7F - 0.5F; float f3 = f * f * 0.6F - 0.7F; - + if (!canBeFilled) { if (fluid != null && fluid.amount >= 1) { int stackSize = tileAltar.getStackInSlot(0).stackSize; @@ -379,6 +376,7 @@ public class BloodAltar { world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + Math.random() - Math.random(), pos.getY() + Math.random() - Math.random(), pos.getZ() + Math.random() - Math.random(), f1, f2, f3); } } else { + System.out.println("Test2"); ItemStack returnedItem = tileAltar.getStackInSlot(0); if (!(returnedItem.getItem() instanceof IBloodOrb)) diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java index 5678fdbe..79428629 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java @@ -83,5 +83,15 @@ public class AltarRecipeRegistry { public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) { this(input, null, minTier, 0, consumeRate, drainRate); } + + public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) + { + if (comparedStack == null || this.input == null) + { + return false; + } + + return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true); + } } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java index 8ed4dcb9..650f66eb 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java @@ -16,6 +16,7 @@ public class ModRecipes { public static void addAltarRecipes() { // ONE + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(OrbRegistry.getOrbStack(ModItems.orbWeak), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 5000, 2, 1, true)); AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.diamond), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 2000, 2, 1, false)); AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.stone), new ItemStack(ModItems.slate), EnumAltarTier.ONE, 1000, 5, 5, false));