Use a wrapper instead of ItemStacks for Altar recipes

This commit is contained in:
Nick 2015-11-03 10:00:40 -08:00
parent e12c78877e
commit 798d4b926c
5 changed files with 66 additions and 17 deletions

View file

@ -1,16 +1,16 @@
package WayofTime.bloodmagic.api.registry;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.ItemStackWrapper;
import WayofTime.bloodmagic.api.altar.AltarRecipe;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import lombok.Getter;
import net.minecraft.item.ItemStack;
public class AltarRecipeRegistry {
@Getter
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
private static BiMap<ItemStackWrapper, AltarRecipe> recipes = HashBiMap.create();
public static void registerRecipe(AltarRecipe recipe) {
if (!recipes.containsValue(recipe))
@ -19,11 +19,7 @@ public class AltarRecipeRegistry {
BloodMagicAPI.getLogger().error("Error adding recipe for " + recipe.input.getDisplayName() + (recipe.output == null ? "" : " -> " + recipe.output.getDisplayName()) + ". Recipe already exists.");
}
public static AltarRecipe getRecipeForInput(ItemStack input) {
for (ItemStack stack : recipes.keySet())
if (stack.getIsItemStackEqual(input))
return recipes.get(stack);
return null;
public static AltarRecipe getRecipeForInput(ItemStackWrapper input) {
return recipes.get(input);
}
}