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



×
×
  • Create New...

Important Information

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