Skip to content

Commit a451802

Browse files
committed
Forge missing dependency crash workaround
1 parent 45f8312 commit a451802

File tree

25 files changed

+269
-8
lines changed

25 files changed

+269
-8
lines changed

16/archCommon/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ version project.mod_version
1212

1313
architectury{
1414
common("fabric", "forge")
15-
injectInjectables = false
1615
}
1716

1817
loom{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.kosmx.emotes;
2+
3+
import dev.architectury.injectables.annotations.ExpectPlatform;
4+
5+
public class PlatformTools {
6+
@ExpectPlatform
7+
public static boolean isPlayerAnimLoaded() {
8+
throw new AssertionError();
9+
}
10+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package io.github.kosmx.emotes.mixin;
2+
3+
import io.github.kosmx.emotes.PlatformTools;
4+
import org.objectweb.asm.tree.ClassNode;
5+
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
6+
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
7+
8+
import java.util.List;
9+
import java.util.Set;
10+
11+
public class EmotesMixinPlugin implements IMixinConfigPlugin {
12+
@Override
13+
public void onLoad(String mixinPackage) {
14+
15+
}
16+
17+
@Override
18+
public String getRefMapperConfig() {
19+
return null;
20+
}
21+
22+
@SuppressWarnings("ConstantConditions")
23+
@Override
24+
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
25+
if (mixinClassName.equals("io.github.kosmx.emotes.arch.mixin.EmotePlayerMixin") && !PlatformTools.isPlayerAnimLoaded()) {
26+
return false;
27+
}
28+
return true;
29+
}
30+
31+
@Override
32+
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
33+
34+
}
35+
36+
@Override
37+
public List<String> getMixins() {
38+
return null;
39+
}
40+
41+
@Override
42+
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
43+
44+
}
45+
46+
@Override
47+
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
48+
49+
}
50+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.kosmx.emotes.fabric;
2+
3+
import net.fabricmc.loader.api.FabricLoader;
4+
5+
public class PlatformToolsImpl {
6+
public static boolean isPlayerAnimLoaded() {
7+
return FabricLoader.getInstance().isModLoaded("player-animator");
8+
}
9+
}

16/fabric/src/main/resources/fabric.mod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"depends": {
3535
"fabricloader": ">=0.9.0",
3636
"fabric": ">=0.16.4",
37-
"minecraft": "1.16.*"
37+
"minecraft": "1.16.*",
38+
"player-animator": "*"
3839
},
3940
"custom": {
4041
"modmenu": {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.github.kosmx.emotes.forge;
2+
3+
public class PlatformToolsImpl {
4+
public static boolean isPlayerAnimLoaded() {
5+
try {
6+
Class.forName("dev.kosmx.playerAnim.api.layered.IAnimation").getName();
7+
return true;
8+
} catch(ClassNotFoundException e) {
9+
return false;
10+
}
11+
}
12+
}

16/forge/src/main/resources/META-INF/mods.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ logoFile="emotecraft_mod_logo.png" #optional
2222
authors="KosmX" #optional
2323

2424
description="${description}"
25+
26+
[[dependencies.emotecraft]]
27+
modId="playeranimator"
28+
mandatory=true
29+
versionRange="[0.2.0,)"
30+
ordering="NONE"
31+
side="BOTH"

16/forge/src/main/resources/emotecraft.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"minVersion": "0.8",
44
"package": "io.github.kosmx.emotes.forge.mixin",
55
"compatibilityLevel": "JAVA_8",
6+
"plugin": "io.github.kosmx.emotes.mixin.EmotesMixinPlugin",
67
"mixins": [
78
"ChunkMapAccessor",
89
"ServerPlayNetworkInstance",

18/archCommon/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
version project.mod_version
66

77
architectury{
8-
injectInjectables = false
98
common("fabric", "forge")
109
}
1110

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.kosmx.emotes;
2+
3+
import dev.architectury.injectables.annotations.ExpectPlatform;
4+
5+
public class PlatformTools {
6+
@ExpectPlatform
7+
public static boolean isPlayerAnimLoaded() {
8+
throw new AssertionError();
9+
}
10+
}

0 commit comments

Comments
 (0)