mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Update to Architectury Plugin 3.1 to support detecting the api FabricLoader
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -19,39 +19,14 @@
|
||||
|
||||
package me.shedaniel.architectury;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import me.shedaniel.architectury.targets.ArchitecturyTarget;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class Architectury {
|
||||
private static final String MOD_LOADER;
|
||||
private static final ImmutableMap<String,String> MOD_LOADERS = ImmutableMap.<String,String>builder()
|
||||
.put("net.fabricmc.loader.FabricLoader", "fabric")
|
||||
.put("net.minecraftforge.fml.common.Mod", "forge")
|
||||
.build();
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
|
||||
public static String getModLoader() {
|
||||
return MOD_LOADER;
|
||||
}
|
||||
|
||||
static {
|
||||
List<String> loader = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : MOD_LOADERS.entrySet()) {
|
||||
try {
|
||||
Class.forName(entry.getKey(), false, Architectury.class.getClassLoader());
|
||||
loader.add(entry.getValue());
|
||||
break;
|
||||
} catch (ClassNotFoundException ignored) {}
|
||||
}
|
||||
if (loader.isEmpty())
|
||||
throw new IllegalStateException("No detected mod loader!");
|
||||
if (loader.size() >= 2)
|
||||
LogManager.getLogger().error("Detected multiple mod loaders! Something is wrong on the classpath! " + String.join(", ", loader));
|
||||
MOD_LOADER = loader.get(0);
|
||||
return ArchitecturyTarget.getCurrentTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ package me.shedaniel.architectury.platform;
|
||||
|
||||
import me.shedaniel.architectury.Architectury;
|
||||
import me.shedaniel.architectury.annotations.ExpectPlatform;
|
||||
import me.shedaniel.architectury.targets.ArchitecturyTarget;
|
||||
import me.shedaniel.architectury.utils.Env;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.SharedConstants;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -37,8 +39,12 @@ public final class Platform {
|
||||
|
||||
/**
|
||||
* @return the current mod loader, either "fabric" or "forge"
|
||||
* @deprecated does not reflect the true mod loader, "quilt" is never returned,
|
||||
* use {@link ArchitecturyTarget#getCurrentTarget()} instead.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
|
||||
public static String getModLoader() {
|
||||
return Architectury.getModLoader();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user