Jump to content

[SOLVED] Server side crash, java.lang.NoClassDefFoundError: mymod/myGui


Recommended Posts

Posted

Hello,

 

in my mod the Client side work fine, but Server side crash when try to open a gui, the error:

 

 

 

Description: Exception in server tick loop

java.lang.NoClassDefFoundError: mymod/myGui

  at mymod.myGuiHandler.getClientGuiElement(myGuiHandler.java:17)

  at mymod.my_item.a(my_item.java:189)

  at ur.a(SourceFile:98)

  at ir.a(ItemInWorldManager.java:348)

  at iv.a(NetServerHandler.java:555)

  at fk.a(SourceFile:58)

  at cg.b(TcpConnection.java:458)

  at iv.d(NetServerHandler.java:136)

  at iw.b(NetworkListenThread.java:57)

  at ht.b(SourceFile:30)

  at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:703)

  at ho.r(DedicatedServer.java:270)

  at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:599)

  at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497)

  at fy.run(SourceFile:849)

Caused by: java.lang.ClassNotFoundException: mymod.myGui

  at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:185)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

  ... 15 more

Caused by: java.lang.NoClassDefFoundError: aul

  at java.lang.ClassLoader.defineClass1(Native Method)

  at java.lang.ClassLoader.defineClass(ClassLoader.java:791)

  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

  at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:174)

  ... 17 more

Caused by: java.lang.ClassNotFoundException: aul

  at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:89)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

 

 

 

 

Follow the line 189 in "my_item" file:

 

 

 

FMLCommonHandler.instance().showGuiScreen(new myGuiHandler().getClientGuiElement(1, par3EntityPlayer, par2World, (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ));

 

 

 

 

 

And this is the code of "myGuiHandler" file:

 

 

 

package mymod;

 

import cpw.mods.fml.common.network.IGuiHandler;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.world.World;

 

public class myGuiHandler implements IGuiHandler

{

  @Override

    public Object getServerGuiElement(int var1, EntityPlayer var2, World var3, int var4, int var5, int var6)

    {

        return null;

    }

  @Override

    public Object getClientGuiElement(int var1, EntityPlayer var2, World var3, int var4, int var5, int var6)

    {

        return var2.getCurrentEquippedItem() != null && var2.getCurrentEquippedItem().getItem() instanceof my_item ? new myGui(var2) : null;

    }

}

 

 

 

 

The "myGui" file is a normal GUIScreen class object.

 

 

Please i need HELP!!!

 

-----------

 

Solution (thanks to diesieben07 and opssemnik):

 

just using EntityPlayer.opengui(mod obj, gui id, x,y,z) function

 

Thanks

Posted

Ok,

 

thank you for reply.

 

I've replace the line 189 with this:

 

par3EntityPlayer.openGui(mymod.instance, 1, par2World, (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ);

 

But when i try to open the gui:

 

"A mod tried to open a gui on the server without being a NetworkMod"

 

my mod has 3 different gui classes but i dont know how to declare or refer the IDs

 

Into main class file it's declared this:

 

@NetworkMod(

clientSideRequired = true,

serverSideRequired = false,

channels = {"MyMod"},

packetHandler = ServerPacketHandler.class

)

 

Any suggestion?

 

 

Posted

What about your proxy classes?

Do you have commonProxy and clientProxy?

I'm going to assume that you're server is calling a client only method, that's why it is crashing!

The server should never handle client side things :)

 

Take a look at:

http://www.minecraftforge.net/wiki/Basic_Modding

It will help you setup the CommonProxy and ClientProxy files correctly.

While http://www.minecraftforge.net/wiki/Containers_and_GUIs may give you some more help inn calling the GUI and such.

If you guys dont get it.. then well ya.. try harder...

Posted

Yes, i've both ClientProxy and CommonProxy. I literally followed any mod guide line.

 

And my 3 GUI aren't container GUI.

 

But the error still happen.

 

There must be something wrong into the @NetworkMod declaration.

 

This my main mod class code:

 

 

 

package MyMod;

 

import net.minecraft.block.Block;

import net.minecraft.item.ItemStack;

import net.minecraft.item.Item;

 

import net.minecraftforge.common.Configuration;

import net.minecraftforge.common.EnumHelper;

import net.minecraftforge.common.Property;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;

import cpw.mods.fml.common.network.NetworkRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = "MyMod", name = "MyMod", version = "xxx")

 

@NetworkMod(

clientSideRequired = true,

serverSideRequired = false,

channels = {"MyMod"},

packetHandler = ServerPacketHandler.class

)

 

public class MyMod

{

    @Instance("MyMod")

    public static MyMod instance;

    public static GuiHandler guiHandler = new GuiHandler();

   

    @SidedProxy(

            clientSide = "MyMod.ClientProxy",

            serverSide = "MyMod.CommonProxy"

    )

   

    public static CommonProxy proxy;

   

    @PreInit

    public void preInit(FMLPreInitializationEvent var1)

    {

        //My config file

    }

 

    @Init

    public void load(FMLInitializationEvent event)

    {

    proxy.registerRenderers();

       

        //Registering GuiHandler

        NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());

       

        //declaring object

 

        //Registering Block

       

        //Adding ItemName

       

        // RECIPIES

 

    }

}

 

 

 

Proxies:

 

 

COMMONPROXY:

package MyMod

 

public class CommonProxy

{

    public static String ITEMS = "/gui/images.png";

 

    public void registerRenderers() {}

}

 

CLIENTPROXY:

package MyMod;

 

import net.minecraftforge.client.MinecraftForgeClient;

 

public class ClientProxy extends CommonProxy

{

    public void registerRenderers()

    {

    ITEMS = "/gui/images.png";

        MinecraftForgeClient.preloadTexture(ITEMS);

    }

}

 

 

 

And This is GuiHandler code:

 

 

 

package MyMod;

 

import cpw.mods.fml.common.network.IGuiHandler;

import net.minecraft.client.gui.GuiScreen;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.world.World;

 

public class GuiHandler implements IGuiHandler

{

@Override

    public Object getServerGuiElement(int var1, EntityPlayer var2, World var3, int var4, int var5, int var6)

    {

        switch (var1)

        {

            case 0:

            return new Gui1(var2);

 

            case 1:

            return new Gui2(var2);

 

            case 2:

            return new Gui3(var2);

 

        }

       

        return null;

    }

@Override

    public Object getClientGuiElement(int var1, EntityPlayer var2, World var3, int var4, int var5, int var6)

    {

        switch (var1)

        {

            case 0:

            return new Gui1(var2);

 

            case 1:

            return new Gui2(var2);

 

            case 2:

            return new Gui3(var2);

 

        }

       

        return null;

    }

}

 

 

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

    • I know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
  • Topics

×
×
  • Create New...

Important Information

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