<|start_filename|>src/main/java/eu/kennytv/forcecloseloadingscreen/mixin/MinecraftMixin.java<|end_filename|>
package eu.kennytv.forcecloseloadingscreen.mixin;

import eu.kennytv.forcecloseloadingscreen.ForceCloseLoadingScreenMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ReceivingLevelScreen;
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Minecraft.class)
public abstract class MinecraftMixin {

    @Shadow
    public abstract void setScreen(@Nullable Screen screen);

    @Inject(at = @At("HEAD"), method = "setScreen", cancellable = true)
    public void setScreen(final Screen screen, final CallbackInfo ci) {
        if (ForceCloseLoadingScreenMod.isInstantClose() && screen instanceof ReceivingLevelScreen) {
            ci.cancel();
            setScreen(null);
        }
    }
}


<|start_filename|>src/main/resources/assets/forcecloseloadingscreen/lang/en_us.json<|end_filename|>
{
  "text.autoconfig.forcecloseloadingscreen.title": "kennytv's epic force close loading screen mod for Fabric",
  "text.autoconfig.forcecloseloadingscreen.option.instantlyCloseUnsafe": "Close loading screen instantly? (potentially unsafe)"
}


<|start_filename|>src/main/java/eu/kennytv/forcecloseloadingscreen/config/Config.java<|end_filename|>
package eu.kennytv.forcecloseloadingscreen.config;

import me.shedaniel.autoconfig.ConfigData;

@me.shedaniel.autoconfig.annotation.Config(name = "forcecloseloadingscreen")
public class Config implements ConfigData {

    boolean instantlyCloseUnsafe;

    public boolean isInstantlyCloseUnsafe() {
        return instantlyCloseUnsafe;
    }
}

<|start_filename|>src/main/java/eu/kennytv/forcecloseloadingscreen/ForceCloseLoadingScreenMod.java<|end_filename|>
package eu.kennytv.forcecloseloadingscreen;

import eu.kennytv.forcecloseloadingscreen.config.Config;
import eu.kennytv.forcecloseloadingscreen.config.ConfigHolder;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;

public class ForceCloseLoadingScreenMod implements ModInitializer {

    private static boolean hasClothConfig; // (▀̿Ĺ̯▀̿ ̿)

    @Override
    public void onInitialize() {
        FabricLoader.getInstance().getModContainer("cloth-config").ifPresent(mod -> {
            AutoConfig.register(Config.class, GsonConfigSerializer::new);
            ConfigHolder.config = AutoConfig.getConfigHolder(Config.class).getConfig();
            hasClothConfig = true;
        });
    }

    public static boolean isInstantClose() {
        return hasClothConfig && ConfigHolder.config.isInstantlyCloseUnsafe();
    }
}


<|start_filename|>src/main/java/eu/kennytv/forcecloseloadingscreen/config/ConfigHolder.java<|end_filename|>
package eu.kennytv.forcecloseloadingscreen.config;

/**
 * No touchy without Cloth API present.
 */
public final class ConfigHolder {

    public static Config config;
}
