Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.