Skip to content

Commit

Permalink
more api for platform
Browse files Browse the repository at this point in the history
  • Loading branch information
RawDiamondMC committed Aug 3, 2024
1 parent 8c4cfce commit 60b008c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import band.kessoku.lib.platform.impl.KessokuPlatformServices;

import java.nio.file.Path;

public interface ModLoader {
static ModLoader getInstance() {
return KessokuPlatformServices.getModLoader();
Expand All @@ -11,4 +13,8 @@ static ModLoader getInstance() {
boolean isFabric();
boolean isNeoForge();
Env getEnv();
Path getGameFolder();
Path getConfigFolder();
Path getModsFolder();
boolean isModLoaded(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;

import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -33,4 +34,24 @@ public boolean isNeoForge() {
public Env getEnv() {
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT ? Env.CLIENT : Env.SERVER;
}

@Override
public Path getGameFolder() {
return FabricLoader.getInstance().getGameDir();
}

@Override
public Path getConfigFolder() {
return FabricLoader.getInstance().getConfigDir();
}

@Override
public Path getModsFolder() {
return getGameFolder().resolve("mods");
}

@Override
public boolean isModLoaded(String id) {
return FabricLoader.getInstance().isModLoaded(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import band.kessoku.lib.platform.api.ModData;
import band.kessoku.lib.platform.api.ModLoader;
import com.google.auto.service.AutoService;
import net.minecraft.MinecraftVersion;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.FMLPaths;

import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -32,4 +36,24 @@ public boolean isNeoForge() {
public Env getEnv() {
return FMLLoader.getDist().isClient() ? Env.CLIENT : Env.SERVER;
}

@Override
public Path getGameFolder() {
return FMLPaths.GAMEDIR.get();
}

@Override
public Path getConfigFolder() {
return FMLPaths.CONFIGDIR.get();
}

@Override
public Path getModsFolder() {
return FMLPaths.MODSDIR.get();
}

@Override
public boolean isModLoaded(String id) {
return ModList.get().isLoaded(id);
}
}

0 comments on commit 60b008c

Please sign in to comment.