Jump to content

[Solved] Server crash java.lang.NoClassDefFoundError: GUIScreen


zedblade

Recommended Posts

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):

 

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

 

Thanks

Link to comment
Share on other sites

Well,

 

I tried your method but still happen same error:

 

FMLCommonHandler.instance().showGuiScreen(new GuiHandler().getClientGuiElement(mymod.myGuiID1, par3EntityPlayer, par2World, (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ));

 

Also I tried using FMLClientHandler:

 

FMLClientHandler.instance().showGuiScreen(new GuiHandler().getClientGuiElement(mymod.myGuiID1, par3EntityPlayer, par2World, (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ));

 

Error: Exception in server tick loop

 

java.lang.NoClassDefFoundError: mymod/myGui1

at mymod.ClientProxy.openClientGui(ClientProxy.java:28)

 

 

This is the HandlerGui code:

 

 

 

package mymod;

 

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

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)

    {

        return null;

    }

@Override

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

    {

 

return new ClientProxy().openClientGui(var1, var2);

 

//        switch (var1)

//        {

//            case 0:

//            return new myGui1(var2);

//

//            case 1:

//            return new myGui2(var2);

//

//            case 2:

//            return new myGui3(var2);

//

//        }

//       

//        return null;

    }

}

 

 

 

ClientProxy code:

 

 

 

package mymod;

 

//import cpw.mods.fml.common.network.Player;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.network.INetworkManager;

import net.minecraft.network.packet.Packet250CustomPayload;

import net.minecraftforge.client.MinecraftForgeClient;

 

public class ClientProxy extends CommonProxy

{

    public void registerRenderers()

    {

    ITEMS = "/gui/images.png";

        MinecraftForgeClient.preloadTexture(ITEMS);

    }

   

    public Object openClientGui(int var1, EntityPlayer var2)

    {

        switch (var1)

        {

            case 0:

            return new myGui1(var2);

 

            case 1:

            return new myGui2(var2);

 

            case 2:

            return new myGui3(var2);

 

        }

       

        return null;

    }

}

 

 

 

CommonProxy code:

 

 

 

package mymod;

 

import net.minecraft.entity.player.EntityPlayer;

 

public class CommonProxy

{

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

 

    public void registerRenderers() {}

   

    public Object openClientGui(int var1, EntityPlayer var2)

    {

        return null;

    }

}

 

 

Link to comment
Share on other sites

Sure, I also tried that.

 

But occurs another error:

 

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

 

And this wont work.

 

Into main mod class file it's declared this:

 

@NetworkMod(

clientSideRequired = true,

serverSideRequired = false,

channels = {"MyMod"},

packetHandler = ServerPacketHandler.class

)

 

Into my_item right_click event there was:

 

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

 

Please anyone can show me a working example of gui open on the server side???

:-\

 

 

 

Link to comment
Share on other sites

this is my main mod class:

 

 

 

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;

   

    public static int myGuiID1 = 0;

    public static int myGuiID2 = 1;

    public static int myGuiID3 = 2;

 

    @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

 

    }

}

 

 

 

GuiHandler class:

 

 

package mymod;

 

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

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)

    {

        return null;

    }

@Override

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

    {

        switch (var1)

        {

            case 0:

            return new myGui1(var2);

 

            case 1:

            return new myGui2(var2);

 

            case 2:

            return new myGui3(var2);

 

        }

       

        return null;

    }

}

 

 

 

Line into my_item right_click event:

 

 

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

 

or

 

par3EntityPlayer.openGui(mymod.instance, mymod.myGuiID1, par2World, 0, 0, 0);

 

 

Link to comment
Share on other sites

You are AWESOME!!!

 

my ModID into @instance("MyMod") was wrong!!!

 

Now the Gui is open but can't play the sound in it:

 

varWorld.playSoundEffect(var10 + 0.5D, var11 + 1.0D, var12 + 0.5D, "mob.blaze.death", 1.0F, 1.0F);

 

won't play...

 

Also the line into the Gui don't work anymore:

 

varWorld.setBlockWithNotify(X, Y, Z, mymod.myblockID);

 

???:o

 

Seems a server notify issue ...

 

Link to comment
Share on other sites

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.