Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to import external libraries to my mod? (MC 1.17)


Recommended Posts

My goal is to connect DL4J library to a Minecraft mod, but there is a problem. I can't figure out to import the library correctly. I tried to modify the build.gradle file like this:

dependencies {
	minecraft 'net.minecraftforge:forge:1.17.1-37.0.21'

	implementation fg.deobf("org.deeplearning4j:deeplearning4j-core:1.0.0-M1.1")
	implementation fg.deobf("org.nd4j:nd4j-native-platform:1.0.0-M1.1")
	implementation fg.deobf("org.slf4j:slf4j-api:2.0.0-alpha2")
	implementation fg.deobf("org.slf4j:slf4j-simple:2.0.0-alpha2")
}

(where the dependency-block is positioned right before the jar-block at the end of the gradle file)

to import DL4J from the Maven repo but even though the script builds successfully, the libraries cannot be used in the Java code. I figured out that compileOnly and runtimeOnly solve the syntax errors in the Code but don't get imported by ForgeGradle (?) so that an NoClassDefFoundError is thrown when a method from the library is called (When JVM loads a class from the library).

What am I missing?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello! When I try to launch the game with forge, i get an error message Error: java.lang.ExceptionInInitializerError: null Help me please   Time: 28/11/21 12:47 Description: Initializing game java.lang.ExceptionInInitializerError: null     at net.minecraft.world.item.Item.handler$zde000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:computing_frames,re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.125.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.getModEventBus()" because the return value of "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.get()" is null     at com.legacy.structure_gel.core.SGConfig$Common.<init>(SGConfig.java:49) ~[structure_gel-1.17.1-2.0.1.jar%2372!:2.0.1] {re:classloading}     at net.minecraftforge.common.ForgeConfigSpec$Builder.configure(ForgeConfigSpec.java:618) ~[forge-1.17.1-37.0.125-universal.jar%2378!:?] {re:classloading}     at com.legacy.structure_gel.core.SGConfig.<clinit>(SGConfig.java:25) ~[structure_gel-1.17.1-2.0.1.jar%2372!:2.0.1] {re:mixin,re:classloading}     ... 25 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraft.world.item.Item.handler$zde000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:computing_frames,re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} -- Initialization -- Details: Stacktrace:     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.125.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} -- System Details -- Details:     Minecraft Version: 1.17.1     Minecraft Version ID: 1.17.1     Operating System: Windows 10 (amd64) version 10.0     Java Version: 16.0.1, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 1031916112 bytes (984 MiB) / 1342177280 bytes (1280 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 8     Processor Vendor: GenuineIntel     Processor Name: Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz     Identifier: Intel64 Family 6 Model 142 Stepping 12     Microarchitecture: whiskey Lake     Frequency (GHz): 2,21     Number of physical packages: 1     Number of physical CPUs: 4     Number of logical CPUs: 8     Graphics card #0 name: Intel(R) UHD Graphics     Graphics card #0 vendor: Intel Corporation (0x8086)     Graphics card #0 VRAM (MB): 1024,00     Graphics card #0 deviceId: 0x9b41     Graphics card #0 versionInfo: DriverVersion=27.20.100.9749     Memory slot #0 capacity (MB): 8192,00     Memory slot #0 clockSpeed (GHz): 2,13     Memory slot #0 type: LPDDR3     Memory slot #1 capacity (MB): 8192,00     Memory slot #1 clockSpeed (GHz): 2,13     Memory slot #1 type: LPDDR3     Virtual memory max (MB): 18039,55     Virtual memory used (MB): 9973,79     Swap memory total (MB): 1932,72     Swap memory used (MB): 549,59     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Launched Version: 1.17.1-forge-37.0.125     Backend library: LWJGL version 3.2.2 SNAPSHOT     Backend API: Intel(R) UHD Graphics GL version 3.2.0 - Build 27.20.100.9749, Intel     Window size: <not initialized>     GL Caps: Using framebuffer using OpenGL 3.2     GL debug messages:      Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'forge'     Type: Client (map_client.txt)     CPU: 8x Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz     OptiFine Version: OptiFine_1.17.1_HD_U_H1     OptiFine Build: 20211104-012451     Render Distance Chunks: 12     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 3.2.0 - Build 27.20.100.9749     OpenGlRenderer: Intel(R) UHD Graphics     OpenGlVendor: Intel     CpuCount: 8     ModLauncher: 9.0.7+91+master.8569cdf     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:           mixin PLUGINSERVICE           eventbus PLUGINSERVICE           object_holder_definalize PLUGINSERVICE           runtime_enum_extender PLUGINSERVICE           capability_token_subclass PLUGINSERVICE           capability_inject_definalize PLUGINSERVICE           accesstransformer PLUGINSERVICE           runtimedistcleaner PLUGINSERVICE           mixin TRANSFORMATIONSERVICE           OptiFine TRANSFORMATIONSERVICE           fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         javafml@null     Mod List:          client-1.17.1-20210706.113038-srg.jar             |Minecraft                     |minecraft                     |1.17.1              |NONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         forge-1.17.1-37.0.125-universal.jar               |Forge                         |forge                         |37.0.125            |NONE      |Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90    
    • hmm, I didn't edit it, for the time being: https://paste.centos.org/view/8598a48d
    • this is full log, my problem is not to load examplemod, minecraft doesn't crush mod list of minecract title screen shows only 2 mods (minecraft and forge)  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.