Jump to content

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


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

 

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

 

Thanks

Posted

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;

    }

}

 

 

Posted

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

:-\

 

 

 

Posted

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

 

 

Posted

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

 

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

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
  • Topics

×
×
  • Create New...

Important Information

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