aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java
blob: 044fbe2403896fe188acd6ecc6a47f0450339393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package dev.isxander.yacl3.platform;

/*? if fabric {*/
import net.fabricmc.loader.api.FabricLoader;
/*?} elif neoforge {*/
/*import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLPaths;
*//*?} elif forge {*//*
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.FMLPaths;
*//*?}*/

import net.minecraft.resources.ResourceLocation;
import java.nio.file.Path;

public final class YACLPlatform {
    public static ResourceLocation parseRl(String rl) {
        /*? if >1.20.6 {*/
        return ResourceLocation.parse(rl);
        /*?} else {*/
        /*return new ResourceLocation(rl);
        *//*?}*/
    }

    public static ResourceLocation rl(String path) {
        return rl("yet_another_config_lib_v3", path);
    }

    public static ResourceLocation mcRl(String path) {
        return rl("minecraft", path);
    }

    public static ResourceLocation rl(String namespace, String path) {
        /*? if >1.20.6 {*/
        return ResourceLocation.fromNamespaceAndPath(namespace, path);
        /*?} else {*/
        /*return new ResourceLocation(namespace, path);
        *//*?}*/
    }

    public static Env getEnvironment() {
        /*? if fabric {*/
        return switch (FabricLoader.getInstance().getEnvironmentType()) {
            case CLIENT -> Env.CLIENT;
            case SERVER -> Env.SERVER;
        };
        /*?} elif forge-like {*/
        /*return switch (FMLEnvironment.dist) {
            case CLIENT -> Env.CLIENT;
            case DEDICATED_SERVER -> Env.SERVER;
        };
        *//*?}*/
    }

    public static Path getConfigDir() {
        /*? if fabric {*/
        return FabricLoader.getInstance().getConfigDir();
        /*?} elif forge-like {*/
        /*return FMLPaths.CONFIGDIR.get();
        *//*?}*/
    }

    public static boolean isDevelopmentEnv() {
        /*? if fabric {*/
        return FabricLoader.getInstance().isDevelopmentEnvironment();
        /*?} elif forge-like {*/
        /*return !FMLEnvironment.production;
        *//*?}*/
    }
}