Jump to content

Recommended Posts

Posted (edited)

EDIT: I had to declare the library like a mod (using the @Mod annotation and adding the mods.toml + pack.mcmeta files). By doing this it works now :D

Hi everyone :D I'm trying to create an internal library for all my mods, and inside it I have a method that registers an Item

public static RegistryObject<Item> registerItem(final DeferredRegister<Item> registry, final String name, final Supplier<Item> itemSupplier) {
  return registry.register(name, itemSupplier);
}

When the method is called from a mod, Forge raises this error
 

Exception message: java.lang.LinkageError: loader constraint violation: loader 'SECURE-BOOTSTRAP' @6bedbc4d wants to load class net.minecraftforge.registries.DeferredRegister. A different class with the same name was previously loaded by 'TRANSFORMER' @6d672bd4. (net.minecraftforge.registries.DeferredRegister is in module [email protected] of loader 'TRANSFORMER' @6d672bd4, parent loader 'bootstrap')

Both the version of Forge included in the library's build.gradle and the mod's build.gradle are the same.
I've never done this, so there's a good chance I'm configuring something wrong.
This is the build.gradle file of the library (which is part of a multi-module project)
 

plugins {
    id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
}

repositories {
    gradlePluginPortal()
    maven {
        name = 'MinecraftForge'
        url = 'https://maven.minecraftforge.net/'
    }
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

minecraft {
    mappings channel: 'official', version: minecraft_version
    reobf = false
    copyIdeResources = true
}

dependencies {
    minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
    implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

 

Edited by JimiIT92
Solved

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • JimiIT92 changed the title to [SOLVED] Use Forge classes in a library

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.