diff options
| author | isxander <xander@isxander.dev> | 2024-04-11 18:43:06 +0100 |
|---|---|---|
| committer | isxander <xander@isxander.dev> | 2024-04-11 18:43:06 +0100 |
| commit | 04fe933f4c24817100f3101f088accf55a621f8a (patch) | |
| tree | feff94ca3ab4484160e69a24f4ee38522381950e /src/main/java/dev/isxander/yacl3/platform | |
| parent | 831b894fdb7fe3e173d81387c8f6a2402b8ccfa9 (diff) | |
| download | YetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.tar.gz YetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.tar.bz2 YetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.zip | |
Extremely fragile and broken multiversion build with stonecutter
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/platform')
3 files changed, 97 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/platform/Env.java b/src/main/java/dev/isxander/yacl3/platform/Env.java new file mode 100644 index 0000000..276d294 --- /dev/null +++ b/src/main/java/dev/isxander/yacl3/platform/Env.java @@ -0,0 +1,10 @@ +package dev.isxander.yacl3.platform; + +public enum Env { + CLIENT, + SERVER; + + public boolean isClient() { + return this == Env.CLIENT; + } +} diff --git a/src/main/java/dev/isxander/yacl3/platform/PlatformEntrypoint.java b/src/main/java/dev/isxander/yacl3/platform/PlatformEntrypoint.java new file mode 100644 index 0000000..6231b20 --- /dev/null +++ b/src/main/java/dev/isxander/yacl3/platform/PlatformEntrypoint.java @@ -0,0 +1,42 @@ +package dev.isxander.yacl3.platform; + +import dev.isxander.yacl3.gui.image.YACLImageReloadListener; + +/*? if fabric {*/ +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.minecraft.server.packs.PackType; + +public class PlatformEntrypoint implements ClientModInitializer { + @Override + public void onInitializeClient() { + ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new YACLImageReloadListener()); + } +} +/*?} elif neoforge {*//* +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; + +@Mod("yet_another_config_lib_v3") +public class PlatformEntrypoint { + public PlatformEntrypoint(IEventBus modEventBus) { + modEventBus.addListener(RegisterClientReloadListenersEvent.class, event -> { + event.registerReloadListener(new YACLImageReloadListener()); + }); + } +} +*//*?} elif forge {*//* +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod("yet_another_config_lib_v3") +public class PlatformEntrypoint { + public PlatformEntrypoint() { + FMLJavaModLoadingContext.get().getModEventBus().<RegisterClientReloadListenersEvent>addListener(event -> { + event.registerReloadListener(new YACLImageReloadListener()); + }); + } +} +*//*?}*/
\ No newline at end of file diff --git a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java new file mode 100644 index 0000000..d134e70 --- /dev/null +++ b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java @@ -0,0 +1,45 @@ +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 java.nio.file.Path; + +public final class YACLPlatform { + 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; + *//*?}*/ + } +} |
