Fixed neoforge crash with merged jar

This commit is contained in:
coolGi
2024-01-13 16:19:10 +10:30
parent 51b543a23e
commit 93c2bf530f
2 changed files with 24 additions and 20 deletions
@@ -14,16 +14,23 @@ import java.util.Set;
*/
public class ForgeMixinPlugin implements IMixinConfigPlugin
{
private boolean isForgeMixinFile = false;
private boolean firstRun = false;
private boolean isForgeMixinFile;
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
{
if (!this.isForgeMixinFile)
{
return false;
if (!this.firstRun) {
try {
Class<?> cls = Class.forName("net.neoforged.fml.common.Mod"); // Check if a NeoForge exclusive class exists
this.isForgeMixinFile = false;
} catch (ClassNotFoundException e) {
this.isForgeMixinFile = true;
}
}
if (!this.isForgeMixinFile)
return false;
if (mixinClassName.contains(".mods."))
{ // If the mixin wants to go into a mod then we check if that mod is loaded or not
@@ -41,12 +48,7 @@ public class ForgeMixinPlugin implements IMixinConfigPlugin
@Override
public void onLoad(String mixinPackage)
{
// prevents running neoforge mixins
// com.seibel.distanthorizons.forge.mixins
this.isForgeMixinFile = mixinPackage.contains(".forge.");
}
public void onLoad(String mixinPackage) { }
@Override
public String getRefMapperConfig() { return null; }
@@ -14,16 +14,23 @@ import java.util.Set;
*/
public class NeoforgeMixinPlugin implements IMixinConfigPlugin
{
private boolean isNeoforgeMixinFile = false;
private boolean firstRun = false;
private boolean isNeoforgeMixinFile;
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
{
if (!this.isNeoforgeMixinFile)
{
return false;
if (!this.firstRun) {
try {
Class<?> cls = Class.forName("net.neoforged.fml.common.Mod"); // Check if a NeoForge exclusive class exists
this.isNeoforgeMixinFile = true;
} catch (ClassNotFoundException e) {
this.isNeoforgeMixinFile = false;
}
}
if (!this.isNeoforgeMixinFile)
return false;
if (mixinClassName.contains(".mods."))
{ // If the mixin wants to go into a mod then we check if that mod is loaded or not
@@ -41,12 +48,7 @@ public class NeoforgeMixinPlugin implements IMixinConfigPlugin
@Override
public void onLoad(String mixinPackage)
{
// prevents running forge mixins
// example string: com.seibel.distanthorizons.neoforge.mixins
this.isNeoforgeMixinFile = mixinPackage.contains("neo");
}
public void onLoad(String mixinPackage) { }
@Override
public String getRefMapperConfig() { return null; }