package net.minecraft.data.advancements;

import com.google.gson.GsonBuilder;
import org.apache.logging.log4j.LogManager;
import com.google.gson.JsonElement;
import java.util.Set;
import java.nio.file.Path;
import java.io.IOException;
import net.minecraft.data.HashCache;
import com.google.common.collect.ImmutableList;
import net.minecraft.advancements.Advancement;
import java.util.function.Consumer;
import java.util.List;
import net.minecraft.data.DataGenerator;
import com.google.gson.Gson;
import org.apache.logging.log4j.Logger;
import net.minecraft.data.DataProvider;

public class AdvancementProvider implements DataProvider {
    private static final Logger LOGGER;
    private static final Gson GSON;
    private final DataGenerator generator;
    private final List<Consumer<Consumer<Advancement>>> tabs;
    
    public AdvancementProvider(final DataGenerator hk) {
        this.tabs = ImmutableList.<Consumer<Consumer<Advancement>>>of(new TheEndAdvancements(), new HusbandryAdvancements(), new AdventureAdvancements(), new NetherAdvancements(), new StoryAdvancements());
        this.generator = hk;
    }
    
    @Override
    public void run(final HashCache hm) throws IOException {
        // 
        // This method could not be decompiled.
        // 
        // Original Bytecode:
        // 
        //     1: getfield        net/minecraft/data/advancements/AdvancementProvider.generator:Lnet/minecraft/data/DataGenerator;
        //     4: invokevirtual   net/minecraft/data/DataGenerator.getOutputFolder:()Ljava/nio/file/Path;
        //     7: astore_2        /* path3 */
        //     8: invokestatic    com/google/common/collect/Sets.newHashSet:()Ljava/util/HashSet;
        //    11: astore_3        /* set4 */
        //    12: aload_3         /* set4 */
        //    13: aload_2         /* path3 */
        //    14: aload_1         /* hm */
        //    15: invokedynamic   BootstrapMethod #0, accept:(Ljava/util/Set;Ljava/nio/file/Path;Lnet/minecraft/data/HashCache;)Ljava/util/function/Consumer;
        //    20: astore          consumer5
        //    22: aload_0         /* this */
        //    23: getfield        net/minecraft/data/advancements/AdvancementProvider.tabs:Ljava/util/List;
        //    26: invokeinterface java/util/List.iterator:()Ljava/util/Iterator;
        //    31: astore          5
        //    33: aload           5
        //    35: invokeinterface java/util/Iterator.hasNext:()Z
        //    40: ifeq            67
        //    43: aload           5
        //    45: invokeinterface java/util/Iterator.next:()Ljava/lang/Object;
        //    50: checkcast       Ljava/util/function/Consumer;
        //    53: astore          consumer7
        //    55: aload           consumer7
        //    57: aload           consumer5
        //    59: invokeinterface java/util/function/Consumer.accept:(Ljava/lang/Object;)V
        //    64: goto            33
        //    67: return         
        //    Exceptions:
        //  throws java.io.IOException
        //    MethodParameters:
        //  Name  Flags  
        //  ----  -----
        //  hm    
        //    StackMapTable: 00 02 FF 00 21 00 06 00 00 00 00 07 00 68 07 00 6A 00 00 FF 00 21 00 00 00 00
        // 
        // The error that occurred was:
        // 
        // java.lang.IllegalStateException: Could not infer any expression.
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:374)
        //     at com.strobel.decompiler.ast.TypeAnalysis.run(TypeAnalysis.java:96)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:344)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:214)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:99)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:782)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:675)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:552)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:519)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:161)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:150)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:125)
        //     at cuchaz.enigma.SourceProvider.getSources(SourceProvider.java:85)
        //     at cuchaz.enigma.EnigmaProject$JarExport.decompileClass(EnigmaProject.java:241)
        //     at cuchaz.enigma.EnigmaProject$JarExport.lambda$decompile$1(EnigmaProject.java:230)
        //     at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        //     at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
        //     at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        //     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        //     at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
        //     at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
        //     at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
        //     at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
        //     at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        //     at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        //     at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        //     at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        //     at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
        // 
        throw new IllegalStateException("An error occurred while decompiling this method.");
    }
    
    private static Path createPath(final Path path, final Advancement w) {
        return path.resolve("data/" + w.getId().getNamespace() + "/advancements/" + w.getId().getPath() + ".json");
    }
    
    @Override
    public String getName() {
        return "Advancements";
    }
    
    static {
        LOGGER = LogManager.getLogger();
        GSON = new GsonBuilder().setPrettyPrinting().create();
    }
}
