package com.jozufozu.flywheel.backend; import java.util.Collection; import java.util.function.Predicate; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.jozufozu.flywheel.backend.source.Resolver; import com.jozufozu.flywheel.backend.source.ShaderLoadingException; import com.jozufozu.flywheel.backend.source.ShaderSources; import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer; import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.event.GatherContextEvent; import com.jozufozu.flywheel.util.ResourceUtil; import com.jozufozu.flywheel.util.StreamUtil; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.DataResult; import com.mojang.serialization.JsonOps; import net.minecraft.client.Minecraft; import net.minecraft.client.world.ClientWorld; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResource; import net.minecraft.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.resource.IResourceType; import net.minecraftforge.resource.ISelectiveResourceReloadListener; import net.minecraftforge.resource.VanillaResourceType; /** * The main entity for loading shaders. * *
* This class is responsible for invoking the loading, parsing, and compilation stages. *
*/ public class Loader implements ISelectiveResourceReloadListener { public static final String PROGRAM_DIR = "flywheel/programs/"; private static final Gson GSON = new GsonBuilder().create(); private final Backend backend; private boolean shouldCrash; public Loader(Backend backend) { this.backend = backend; // Can be null when running datagenerators due to the unfortunate time we call this Minecraft minecraft = Minecraft.getInstance(); if (minecraft != null) { IResourceManager manager = minecraft.getResourceManager(); if (manager instanceof IReloadableResourceManager) { ((IReloadableResourceManager) manager).registerReloadListener(this); } } } public void notifyError() { shouldCrash = true; } @Override public void onResourceManagerReload(IResourceManager manager, Predicate