2020-04-24 03:25:58 +02:00
|
|
|
package net.minestom.server.recipe;
|
2020-04-01 13:16:18 +02:00
|
|
|
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.item.ItemStack;
|
|
|
|
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
2020-10-02 18:18:04 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
2020-04-01 13:16:18 +02:00
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
import java.util.LinkedList;
|
2020-04-01 13:16:18 +02:00
|
|
|
import java.util.List;
|
2020-10-02 18:18:04 +02:00
|
|
|
import java.util.Objects;
|
2020-04-01 13:16:18 +02:00
|
|
|
|
2020-04-26 04:50:38 +02:00
|
|
|
public abstract class ShapelessRecipe extends Recipe {
|
2020-10-02 18:18:04 +02:00
|
|
|
private String group;
|
|
|
|
private final List<DeclareRecipesPacket.Ingredient> ingredients;
|
|
|
|
private ItemStack result;
|
|
|
|
|
|
|
|
protected ShapelessRecipe(
|
|
|
|
@NotNull String recipeId,
|
|
|
|
@NotNull String group,
|
|
|
|
@Nullable List<DeclareRecipesPacket.Ingredient> ingredients,
|
|
|
|
@NotNull ItemStack result
|
|
|
|
) {
|
|
|
|
super(RecipeType.SHAPELESS, recipeId);
|
|
|
|
this.group = group;
|
|
|
|
this.ingredients = Objects.requireNonNullElseGet(ingredients, LinkedList::new);
|
|
|
|
this.result = result;
|
|
|
|
}
|
2020-04-01 13:16:18 +02:00
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
@NotNull
|
|
|
|
public String getGroup() {
|
|
|
|
return group;
|
|
|
|
}
|
2020-04-01 13:16:18 +02:00
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
public void setGroup(@NotNull String group) {
|
|
|
|
this.group = group;
|
2020-04-01 13:16:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addIngredient(DeclareRecipesPacket.Ingredient ingredient) {
|
|
|
|
ingredients.add(ingredient);
|
|
|
|
}
|
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
@NotNull
|
2020-04-01 13:16:18 +02:00
|
|
|
public List<DeclareRecipesPacket.Ingredient> getIngredients() {
|
|
|
|
return ingredients;
|
|
|
|
}
|
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
@NotNull
|
2020-04-01 13:16:18 +02:00
|
|
|
public ItemStack getResult() {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-02 18:18:04 +02:00
|
|
|
public void setResult(@NotNull ItemStack result) {
|
2020-04-01 13:16:18 +02:00
|
|
|
this.result = result;
|
|
|
|
}
|
|
|
|
}
|