Jump to content

Recommended Posts

Posted

Hi, I am trying to use a shadowed dependency in my mod for version 1.8.9, but I just can't get it fully working.

I think the shadowing is working (at least a little) because I can use the dependency in my mod without getting a classdefnotfound, but if I actually try to use the dependency it just crashes with this error:
The error:

Spoiler

net.minecraftforge.fml.common.LoaderException: java.lang.ExceptionInInitializerError
	at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:739)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:310)
	at net.minecraft.client.Minecraft.startGame(Minecraft.java:495)
	at net.minecraft.client.Minecraft.run(Minecraft.java:329)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at gg.essential.loader.stage2.relaunch.Relaunch.relaunch(Relaunch.java:124)
	at gg.essential.loader.stage2.EssentialLoader.preloadEssential(EssentialLoader.java:220)
	at gg.essential.loader.stage2.EssentialLoader.loadPlatform(EssentialLoader.java:116)
	at gg.essential.loader.stage2.EssentialLoaderBase.load(EssentialLoaderBase.java:148)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at gg.essential.loader.stage1.EssentialLoaderBase.load(EssentialLoaderBase.java:293)
	at gg.essential.loader.stage1.EssentialSetupTweaker.<init>(EssentialSetupTweaker.java:44)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at gg.essential.loader.stage0.EssentialSetupTweaker.loadStage1(EssentialSetupTweaker.java:53)
	at gg.essential.loader.stage0.EssentialSetupTweaker.<init>(EssentialSetupTweaker.java:26)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:98)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:243)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:278)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)
Caused by: java.lang.ExceptionInInitializerError
	at me.ryan.ryanair.deps.moulconfig.processor.BuiltinMoulConfigGuis.addProcessors(BuiltinMoulConfigGuis.java:57)
	at me.ryan.ryanair.config.ConfigManager.init(ConfigManager.java:16)
	at me.ryan.ryanair.RyanairMod.init(RyanairMod.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
	at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:737)
	... 45 more
Caused by: java.util.NoSuchElementException: Collection is empty.
	at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:201)
	at me.ryan.ryanair.deps.moulconfig.common.IMinecraft.<clinit>(IMinecraft.kt:60)
	... 74 more

 


I have no idea if this is me using the dependency wrong, me shadowing the dependency wrong, or the dependency just being broken.

Can someone maybe check if something obvious is wrong?

Thanks in advance!

I have provided everything I could think of, if something more is needed, please tell me.

Dependency I am trying to shadow into my jar: https://github.com/NotEnoughUpdates/MoulConfig I have downloaded this dependency as "/libs/legacy-3.0.0-beta.13.jar"

Example of how the dependency should work (their own example): https://github.com/NotEnoughUpdates/MoulConfig/blob/master/legacy/src/main/java/io/github/notenoughupdates/moulconfig/test/MoulConfigTest.java

Example of how the dependency should work (another mod written in kotlin (see line 91)): https://github.com/hannibal002/SkyHanni/blob/beta/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt

My ConfigManager.java (Where it breaks (see comment on line 16)):
 

Spoiler
package me.ryan.ryanair.config;

import io.github.notenoughupdates.moulconfig.processor.BuiltinMoulConfigGuis;
import io.github.notenoughupdates.moulconfig.processor.ConfigProcessorDriver;
import io.github.notenoughupdates.moulconfig.processor.MoulConfigProcessor;
import me.ryan.ryanair.player.Player;
import net.minecraft.client.gui.GuiScreen;

public class ConfigManager {
    public static GuiScreen screenToOpen = null;
    private static final RyanairConfig con = new RyanairConfig();

    public static void init(){
//        MoulConfigProcessor<TestConfig> processor = new MoulConfigProcessor<>(testConfig);
        MoulConfigProcessor<RyanairConfig> processor = new MoulConfigProcessor<>(con);             //LINE THAT CRASHES
        BuiltinMoulConfigGuis.addProcessors(processor);
        ConfigProcessorDriver driver = new ConfigProcessorDriver(processor);
        driver.checkExpose = false;
        driver.processConfig(con);
        con.testCategory.text2.whenChanged((oldValue, newValue) ->
                Player.sendChatMessage("Just changed text2 from " + oldValue + " to " + newValue));
    }
}

 

My FMLInitializationEvent:
 

Spoiler
@EventHandler
    public void init(FMLInitializationEvent event){
        MinecraftForge.EVENT_BUS.register(new ItemTooltipListener(this));
        MinecraftForge.EVENT_BUS.register(new TickListener(this));
        MinecraftForge.EVENT_BUS.register(new KeyInputListener(this));
        ClientCommandHandler.instance.registerCommand(new StonkPriceCommand());
        ClientRegistry.registerKeyBinding(debugKey);
        ConfigManager.init();                                                                //THIS LINE CRASHES
    }

 

My build.gradle file (gradle 4.5):
(I run the tasks: "build shadowJar copyJarToBin" to build my mod)

Spoiler
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

// For those who want the bleeding edge
buildscript {
    repositories {
        jcenter()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven{
            name = "neu"
            url = "https://maven.notenoughupdates.org/releases"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.shadow'

/*
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
plugins {
    id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
project.sourceCompatibility = '1.8'
project.targetCompatibility = '1.8'
version = "1.1"
group= "me.ryan.ryanair" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ryanair"

minecraft {
    version = "1.8.9-11.15.1.2318-1.8.9"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "stable_20"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
//    launchConfigs {
//        client {
//            arg '--tweakClass', 'io.github.notenoughupdates.moulconfig.tweaker.DevelopmentResourceTweaker'
//        }
//    }
}

configurations {
    shadowModImpl
    modImplementation.extendsFrom shadowModImpl
}

dependencies {
    shadowModImpl files('libs/legacy-3.0.0-beta.13.jar')
}


dependencies {
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"
      
    // real examples
//    compile 'io.github.notenoughupdates:moulconfig:'  // adds neu to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

}

tasks.withType(ShadowJar) {
    configurations = [project.configurations.shadowModImpl]
    relocate 'io.github.notenoughupdates.moulconfig', 'me.ryan.ryanair.deps.moulconfig'
    finalizedBy 'reobfShadowJar'
}

processResources
{
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
                
        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
        
    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}
assemble.dependsOn shadowJar

reobf {
    shadowJar {}
}

task copyJarToBin(type: Copy) {
    from "${buildDir}/libs/ryanair-${project.version}-all.jar"
    into "C:\\Users\\ryanv\\Desktop\\programmas\\handige mc shit\\MultiMC\\instances\\1.8.9\\.minecraft\\mods"
}

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • the modpack keep crashing idk why,cause it never said anything about any mods causing it. crash log:https://drive.google.com/file/d/1iYKlUgvHUob8DjyRc3gqP_Viv_kSHO6L/view?usp=sharing mod list:https://drive.google.com/file/d/1MvMT-z9Jg2BITQ4uLshJ1uOh7q9EMBfC/view?usp=sharing but the server(anternos) works just fine
    • Hello, I am trying to make 2 recipes for a ruby. The first one is turning a block into a ruby and the other one is 9 nuggets into a ruby. But I keep on getting a error java.lang.IllegalStateException: Duplicate recipe rubymod:ruby   Any help would be great on how to fix it
    • Hello everyone, i'm new with programing Mods, and will need a lot of your help if possible,  Im trying to make a new GUI interface responsible to control the Droprate of game, it will control de loot drop and loot table for mobs and even blocks, but i try to make a simple Gui Screen, and wenever i try to use it, the game crash's with the error message in the subject, here is the code im using to:  IDE: IntelliJ Comunity - latest version Forge: 47.3.0 Minecraft version: 1.20.1 mapping_channel: parchment mapping_version=2023.09.03-1.20.1 Crash report link: https://pastebin.com/6dV8k1Fw   Code im using is:    package createchronical.droprateconfig; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import java.util.HashMap; import java.util.Map; public class ConfigScreen extends Screen { private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("droprateconfig", "textures/gui/config_background.png"); // Mapa de mobs e itens com seus respectivos drop rates private final Map<String, Integer> dropRates = new HashMap<>(); public ConfigScreen() { super(Component.literal("Configurações de Drop Rate")); // Inicializa com valores de drop rate padrão dropRates.put("Zombie", 10); // Exemplo de mob dropRates.put("Creeper", 5); // Exemplo de mob dropRates.put("Iron Ore", 50); // Exemplo de item dropRates.put("Diamond", 2); // Exemplo de item } @Override protected void init() { // Cria um botão para cada mob/item e adiciona na tela int yOffset = this.height / 2 - 100; // Posicionamento inicial for (Map.Entry<String, Integer> entry : dropRates.entrySet()) { String itemName = entry.getKey(); int dropRate = entry.getValue(); // Cria um botão para cada mob/item this.addRenderableWidget(Button.builder( Component.literal(itemName + ": " + dropRate + "%"), button -> onDropRateButtonPressed(itemName) ).bounds(this.width / 2 - 100, yOffset, 200, 20).build()); yOffset += 25; // Incrementa a posição Y para o próximo botão } // Adiciona o botão de "Salvar Configurações" this.addRenderableWidget(Button.builder(Component.literal("Salvar Configurações"), button -> onSavePressed()) .bounds(this.width / 2 - 100, yOffset, 200, 20) .build()); } private void onDropRateButtonPressed(String itemName) { // Lógica para alterar o drop rate do item/mob selecionado // Aqui, vamos apenas incrementar o valor como exemplo int currentRate = dropRates.get(itemName); dropRates.put(itemName, currentRate + 5); // Aumenta o drop rate em 5% } private void onSavePressed() { // Lógica para salvar as configurações (temporariamente apenas na memória) // Vamos apenas imprimir para verificar dropRates.forEach((item, rate) -> { System.out.println("Item: " + item + " | Novo Drop Rate: " + rate + "%"); }); // Fecha a tela após salvar Screen pGuiScreen = null; assert this.minecraft != null; this.minecraft.setScreen(pGuiScreen); } @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { this.renderBackground(guiGraphics); guiGraphics.blit(BACKGROUND_TEXTURE, this.width / 2 - 128, this.height / 2 - 128, 0, 0, 256, 256, 256, 256); super.render(guiGraphics, mouseX, mouseY, partialTicks); } }  
    • Also add the latest.log from /logs/
  • Topics

×
×
  • Create New...

Important Information

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