NaturesAura/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java

47 lines
1.3 KiB
Java
Raw Normal View History

2018-10-16 01:36:30 +02:00
package de.ellpeck.naturesaura.recipes;
import de.ellpeck.naturesaura.Helper;
import net.minecraft.item.ItemStack;
2018-10-22 00:14:52 +02:00
import net.minecraft.util.ResourceLocation;
2018-10-16 01:36:30 +02:00
2018-10-22 00:14:52 +02:00
import java.util.HashMap;
2018-10-16 01:36:30 +02:00
import java.util.List;
2018-10-22 00:14:52 +02:00
import java.util.Map;
2018-10-16 01:36:30 +02:00
public class TreeRitualRecipe {
2018-10-22 00:14:52 +02:00
public static final Map<ResourceLocation, TreeRitualRecipe> RECIPES = new HashMap<>();
2018-10-16 01:36:30 +02:00
2018-10-22 00:14:52 +02:00
public final ResourceLocation name;
2018-10-16 01:36:30 +02:00
public final ItemStack saplingType;
public final ItemStack[] items;
public final ItemStack result;
public final int time;
2018-10-22 00:14:52 +02:00
public TreeRitualRecipe(ResourceLocation name, ItemStack saplingType, ItemStack result, int time, ItemStack... items) {
this.name = name;
2018-10-16 01:36:30 +02:00
this.saplingType = saplingType;
this.items = items;
this.result = result;
this.time = time;
}
public boolean matchesItems(ItemStack sapling, List<ItemStack> items) {
if (this.saplingType.isItemEqual(sapling)) {
for (ItemStack ingredient : this.items) {
2018-10-16 11:49:30 +02:00
if (Helper.getItemIndex(items, ingredient) < 0) {
2018-10-16 01:36:30 +02:00
return false;
}
}
return true;
} else {
return false;
}
}
2018-10-18 13:34:37 +02:00
public TreeRitualRecipe add() {
2018-10-22 00:14:52 +02:00
RECIPES.put(this.name, this);
2018-10-18 13:34:37 +02:00
return this;
2018-10-16 01:36:30 +02:00
}
}