Search in sources :

Example 1 with AbstractRecipeGenerator

use of net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator in project frame-fabric by moddingplayground.

the class RecipeProvider method createFileMapAdvancements.

public Map<Identifier, JsonElement> createFileMapAdvancements() {
    Map<Identifier, JsonElement> map = Maps.newHashMap();
    for (Supplier<AbstractRecipeGenerator> generator : this.getGenerators()) {
        AbstractRecipeGenerator gen = generator.get();
        gen.accept((id, factory) -> factory.offerTo(provider -> {
            JsonObject json = provider.toAdvancementJson();
            if (json != null && map.put(id, json) != null)
                throw new IllegalStateException("Duplicate recipe advancement " + id);
        }, id));
        Identifier rootId = gen.getId("root");
        if (!map.containsKey(rootId)) {
            map.put(rootId, Advancement.Builder.create().criterion("impossible", new ImpossibleCriterion.Conditions()).toJson());
        }
    }
    return map;
}
Also used : JsonObject(com.google.gson.JsonObject) DataType(net.moddingplayground.frame.impl.toymaker.DataType) DataCache(net.minecraft.data.DataCache) Maps(com.google.common.collect.Maps) Supplier(java.util.function.Supplier) ImpossibleCriterion(net.minecraft.advancement.criterion.ImpossibleCriterion) JsonElement(com.google.gson.JsonElement) AbstractRecipeGenerator(net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator) RecipeGeneratorStore(net.moddingplayground.frame.api.toymaker.v0.registry.generator.RecipeGeneratorStore) Map(java.util.Map) Identifier(net.minecraft.util.Identifier) Advancement(net.minecraft.advancement.Advancement) DataGenerator(net.minecraft.data.DataGenerator) ImpossibleCriterion(net.minecraft.advancement.criterion.ImpossibleCriterion) Identifier(net.minecraft.util.Identifier) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) AbstractRecipeGenerator(net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator)

Aggregations

Maps (com.google.common.collect.Maps)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Map (java.util.Map)1 Supplier (java.util.function.Supplier)1 Advancement (net.minecraft.advancement.Advancement)1 ImpossibleCriterion (net.minecraft.advancement.criterion.ImpossibleCriterion)1 DataCache (net.minecraft.data.DataCache)1 DataGenerator (net.minecraft.data.DataGenerator)1 Identifier (net.minecraft.util.Identifier)1 AbstractRecipeGenerator (net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator)1 RecipeGeneratorStore (net.moddingplayground.frame.api.toymaker.v0.registry.generator.RecipeGeneratorStore)1 DataType (net.moddingplayground.frame.impl.toymaker.DataType)1