2020-10-02 21:09:14 +02:00
|
|
|
package com.minelittlepony.unicopia.item;
|
|
|
|
|
2022-06-25 00:19:55 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2021-02-03 21:25:42 +01:00
|
|
|
import com.google.gson.JsonArray;
|
2021-11-11 19:06:28 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.spell.crafting.SpellbookRecipe;
|
|
|
|
import com.minelittlepony.unicopia.ability.magic.spell.crafting.TraitRequirementRecipe;
|
2021-02-03 21:25:42 +01:00
|
|
|
|
2022-06-25 00:19:55 +02:00
|
|
|
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
2021-02-19 09:34:26 +01:00
|
|
|
import net.minecraft.loot.LootTable;
|
2021-02-03 21:25:42 +01:00
|
|
|
import net.minecraft.recipe.Ingredient;
|
2020-10-02 21:09:14 +02:00
|
|
|
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
|
|
|
|
|
|
|
public interface URecipes {
|
2021-11-11 19:06:28 +01:00
|
|
|
RecipeType<SpellbookRecipe> SPELLBOOK = RecipeType.register("unicopia:spellbook");
|
2020-10-02 21:09:14 +02:00
|
|
|
|
2021-11-11 19:06:28 +01:00
|
|
|
RecipeSerializer<ShapelessRecipe> ZAP_APPLE_SERIALIZER = RecipeSerializer.register("unicopia:crafting_zap_apple", new ZapAppleRecipe.Serializer());
|
|
|
|
RecipeSerializer<GlowingRecipe> GLOWING_SERIALIZER = RecipeSerializer.register("unicopia:crafting_glowing", new SpecialRecipeSerializer<>(GlowingRecipe::new));
|
|
|
|
RecipeSerializer<JarInsertRecipe> JAR_INSERT_SERIALIZER = RecipeSerializer.register("unicopia:jar_insert", new SpecialRecipeSerializer<>(JarInsertRecipe::new));
|
|
|
|
RecipeSerializer<TraitRequirementRecipe> TRAIT_REQUIREMENT = RecipeSerializer.register("unicopia:spellbook/crafting", new TraitRequirementRecipe.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;
|
|
|
|
}
|
|
|
|
|
2021-02-19 09:34:26 +01:00
|
|
|
static void bootstrap() {
|
2022-06-25 00:19:55 +02:00
|
|
|
LootTableEvents.MODIFY.register((res, manager, id, supplier, setter) -> {
|
2021-02-19 09:34:26 +01:00
|
|
|
if (!"minecraft".contentEquals(id.getNamespace())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Identifier modId = new Identifier("unicopiamc", id.getPath());
|
|
|
|
LootTable table = manager.getTable(modId);
|
|
|
|
if (table != LootTable.EMPTY) {
|
2022-06-25 00:19:55 +02:00
|
|
|
supplier.pools(List.of(table.pools));
|
2021-02-19 09:34:26 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-02 21:09:14 +02:00
|
|
|
}
|