Unicopia/src/main/java/com/minelittlepony/unicopia/item/URecipes.java

49 lines
1.8 KiB
Java
Raw Normal View History

2020-10-02 21:09:14 +02:00
package com.minelittlepony.unicopia.item;
2021-02-03 21:25:42 +01:00
import com.google.gson.JsonArray;
import net.minecraft.recipe.Ingredient;
2020-10-02 21:09:14 +02:00
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.ShapelessRecipe;
2021-02-03 21:25:42 +01:00
import net.minecraft.recipe.SpecialRecipeSerializer;
2020-10-02 21:09:14 +02:00
import net.minecraft.util.Identifier;
2021-02-03 21:25:42 +01:00
import net.minecraft.util.collection.DefaultedList;
2020-10-02 21:09:14 +02:00
import net.minecraft.util.registry.Registry;
public interface URecipes {
RecipeSerializer<ShapelessRecipe> ZAP_APPLE_SERIALIZER = register("crafting_zap_apple", new ZapAppleRecipe.Serializer());
2021-02-03 21:25:42 +01:00
RecipeSerializer<GlowingRecipe> GLOWING_SERIALIZER = register("crafting_glowing", new SpecialRecipeSerializer<>(GlowingRecipe::new));
2021-02-14 21:15:30 +01:00
RecipeSerializer<JarInsertRecipe> JAR_INSERT_SERIALIZER = register("jar_insert", new SpecialRecipeSerializer<>(JarInsertRecipe::new));
2020-10-02 21:09:14 +02:00
static <T extends Recipe<?>> RecipeType<T> register(final String id) {
return Registry.register(Registry.RECIPE_TYPE, new Identifier("unicopia", id), new RecipeType<T>() {
@Override
public String toString() {
return id;
}
});
}
static <S extends RecipeSerializer<T>, T extends Recipe<?>> S register(String id, S serializer) {
return Registry.register(Registry.RECIPE_SERIALIZER, new Identifier("unicopia", id), serializer);
}
2021-02-03 21:25:42 +01:00
static DefaultedList<Ingredient> getIngredients(JsonArray json) {
DefaultedList<Ingredient> defaultedList = DefaultedList.of();
for (int i = 0; i < json.size(); ++i) {
Ingredient ingredient = Ingredient.fromJson(json.get(i));
if (!ingredient.isEmpty()) {
defaultedList.add(ingredient);
}
}
return defaultedList;
}
2020-10-02 21:09:14 +02:00
static void bootstrap() {}
}