-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab302a9
commit 6a4677b
Showing
5 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/frozenblock/unforked/FabricLoaderInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.frozenblock.unforked; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import net.fabricmc.loader.impl.FabricLoaderImpl; | ||
import net.fabricmc.loader.impl.discovery.ModCandidate; | ||
import net.fabricmc.loader.impl.metadata.LoaderModMetadata; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
// Inspired by ModsMod | ||
@ApiStatus.Internal | ||
@UtilityClass | ||
public class FabricLoaderInterface { | ||
static void init() {} | ||
|
||
private static final Method ADD_MOD; | ||
private static final Method CREATE_PLAIN; | ||
private static final Field MODS; | ||
|
||
static { | ||
try { | ||
ADD_MOD = FabricLoaderImpl.class.getDeclaredMethod("addMod", ModCandidate.class); | ||
ADD_MOD.setAccessible(true); | ||
|
||
MODS = FabricLoaderImpl.class.getDeclaredField("mods"); | ||
MODS.setAccessible(true); | ||
|
||
CREATE_PLAIN = ModCandidate.class.getDeclaredMethod("createPlain", List.class, LoaderModMetadata.class, boolean.class, Collection.class); | ||
CREATE_PLAIN.setAccessible(true); | ||
} catch (NoSuchMethodException | NoSuchFieldException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/net/frozenblock/unforked/UnforkedLanguageAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.frozenblock.unforked; | ||
|
||
|
||
import net.fabricmc.loader.api.LanguageAdapter; | ||
import net.fabricmc.loader.api.ModContainer; | ||
|
||
public final class UnforkedLanguageAdapter implements LanguageAdapter { | ||
@Override | ||
public native <T> T create(ModContainer mod, String value, Class<T> type); | ||
|
||
static { | ||
UnforkedLoader.init(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/net/frozenblock/unforked/UnforkedLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.frozenblock.unforked; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
@ApiStatus.Internal | ||
@UtilityClass | ||
public class UnforkedLoader { | ||
|
||
void init() { | ||
System.out.println("This is working"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters