Jump to content

[1.12.2] Mod Crashes on Server, but Not Client


RileyTheFox

Recommended Posts

Hello there! It's been a decent time since I've worked on my mod, seeing as the changes in 1.12 broke almost everything in it. At this point, I was ecstatic as it seemed I had gotten it running again! However, I've been encountering a game-breaking issue that I can't wrap my head around enough to solve.

Whenever I start my mod within a server- even a server with only my mod- it crashes with a java.lang.NoClassDefFoundError. From what I have seen in the crash report (https://pastebin.com/ru6U5zhH) and from what I have seen browsing for an answer here on the Forge Forums, it seems as though I have made a mistake by rendering my entities server-side rather than client-side. Though I've seen that I need to render my own entities through the client proxy, I can't seem to find out exactly how I am supposed to do so due to the changes to coding in 1.12 and my own taking a break which has made me rusty. 

 

All I am asking for is some advice on what I am doing wrong, or what I should do. I am by no means "new" to coding, and I've coded this mod much further before, but I am terribly rusty and need help trying to figure out this error. 

 

The class that's giving the error according to the log is as follows.

package riley.fallenstars.utils.handlers;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import riley.fallenstars.entities.EntityChinchilla;
import riley.fallenstars.entities.EntityFox;
import riley.fallenstars.entities.EntityShepherd;
import riley.fallenstars.entities.render.RenderChinchilla;
import riley.fallenstars.entities.render.RenderFox;
import riley.fallenstars.entities.render.RenderShepherd;

public class RenderHandler
{
    public static void registerEntityRenders()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityFox.class, new IRenderFactory<EntityFox>()
        {
            @Override
            public Render<? super EntityFox> createRenderFor(RenderManager renderManager)
            {
                return new RenderFox(renderManager);
            }
        });
        RenderingRegistry.registerEntityRenderingHandler(EntityChinchilla.class, new IRenderFactory<EntityChinchilla>()
        {
            @Override
            public Render<? super EntityChinchilla> createRenderFor(RenderManager renderManager)
            {
                return new RenderChinchilla(renderManager);
            }
        });
        RenderingRegistry.registerEntityRenderingHandler(EntityShepherd.class, new IRenderFactory<EntityShepherd>()
        {
            @Override
            public Render<? super EntityShepherd> createRenderFor(RenderManager renderManager)
            {
                return new RenderShepherd(renderManager);
            }
        });
    }
}

If there is anything else I should link according to the crash report or other needed info; I am more than willing to do so. A huge thank you for any help in advance, and I look forward to finding an answer so that I may finally work on restoring my little mod to it's former state.

Link to comment
Share on other sites

And where do you call this code from?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

6 minutes ago, Draco18s said:

And where do you call this code from?

Apologies. I call the RenderHandler from my Registry Handler here:
 

package riley.fallenstars.utils.handlers;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import riley.fallenstars.init.FallenStarsBlocks;
import riley.fallenstars.init.FallenStarsEntities;
import riley.fallenstars.init.FallenStarsItems;
import riley.fallenstars.utils.IHasModel;

@Mod.EventBusSubscriber
public class RegistryHandler
{
    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll(FallenStarsItems.ITEMS.toArray(new Item[0]));
    }

    @SubscribeEvent
    public static void onBlockRegister(RegistryEvent.Register<Block> event)
    {
        event.getRegistry().registerAll(FallenStarsBlocks.BLOCKS.toArray(new Block[0]));
    }

    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event)
    {
        for (Item item : FallenStarsItems.ITEMS)
        {
            if (item instanceof IHasModel)
            {
                ((IHasModel)item).registerModels();
            }
        }

        for (Block block : FallenStarsBlocks.BLOCKS)
        {
            if (block instanceof IHasModel)
            {
                ((IHasModel)block).registerModels();;
            }
        }
    }

    public static void preInitRegistries()
    {
        FallenStarsEntities.registerEntities();
        RenderHandler.registerEntityRenders();
    }

    public static void initRegistries()
    {
        SoundsHandler.registerSounds();
    }
}

 

Which the "preInitRegistries()" method is then called from my main class under it's preInit. Here's the main class as well, just in case:
 

package riley.fallenstars;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import riley.fallenstars.init.FallenStarsTab;
import riley.fallenstars.proxy.CommonProxy;
import riley.fallenstars.utils.Reference;
import riley.fallenstars.utils.handlers.RegistryHandler;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
public class FallenStars
{
    @Mod.Instance
    public static FallenStars instance;

    public static final CreativeTabs fallenstarstab = new FallenStarsTab("fallenstarstab");

    @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
    public static CommonProxy proxy;

    @Mod.EventHandler
    public static void preInit(FMLPreInitializationEvent event)
    {
        RegistryHandler.preInitRegistries();
    }

    @Mod.EventHandler
    public static void init(FMLInitializationEvent event)
    {
        RegistryHandler.initRegistries();
    }

    @Mod.EventHandler
    public static void postInit(FMLPostInitializationEvent event) {}
}

 

I've been following some videos to somewhat refresh myself and to learn the changes in forge different from 1.10.2. So apologies if it's at all wrong. That's why I'm here to see, I assume I did something wrong here and I kinda understand what I did wrong but am unsure how to fix it.

Link to comment
Share on other sites

You call this from common code:

2 minutes ago, RileyTheFox said:

RegistryHandler.preInitRegistries();

This calls:

2 minutes ago, RileyTheFox said:

RenderHandler.registerEntityRenders();

This calls

35 minutes ago, RileyTheFox said:

RenderingRegistry.registerEntityRenderingHandler(EntityFox.class, new IRenderFactory<EntityFox>()

which is a class located at

35 minutes ago, RileyTheFox said:

import net.minecraftforge.fml.client.registry.RenderingRegistry;

Oops, that's client side only. Server has crashed.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 minutes ago, Draco18s said:

You call this from common code:

This calls:

This calls

which is a class located at

Oops, that's client side only. Server has crashed.

Alright, thank you so much. That actually helps me understand it a whole lot better than I was. So to fix it, would I have to change the fact that in the main class it's calling for common proxy? Or is there a better solution to this?

Link to comment
Share on other sites

I'm very sorry for the double post. I tried fixing the issue by calling it from my ClientProxy instead though now I am met with this crash:
https://pastebin.com/bnfCpfNj

My client proxy looks like this now:

package riley.fallenstars.proxy;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import riley.fallenstars.utils.handlers.RenderHandler;

public class ClientProxy implements CommonProxy
{
    @Override
    public void registerItemRenderer(Item item, int meta, String id)
    {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id));
    }

    @Override
    public void init()
    {
        RenderHandler.registerEntityRenders();
    }
}

 

I moved the RenderHandler.registerEntityRenders() from the RegistryHandler (which from what I understand from your response was being called to the common rather than to the client) to the ClientProxy instead. I'm still unsure and am baffled as to what I'm doing wrong as I referenced my old code from 1.10 this time just to try and get an idea. I feel like that idea is wrong, unless I'm getting closer? I really can't tell at this point. 

 

Again, apologies for double-posting. Just wanted to update on what I did/tried.

Link to comment
Share on other sites

No, that is correct.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.



×
×
  • Create New...

Important Information

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