Skip to content

Commit

Permalink
Fix mod-load-order-dependent crashes in (Neo)Forge.
Browse files Browse the repository at this point in the history
- Fix mixin-related crashes in Forge and NeoForge
- Remove mixin extras work-around; requires Forge 49.0.31
  • Loading branch information
gniftygnome committed Mar 14, 2024
1 parent 4cea9b7 commit ae1cdca
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"depends": {
"fabricloader": ">=0.15",
"fabric-api": "*",
"minecraft": ">=1.20.4 <1.21"
"minecraft": ">=1.20.4 <1.20.5"
},
"breaks": {
"terrablender": "<3.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.terraformersmc.biolith.impl.mixin;

import com.google.common.collect.ImmutableMap;
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.LoadingModList;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -16,22 +15,20 @@ public class BiolithForgeMixinConfigPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> TRUE = () -> true;

private static final Map<String, Supplier<Boolean>> CONDITIONS = ImmutableMap.of(
"com.terraformersmc.biolith.impl.mixin.MixinTBTheEndBiomeSource", () -> ModList.get().isLoaded("terrablender")
"com.terraformersmc.biolith.impl.mixin.MixinTBTheEndBiomeSource", () -> LoadingModList.get().getModFileById("terrablender") != null
);

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return CONDITIONS.getOrDefault(mixinClassName, TRUE).get();
}

// Boilerplate

@Override
public void onLoad(String mixinPackage) {
// Work-around for ME auto-apply issue on Forge
MixinExtrasBootstrap.init();
}

// Boilerplate

@Override
public String getRefMapperConfig() {
return null;
Expand Down
4 changes: 2 additions & 2 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ config = "biolith.forge.mixins.json"
[[dependencies.biolith]]
modId = "forge"
mandatory = true
versionRange = "[1,)"
versionRange = "[49.0.31,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.biolith]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20.4,1.21)"
versionRange = "[1.20.4,1.20.5)"
ordering = "NONE"
side = "BOTH"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.terraformersmc.biolith.impl.mixin;

import com.google.common.collect.ImmutableMap;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.LoadingModList;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -15,7 +15,7 @@ public class BiolithNeoForgeMixinConfigPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> TRUE = () -> true;

private static final Map<String, Supplier<Boolean>> CONDITIONS = ImmutableMap.of(
"com.terraformersmc.biolith.impl.mixin.MixinTBTheEndBiomeSource", () -> ModList.get().isLoaded("terrablender")
"com.terraformersmc.biolith.impl.mixin.MixinTBTheEndBiomeSource", () -> LoadingModList.get().getModFileById("terrablender") != null
);

@Override
Expand Down
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ side = "BOTH"
[[dependencies.biolith]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.4,1.21)"
versionRange = "[1.20.4,1.20.5)"
ordering = "NONE"
side = "BOTH"

0 comments on commit ae1cdca

Please sign in to comment.