So following the stacktrace, I can see that the issue comes from trying to load the class net/minecraft/client/multiplayer/WorldClient on the Server side...
The weird part is that I cannot find anywhere along the stacktrace that it is making this call, so I don't know how to change it. Code is as follows:
I figure, why not look in my register helper class and my BHH_Entites class... But I cannot find the problem. Here's the code for them, maybe somebody else can spot them.
BHH_Entities is creating a new EntityNPC using the client world (Minecraft#theWorld).
There's several things wrong with this:
Entities aren't singletons, each entity in the world is its own instance of the appropriate Entity class. Don't create an instance of an entity in the registration process, you need to register your Entity class rather than an instance of it.
Minecraft is a client-only class. Do not use it outside of client-only code (e.g. rendering), otherwise you'll crash the server.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So, it seems that there's more to it than just that mistake. Stacktrace is now complaining about not finding my ModelNPC class file, which is caused by:
ModelNPC derives from ModelBiped, so I figure it's just returning the failure to find ModelBiped to ModelNPC.
This problem is still only on the server, but it shouldn't have this in the first place because the Models are called with the renderer. The only time in code that I don't have that kind of thing in a RenderEntity or ModelEntity type of file is in my RegisterHelper. It's a static function that should only ever be called by the client, like so:
public static void registerRenderBlock(Block block)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(Reference.MOD_ID + ":" + block.getUnlocalizedName().substring(5), "inventory"));
}
public static void registerRenderItem(Item item)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
public static void registerRenderNPC(Class classIn)
{
RenderingRegistry.registerEntityRenderingHandler(classIn, new RenderNPC(new ModelNPC(), 1.0F));
}
}
I feel like the problem may be that the RegisterHelper is used in Common, so it loads the file for common and looks for the client dependencies, even though it won't run that code. It fails to find the dependencies, and thus the server crashes. If this sounds right, I'd love suggestions on how to fix it. If not, what am I doing wrong here?
If the render registration methods are only ever called from the client side, they shouldn't crash the dedicated server. Could you post the full crash report?
In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
It's much easier to read code with proper formatting and syntax highlighting.
Why are you using 1.8.8? It's trivial to update to 1.8.9, which offers various new features like registry name methods for Block/Item and the capability system.
When you update to 1.8.9, use Block#setRegistryName to set a block's registry name and GameRegistry.registerBlock(Block) to register it using that name. The same applies to items.
Don't use unlocalised names for your models, use registry names (block.getRegistryName() in 1.8.9 or Block.blockRegistry.getNameForObject(block).toString() in 1.8/1.8.8, also the same for items).
I would highly recommend having one class each to register and store your blocks, items and entities (with all the registration logic contained in these classes); one class to register your block/item models and another to register your entity renderers.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Fixed the issues in my move to 1.8.9, however, in the process I messed up my custom renderer for my NPC. No errors, just a big white box instead of what should look like a standard player render.
Since it's now a different problem and a different version, I'll leave this thread here, but start a new one for the issue at hand.
So following the stacktrace, I can see that the issue comes from trying to load the class net/minecraft/client/multiplayer/WorldClient on the Server side...
The weird part is that I cannot find anywhere along the stacktrace that it is making this call, so I don't know how to change it. Code is as follows:
BH_HousingMod.java----
package com.bluehex.bh_housing;
import com.bluehex.bh_housing.proxy.CommonProxy;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
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;
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class BH_HousingMod
{
public static BH_HousingMod instance = new BH_HousingMod();
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
proxy.preInit();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
proxy.init();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
proxy.postInit();
}
}
Stacktrace says problem on CommonProxy.init(), so let's look there...
CommonProxy.java------
package com.bluehex.bh_housing.proxy;
import com.bluehex.bh_housing.common.init.BHH_Blocks;
import com.bluehex.bh_housing.common.init.BHH_Entities;
import com.bluehex.bh_housing.common.init.BHH_Items;
import com.bluehex.bh_housing.common.init.BHH_Recipes;
public class CommonProxy
{
public void preInit()
{
BHH_Blocks.registerBlocks();
BHH_Items.registerItems();
BHH_Recipes.registerRecipes();
}
public void init()
{
}
public void postInit()
{
}
}
Stacktrace stops at BHH_Entities.registerEntities(); and gives the following error:
net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient
........
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient
I figure, why not look in my register helper class and my BHH_Entites class... But I cannot find the problem. Here's the code for them, maybe somebody else can spot them.
BHH_Entities.java-------
package com.bluehex.bh_housing.common.init;
import com.bluehex.bh_housing.common.entity.EntityNPC;
import com.bluehex.bh_housing.helpers.RegisterHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.common.Mod;
public class BHH_Entities
{
public static void registerEntities()
{
public static void registerRenderEntities()
{
}
RegisterHelper.java-------
package com.bluehex.bh_housing.helpers;
import com.bluehex.bh_housing.BH_HousingMod;
import com.bluehex.bh_housing.Reference;
import com.bluehex.bh_housing.client.model.ModelNPC;
import com.bluehex.bh_housing.client.renderer.RenderNPC;
import com.bluehex.bh_housing.common.entity.EntityNPC;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class RegisterHelper
{
{
public static void registerItem(Item item)
{
public static void registerEntity(int id, Entity entityIn, int eggPrimary, int eggSecondary)
{
EntityRegistry.registerEgg(entityIn.getClass(), eggPrimary, eggSecondary);
public static void registerRenderBlock(Block block)
{
public static void registerRenderItem(Item item)
{
public static void registerRenderEntity(Entity entity)
{
}
BHH_Entities is creating a new EntityNPC using the client world (Minecraft#theWorld).
There's several things wrong with this:
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
That's where I saw my Minecraft.getMinecraft().theWorld call!!! Thank you!
Now on to the next bug, eh?
So, it seems that there's more to it than just that mistake. Stacktrace is now complaining about not finding my ModelNPC class file, which is caused by:
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.model.ModelBiped
ModelNPC derives from ModelBiped, so I figure it's just returning the failure to find ModelBiped to ModelNPC.
This problem is still only on the server, but it shouldn't have this in the first place because the Models are called with the renderer. The only time in code that I don't have that kind of thing in a RenderEntity or ModelEntity type of file is in my RegisterHelper. It's a static function that should only ever be called by the client, like so:
RegisterHelper.java-------
package com.bluehex.bh_housing.helpers;
import com.bluehex.bh_housing.BH_HousingMod;
import com.bluehex.bh_housing.Reference;
import com.bluehex.bh_housing.client.model.ModelNPC;
import com.bluehex.bh_housing.client.renderer.RenderNPC;
import com.bluehex.bh_housing.common.entity.EntityNPC;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class RegisterHelper
{
{
public static void registerItem(Item item)
{
public static void registerEntity(int id, Class classIn, String name, int eggPrimary, int eggSecondary)
{
EntityRegistry.registerEgg(classIn, eggPrimary, eggSecondary);
public static void registerRenderBlock(Block block)
{
public static void registerRenderItem(Item item)
{
public static void registerRenderNPC(Class classIn)
{
}
I feel like the problem may be that the RegisterHelper is used in Common, so it loads the file for common and looks for the client dependencies, even though it won't run that code. It fails to find the dependencies, and thus the server crashes. If this sounds right, I'd love suggestions on how to fix it. If not, what am I doing wrong here?
If the render registration methods are only ever called from the client side, they shouldn't crash the dedicated server. Could you post the full crash report?
In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
It's much easier to read code with proper formatting and syntax highlighting.
Why are you using 1.8.8? It's trivial to update to 1.8.9, which offers various new features like registry name methods for Block/Item and the capability system.
When you update to 1.8.9, use Block#setRegistryName to set a block's registry name and GameRegistry.registerBlock(Block) to register it using that name. The same applies to items.
Don't use unlocalised names for your models, use registry names (block.getRegistryName() in 1.8.9 or Block.blockRegistry.getNameForObject(block).toString() in 1.8/1.8.8, also the same for items).
I would highly recommend having one class each to register and store your blocks, items and entities (with all the registration logic contained in these classes); one class to register your block/item models and another to register your entity renderers.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I think I'll go about that move to 1.8.9 and then see if I don't fix the problem at the same time. I'll be back after the migration.
Fixed the issues in my move to 1.8.9, however, in the process I messed up my custom renderer for my NPC. No errors, just a big white box instead of what should look like a standard player render.
Since it's now a different problem and a different version, I'll leave this thread here, but start a new one for the issue at hand.
Edit: Link to new issue: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2610305-1-8-9-entities-with-custom-renderer-is-rendering