Skip to content

Commit 588b55f

Browse files
committed
Add LoaderMixin for compatibility purposes
1 parent 0535fcc commit 588b55f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of OneConfig.
3+
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
4+
* Copyright (C) 2021~2023 Polyfrost.
5+
* <https://polyfrost.cc> <https://github.com/Polyfrost/>
6+
*
7+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8+
*
9+
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
10+
* General Public License as published by the Free Software Foundation, AND
11+
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
12+
* either version 1.0 of the Additional Terms, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
* Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public
21+
* License. If not, see <https://www.gnu.org/licenses/>. You should
22+
* have also received a copy of the Additional Terms Applicable
23+
* to OneConfig, as published by Polyfrost. If not, see
24+
* <https://polyfrost.cc/legal/oneconfig/additional-terms>
25+
*/
26+
27+
package cc.polyfrost.oneconfig.internal.mixin;
28+
29+
import net.minecraftforge.fml.common.Loader;
30+
import org.spongepowered.asm.mixin.Mixin;
31+
import org.spongepowered.asm.mixin.injection.At;
32+
import org.spongepowered.asm.mixin.injection.Inject;
33+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34+
35+
@Mixin(value = Loader.class, remap = false)
36+
public class LoaderMixin {
37+
38+
@Inject(method = "isModLoaded", at = @At("HEAD"), cancellable = true, remap = false)
39+
private static void oneconfig$isModLoaded(String modname, CallbackInfoReturnable<Boolean> cir) {
40+
if (modname.equals("oneconfig")) {
41+
cir.setReturnValue(true);
42+
}
43+
}
44+
45+
}

versions/src/main/resources/mixins.oneconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"EntityPlayerSPMixin",
1313
"EntityRendererMixin",
1414
"GuiIngameForgeMixin",
15+
"LoaderMixin",
1516
"MinecraftMixin",
1617
"NetworkManagerMixin",
1718
"OptifineConfigMixin",

0 commit comments

Comments
 (0)