2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.api.registry;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
2015-12-03 03:27:28 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
2015-10-30 03:22:14 +00:00
|
|
|
import com.google.common.collect.BiMap;
|
|
|
|
import com.google.common.collect.HashBiMap;
|
2015-12-03 03:27:28 +00:00
|
|
|
import lombok.EqualsAndHashCode;
|
2015-10-30 03:22:14 +00:00
|
|
|
import lombok.Getter;
|
2015-12-03 03:27:28 +00:00
|
|
|
import lombok.ToString;
|
2015-11-28 01:15:19 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-12-03 03:27:28 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2015-10-30 03:22:14 +00:00
|
|
|
public class AltarRecipeRegistry {
|
|
|
|
|
|
|
|
@Getter
|
2015-11-28 01:15:19 +00:00
|
|
|
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
|
2015-10-30 03:22:14 +00:00
|
|
|
|
|
|
|
public static void registerRecipe(AltarRecipe recipe) {
|
|
|
|
if (!recipes.containsValue(recipe))
|
|
|
|
recipes.put(recipe.input, recipe);
|
|
|
|
else
|
2015-12-23 17:41:59 +00:00
|
|
|
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> " );
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
2015-11-03 18:00:40 +00:00
|
|
|
return recipes.get(input);
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
2015-12-03 03:27:28 +00:00
|
|
|
|
|
|
|
@Getter
|
|
|
|
@ToString
|
|
|
|
@EqualsAndHashCode
|
|
|
|
public static class AltarRecipe {
|
|
|
|
|
|
|
|
public final int syphon, consumeRate, drainRate;
|
|
|
|
public final boolean useTag;
|
|
|
|
public final ItemStack input, output;
|
|
|
|
public final EnumAltarTier minTier;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows creation of a recipe for the {@link WayofTime.bloodmagic.block.BlockAltar} / {@link WayofTime.bloodmagic.tile.TileAltar}.
|
|
|
|
* The output ItemStack is allowed to be null as some recipes do not contain an output. (Blood Orbs)
|
|
|
|
*
|
|
|
|
* @param input - The input ItemStack
|
|
|
|
* @param output - The ItemStack obtained from the recipe
|
|
|
|
* @param minTier - The minimum tier of Altar required
|
|
|
|
* @param syphon - The amount of LP to syphon from the Altar
|
|
|
|
* @param consumeRate - The rate at which LP is consumed during crafting
|
|
|
|
* @param drainRate - The rate at which LP is drained during crafting
|
|
|
|
* @param useTag -
|
|
|
|
*/
|
|
|
|
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
|
|
|
this.input = input;
|
|
|
|
this.output = output;
|
|
|
|
this.minTier = minTier;
|
2015-12-23 17:41:59 +00:00
|
|
|
this.syphon = syphon < 0 ? -syphon : syphon;
|
|
|
|
this.consumeRate = consumeRate < 0 ? -consumeRate : consumeRate;
|
|
|
|
this.drainRate = drainRate < 0 ? -drainRate : drainRate;
|
2015-12-03 03:27:28 +00:00
|
|
|
this.useTag = useTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
|
|
|
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
|
|
|
this(input, null, minTier, 0, consumeRate, drainRate);
|
|
|
|
}
|
2015-12-23 02:03:00 +00:00
|
|
|
|
2015-12-23 02:05:47 +00:00
|
|
|
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
2015-12-23 17:41:59 +00:00
|
|
|
if (comparedStack == null || this.input == null)
|
2015-12-23 02:03:00 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
|
|
|
|
}
|
2015-12-03 03:27:28 +00:00
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|