Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d3b9f36a2
|
||
|
|
0dc846ba07
|
||
|
|
02408383e3
|
||
|
|
d24c1ec17c
|
No files matched your search
+1
-1
@@ -4,6 +4,6 @@ mixinextras_version=0.4.1
|
||||
fabric_version=0.18.6
|
||||
neoforge_version=20.2.3-beta
|
||||
forge_version=1.20.1-47.0.19
|
||||
mod_version=1.1
|
||||
mod_version=1.2
|
||||
maven_group=com.nerjal
|
||||
maven_artifact=ModdingUtils
|
||||
@@ -17,13 +17,31 @@ public class CompatMixinPlugin implements IMixinConfigPlugin {
|
||||
Set<String> skippedModCompats = new HashSet<>();
|
||||
Logger logger;
|
||||
|
||||
private static int lastIndexOf(String target, String[] array) {
|
||||
int x = array.length - 1;
|
||||
while (x >= 0) {
|
||||
String s = array[x--];
|
||||
if (Objects.equals(s, target)) break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
String[] split = mixinPackage.split("\\.");
|
||||
int x = split.length;
|
||||
String s = split[--x];
|
||||
while (s.isBlank() && x > 0) s = split[--x];
|
||||
logger = LoggerFactory.getLogger("["+s+"/MixinCompat]");
|
||||
int x;
|
||||
String s = null;
|
||||
if ((x = lastIndexOf("mixin", split)) == -1) {
|
||||
if ((x = lastIndexOf("mixins", split)) == -1) {
|
||||
x = split.length;
|
||||
s = split[--x];
|
||||
while ((s.isBlank()) && x > 0) s = split[--x];
|
||||
}
|
||||
}
|
||||
if (s == null) {
|
||||
s = split[x];
|
||||
}
|
||||
logger = LoggerFactory.getLogger(s+"/MixinCompat");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ public enum Loader {
|
||||
;
|
||||
|
||||
public static Loader parse(String s) {
|
||||
String lower = s.toLowerCase();
|
||||
return switch (s.toLowerCase()) {
|
||||
case "modlauncher" -> {
|
||||
if (Loader.class.getClassLoader().getResource("net/neoforged/fml/ModLoader.class") == null) {
|
||||
|
||||
@@ -21,10 +21,6 @@ public abstract sealed class PlatformService permits PlatformServiceFabric, Plat
|
||||
String side = MixinService.getService().getSideName();
|
||||
LOADER = Loader.parse(name);
|
||||
SIDE = Side.parse(side);
|
||||
|
||||
System.out.println(MixinService.getService().getName());
|
||||
System.out.println(MixinService.getService().getSideName());
|
||||
System.out.println(MixinService.getService().getClass());
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@@ -55,6 +51,8 @@ public abstract sealed class PlatformService permits PlatformServiceFabric, Plat
|
||||
return modsMap.computeIfAbsent(modId, this::createModContainer);
|
||||
}
|
||||
|
||||
public abstract boolean isDevEnv();
|
||||
|
||||
@Contract(pure = true)
|
||||
protected abstract Optional<PlatformModContainer> createModContainer(String modId);
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@ final class PlatformServiceFabric extends PlatformService {
|
||||
.map(FabricModContainer::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
static final class FabricModContainer extends PlatformModContainer {
|
||||
|
||||
private FabricModContainer(ModMetadata modMetadata) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.nerjal.moddingutils.platform;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,6 +14,11 @@ final class PlatformServiceForge extends PlatformService {
|
||||
return Optional.ofNullable(ModList.get().getModFileById(modId)).map(i -> new ForgeModContainer(modId, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
static final class ForgeModContainer extends PlatformModContainer {
|
||||
|
||||
ForgeModContainer(String modId, IModFileInfo modInfo) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.nerjal.moddingutils.platform;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.neoforgespi.language.IModFileInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,6 +14,11 @@ final class PlatformServiceNeoForge extends PlatformService {
|
||||
return Optional.ofNullable(ModList.get().getModFileById(modId)).map(i -> new NeoForgeModContainer(modId, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
static final class NeoForgeModContainer extends PlatformModContainer {
|
||||
NeoForgeModContainer(String modId, IModFileInfo modInfo) {
|
||||
super(modId, Arrays.stream(modInfo.getConfig().getConfigElement("authors")
|
||||
|
||||
@@ -10,4 +10,9 @@ final class PlatformServiceOther extends PlatformService {
|
||||
protected Optional<PlatformModContainer> createModContainer(String modId) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ module ModdingUtils {
|
||||
requires net.minecraftforge.forgespi;
|
||||
requires net.neoforged.neoforgespi;
|
||||
requires fml_core;
|
||||
requires fmlloader;
|
||||
requires fml_loader;
|
||||
opens com.nerjal.moddingutils.compat;
|
||||
opens com.nerjal.moddingutils.mod;
|
||||
opens com.nerjal.moddingutils.platform;
|
||||
|
||||
Reference in new issue
Block a user