Skip to content

Commit 40421df

Browse files
committed
Try import Chicory
1 parent 9f65ea4 commit 40421df

5 files changed

Lines changed: 36 additions & 3 deletions

File tree

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ group = mod_group_id
1818

1919
repositories {
2020
// Add here additional repositories if required by some of the dependencies below.
21+
maven {
22+
name = 'BlameJared Maven (CrT / Bookshelf)'
23+
url = 'https://maven.blamejared.com'
24+
}
25+
mavenCentral()
26+
flatDir { dir 'libs' }
2127
}
2228

2329
base {
@@ -95,7 +101,8 @@ dependencies {
95101
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
96102
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
97103
implementation "net.neoforged:neoforge:${neo_version}"
98-
104+
implementation 'com.dylibso.chicory:runtime:1.5.1'
105+
jarJar 'com.dylibso.chicory:runtime:1.5.1'
99106
// Example optional mod dependency with JEI
100107
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
101108
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ loader_version_range=[1,)
2626

2727
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
2828
# Must match the String constant located in the main mod class annotated with @Mod.
29-
mod_id=examplemod
29+
mod_id=sml
3030
# The human-readable display name for the mod.
3131
mod_name=Example Mod
3232
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.

libs/chicory-runtime-1.5.1.jar

113 KB
Binary file not shown.

src/main/java/com/synthmodloader/modloader/SynthModLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.synthmodloader.modloader;
22

33
import com.synthmodloader.modloader.Config;
4+
import com.synthmodloader.modloader.integration.ChicoryIntegration;
45
import org.slf4j.Logger;
56

67
import com.mojang.logging.LogUtils;
@@ -48,7 +49,7 @@ public SynthModLoader(IEventBus modEventBus, ModContainer modContainer) {
4849
// Register the commonSetup method for modloading
4950
modEventBus.addListener(this::commonSetup);
5051

51-
52+
ChicoryIntegration.init();
5253
// Register ourselves for server and other game events we are interested in.
5354
// Note that this is necessary if and only if we want *this* class (ExampleMod) to respond directly to events.
5455
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.synthmodloader.modloader.integration;
2+
3+
import com.dylibso.chicory.runtime.ExportFunction;
4+
import com.dylibso.chicory.wasm.types.Value;
5+
import com.dylibso.chicory.wasm.Parser;
6+
import com.dylibso.chicory.runtime.Instance;
7+
import com.synthmodloader.modloader.SynthModLoader;
8+
9+
import java.io.IOException;
10+
11+
public class ChicoryIntegration {
12+
public static void init() {
13+
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
14+
try {
15+
var module = Parser.parse(classloader.getResourceAsStream("test.wasm"));
16+
Instance instance = Instance.builder(module).build();
17+
ExportFunction testFunction = instance.export("testFunction");
18+
SynthModLoader.LOGGER.info("OUTPUT: " + testFunction.apply(1)[0]);
19+
} catch(Exception e) {
20+
SynthModLoader.LOGGER.error("Error loading test module !", e);
21+
}
22+
23+
24+
}
25+
}

0 commit comments

Comments
 (0)