package team.creative.enhancedvisuals.client;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import net.minecraft.client.Minecraft;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import team.creative.enhancedvisuals.EnhancedVisuals;
import team.creative.enhancedvisuals.api.type.VisualType;
import team.creative.enhancedvisuals.client.render.EVRenderer;

@OnlyIn(value = Dist.CLIENT)
public class EVClient {
    
    private static Minecraft mc = Minecraft.getInstance();
    
    public static void init(FMLClientSetupEvent event) {
        ReloadableResourceManager reloadableResourceManager = (ReloadableResourceManager) Minecraft.getInstance().getResourceManager();
        
        reloadableResourceManager.registerReloadListener(new PreparableReloadListener() {
            
            @Override
            public CompletableFuture<Void> reload(PreparationBarrier p_10638_, ResourceManager p_10639_, ProfilerFiller p_10640_, ProfilerFiller p_10641_, Executor p_10642_, Executor p_10643_) {
                return CompletableFuture.runAsync(() -> {
                    VisualManager.clearParticles();
                    EVRenderer.reloadResources = true;
                }, p_10643_);
            }
        });
        
        ResourceManager manager = mc.getResourceManager();
        for (VisualType type : VisualType.getTypes())
            type.loadResources(manager);
        
        MinecraftForge.EVENT_BUS.register(EVRenderer.class);
    }
    
    public static boolean shouldRender() {
        return mc.player != null ? (!mc.player.isSpectator() && (!mc.player.isCreative() || EnhancedVisuals.CONFIG.doEffectsInCreative)) : true;
    }
    
    public static boolean shouldTick() {
        return true;
    }
}

@@ -51,194 +51,38 @@
 ort 
-java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.Executor;%0A%0Aimport net.minecraft.client.Minecraft;%0Aimport net.minecraft.server.packs.resources.PreparableReloadListener
+net.minecraft.client.Minecraft
 ;%0Aim
@@ -203,32 +203,108 @@
 esourceManager;%0A
+import net.minecraft.server.packs.resources.SimplePreparableReloadListener;%0A
 import net.minec
@@ -1112,16 +1112,22 @@
 ner(new 
+Simple
 Preparab
@@ -1199,74 +1199,32 @@
    p
-ublic CompletableFuture%3CVoid%3E reload(PreparationBarrier p_10638_, 
+rotected Object prepare(
 Reso
@@ -1243,11 +1243,11 @@
 p_10
-639
+796
 _, P
@@ -1268,78 +1268,58 @@
 p_10
-640_, ProfilerFiller p_10641_, Executor p_10642_, Executor p_10643_) %7B
+797_) %7B%0A                return null;%0A            %7D
 %0A   
@@ -1331,58 +1331,134 @@
     
+%0A    
     
-return CompletableFuture.runAsync(() -%3E %7B%0A    
+    @Override%0A            protected void apply(Object p_10793_, ResourceManager p_10794_, ProfilerFiller p_10795_) %7B%0A
     
@@ -1517,20 +1517,16 @@
         
-    
 EVRender
@@ -1556,38 +1556,8 @@
 ue;%0A
-                %7D, p_10643_);%0A
     

Revert "Fixed resource reloader"