mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-26 21:52:50 +02:00
2b236b441c
* fixes recipes for 1.20.1 (and probably 1.20.4)
* add support for smithing trims and transforms
(cherry picked from commit 78cb62fa72
)
68 lines
1.8 KiB
Java
68 lines
1.8 KiB
Java
package net.minestom.server.recipe;
|
|
|
|
import net.minestom.server.item.ItemStack;
|
|
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
public abstract class ShapelessRecipe extends Recipe {
|
|
private String group;
|
|
private RecipeCategory.Crafting category;
|
|
private final List<DeclareRecipesPacket.Ingredient> ingredients;
|
|
private ItemStack result;
|
|
|
|
protected ShapelessRecipe(
|
|
@NotNull String recipeId,
|
|
@NotNull String group,
|
|
@NotNull RecipeCategory.Crafting category,
|
|
@Nullable List<DeclareRecipesPacket.Ingredient> ingredients,
|
|
@NotNull ItemStack result
|
|
) {
|
|
super(Type.SHAPELESS, recipeId);
|
|
this.group = group;
|
|
this.category = category;
|
|
this.ingredients = Objects.requireNonNullElseGet(ingredients, LinkedList::new);
|
|
this.result = result;
|
|
}
|
|
|
|
@NotNull
|
|
public String getGroup() {
|
|
return group;
|
|
}
|
|
|
|
public void setGroup(@NotNull String group) {
|
|
this.group = group;
|
|
}
|
|
|
|
@NotNull
|
|
public RecipeCategory.Crafting getCategory() {
|
|
return category;
|
|
}
|
|
|
|
public void setCategory(@NotNull RecipeCategory.Crafting category) {
|
|
this.category = category;
|
|
}
|
|
|
|
public void addIngredient(DeclareRecipesPacket.Ingredient ingredient) {
|
|
ingredients.add(ingredient);
|
|
}
|
|
|
|
@NotNull
|
|
public List<DeclareRecipesPacket.Ingredient> getIngredients() {
|
|
return ingredients;
|
|
}
|
|
|
|
@NotNull
|
|
public ItemStack getResult() {
|
|
return result;
|
|
}
|
|
|
|
public void setResult(@NotNull ItemStack result) {
|
|
this.result = result;
|
|
}
|
|
}
|