Jump to content

Recommended Posts

Posted

Hello guy,

I started programming mod very recently and i'm facing a problem with the port of my mod on server.
Many peoples told that the mod is nowaday universal and works both on client and on server.
However, the server refuse tu start because of java.lang.NoSuchMethodError on my registerRender() method.

I specify i put the   " @SideOnly(Side.CLIENT)" before but nothing change.

I hope you can help me and thank you

error_eclipse.txt

Posted

There is a section for modder support, it would probably be better if you posted there:

http://www.minecraftforge.net/forum/forum/70-modder-support/

 

As for your problem, it's difficult to help you without being able to see your actual code. But from what I'm getting you need to use proxies:

https://mcforge.readthedocs.io/en/latest/concepts/sides/

A common use case is to register renderers and models, something which must be called from the main initialization methods preInit, init, or postInit. However, many rendering related classes and registries are not present on the physical server and may crash it. Therefore, we put these actions into the client proxy, ensuring that they will always execute for the physical client.

 

Here is what I do:

My @Mod class:

https://github.com/Kriptikz/Archmage/blob/1.11.2/src/main/java/kriptikz/archmage/Archmage.java

 

My ClientProxy where I register renders for Entities:

https://github.com/Kriptikz/Archmage/blob/1.11.2/src/main/java/kriptikz/archmage/proxy/ClientProxy.java#L29

Posted (edited)

The problem is when you call new ModItems(); in your common proxy preInit. Which ofc calls the constructor you made in ModItems() which calls initItems(); registerItems(); and registerRenders();  which means your calling registerRenders() in your common proxy preInit. You can only register renders on the client, so this method should only be called in your client proxy. I explain the steps to fix up your code below:

 

First get rid of this constructor:

https://github.com/TheCaliban/CaliArmor/blob/master/src/main/java/com/mod/CaliArmor/init/ModItems.java#L29-L34

 

And make all your methods in ModItems static.

 

Then instead of creating an instance here:

https://github.com/TheCaliban/CaliArmor/blob/master/src/main/java/com/mod/CaliArmor/proxy/CommonProxy.java#L9

 

do this:

public class CommonProxy
{
	public void preInit()
	{
        // Get rid of this, as methods should be all static now
        //new ModItems();

        // initialize items
        ModItems.initItems();

        // register items
        ModItems.registerItems();
      
	}
	public void Init()
	{
		new ModRecipes().registerCraftRecipes();
		new ModRecipes().registerFurnaceRecipes();
		new ModRecipes().registerBrewingRecipes();
	}
}

 

Then for your ClientProxy:

public class ClientProxy extends CommonProxy
{
	@Override
	public void preInit()
	{
            super.preInit();
        
            // register renders
            ModItems.registerRenders();
	}
	@Override
	public void Init()
	{
		super.Init();
	}
}

 

Edited by Kriptikz

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.