Jump to content

[1.7.10] Testing mod in Eclipse on Server - Crash from my network registry


Thornack

Recommended Posts

Hi everyone,

 

I want to try to run my mod on a server then join the server from a client to test whether everything works. The IDE I am using is Eclipse Luna, (ive never tried this before so I may be doing something wrong) but when I hit the Run Server I get a  java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityClientPlayerMP

 

The crash Report (ive included the code snippets and their methods that are found in the crash report)

 

 

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityClientPlayerMP

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

... 42 more

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/EntityClientPlayerMP for invalid side SERVER

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) ~[forgeSrc-1.7.10-10.13.2.1230.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

... 42 more

[12:45:19] [server thread/ERROR]: Encountered an unexpected exception

java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/EntityClientPlayerMP for invalid side SERVER

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) ~[forgeSrc-1.7.10-10.13.2.1230.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]

at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.7.0_25]

at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) ~[?:1.7.0_25]

at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.7.0_25]

at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_25]

at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:113) ~[simpleNetworkWrapper.class:?]

at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:106) ~[simpleNetworkWrapper.class:?]

at custommod.network.CustomModNetworkRegistry.registerMessage(CustomModNetworkRegistry.java:22) ~[CustomModNetworkRegistry.class:?]

       

/// CustomModNetworkRegistry.java:22 is this line---> network.registerMessage(message, message, networkChannelID++, Side.SERVER);

it is found in this method

public static final <T extends CustomModAbstractMessage<T> & IMessageHandler<T, IMessage>> 
	void registerMessage(Class<T> message){
	network.registerMessage(message, message, networkChannelID++, Side.SERVER);
	network.registerMessage(message, message, networkChannelID++, Side.CLIENT);
}

 

at custommod.network.CustomModNetworkRegistry.registerAllMessages(CustomModNetworkRegistry.java:33) ~[CustomModNetworkRegistry.class:?]

 

/// CustomModNetworkRegistry.java:33 is this line---> registerMessage(MessageUpdateSpawnerRates.class);

it is found in this method

//register all packet types used in our mod
private static void registerAllMessages(){
	registerMessage(MessageUpdateSpawnerRates.class);
	registerMessage(MessageUpdateSpawnerExtraOptions.class);
	registerMessage(MessageUpdateState.class);
	registerMessage(MessageSolved.class);
	registerMessage(MessageJump.class);
	registerMessage(MessageUpdateStats.class);
}

 

at custommod.network.CustomModNetworkRegistry.init(CustomModNetworkRegistry.java:17) ~[CustomModNetworkRegistry.class:?]

 

/// CustomModNetworkRegistry.java:17 is this line:  registerAllMessages(););

it is found in this method

public static void init(){
	networkChannelID = 0;
	network = NetworkRegistry.INSTANCE.newSimpleChannel("custommod");
	registerAllMessages();
}

 

at custommod.CustomMod.preInit(CustomMod.java:49) ~[CustomMod.class:?]

 

CustomMod.java:49 this is in my main mod class and is this line --->CustomModNetworkRegistry.init();

@EventHandler
public void preInit(FMLPreInitializationEvent preEvent) {
	this.instance = this;
	commonProxy.preInit(); // Things are now delegated to CommonProxy 

	//register messages
   CustomModNetworkRegistry.init();
}

 

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]

at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]

at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513) ~[Loader.class:?]

... 5 more

Link to comment
Share on other sites

Client code present on dedicated server.  Fix yo shit.

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

Anything inside a package called "client" is for the client only and is marked @SideOnly(Side.CLIENT)

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

Okay, it is a bit complicated but important to understand when modding. Minecraft is a client-server game, but such games often run a lot of code on the client in parallel with the server in order to prevent stuttering and lag due to network issues. But there is some code that only runs on the client and some that only runs on the server. To save memory space (I guess that's the reason), Minecraft only loads some classes on one side. If it is not on the side, Java can't see it and you'll get the class not found exception.

 

However, a further complication is that when you run the game "client" it also runs a server and does it in the same Java executable. This means that the sided classes are actually loaded for both sides. So some code might appear to behave when you really did it wrong.

 

Anyway, one of the solutions is to use the right classes. And furthermore there is a mechanism called the "proxy" which can help you collect methods that depend on sided classes so they only load what is appropriate.

 

I have a tutorial on some of this here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-17217x-quick-tips-for.html

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

my Abstract Message Class

 

I do have a reference to client side in my abstract message class


public abstract class CustomModAbstractMessage<T extends IMessage> implements IMessage, IMessageHandler<T, IMessage>{

@Override
public IMessage onMessage(T message, MessageContext ctx) {
	if (ctx.side == Side.CLIENT) {
		return handleClientMessage(Minecraft.getMinecraft().thePlayer, message, ctx);
	} else {
		return handleServerMessage(ctx.getServerHandler().playerEntity, message, ctx);
	}
}

public void sendToServer(){
	PWNetworkRegistry.getNetwork().sendToServer(this);
}

public void sendTo(EntityPlayerMP player){
	PWNetworkRegistry.getNetwork().sendTo(this, player);
}

public void sendToAll(){
	PWNetworkRegistry.getNetwork().sendToAll(this);
}

public void sendToDimension(int dimensionId){
	PWNetworkRegistry.getNetwork().sendToDimension(this, dimensionId);
}

public abstract void fromBytes(ByteBuf buf);

public abstract void toBytes(ByteBuf buf);

public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx);

public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx);

}

Link to comment
Share on other sites

return handleClientMessage(Minecraft.getMinecraft().thePlayer, message, ctx);

 

Oh jesus christ.  The server still has to LOAD the code for this class and make sure it's valid.  It can't do that if you include a reference to a client sided object.

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

So in Client Proxy do something like

 

public static EntityPlayer getPlayer(){

return Minecraft.getMinecraft().thePlayer;

}

 

and then in my abstract message class

 

if (ctx.side == Side.CLIENT) {

return handleClientMessage(ClientProxy.getPlayer(), message, ctx);

}

Link to comment
Share on other sites

I get the following crash

 

[14:07:03] [main/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!

[14:07:03] [main/WARN] [FML]: Offendor: net/minecraft/server/gui/MinecraftServerGui$1.windowClosing(Ljava/awt/event/WindowEvent;)V

[14:07:03] [main/WARN] [FML]: Use FMLCommonHandler.exitJava instead

[14:07:03] [main/WARN] [FML]: =============================================================

[14:07:03] [server thread/INFO]: Starting minecraft server version 1.7.10

[14:07:03] [server thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization

[14:07:03] [server thread/INFO] [FML]: MinecraftForge v10.13.2.1230 Initialized

[14:07:03] [server thread/INFO] [FML]: Replaced 182 ore recipies

[14:07:03] [server thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization

[14:07:04] [server thread/INFO] [FML]: Searching C:\Users\{Lukasz\Desktop\modding\CustomMod_1.7.10\eclipse\mods for mods

[14:07:09] [server thread/INFO] [FML]: Forge Mod Loader has identified 6 mods to load

[14:07:10] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, custommod] at CLIENT

[14:07:10] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, custommod] at SERVER

[14:07:10] [server thread/INFO] [FML]: Processing ObjectHolder annotations

[14:07:10] [server thread/INFO] [FML]: Found 341 ObjectHolder annotations

[14:07:10] [server thread/INFO] [FML]: Configured a dormant chunk cache size of 0

[14:07:11] [server thread/INFO] [FML]: Applying holder lookups

[14:07:11] [server thread/INFO] [FML]: Holder lookups applied

[14:07:11] [server thread/INFO]: Loading properties

[14:07:11] [server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

[14:07:11] [server thread/WARN] [FML]: Can't revert to frozen GameData state without freezing first.

[14:07:11] [server thread/INFO] [FML]: Applying holder lookups

[14:07:11] [server thread/INFO] [FML]: Holder lookups applied

[14:07:11] [server thread/INFO] [FML]: The state engine was in incorrect state POSTINITIALIZATION and forced into state SERVER_STOPPED. Errors may have been discarded.

Link to comment
Share on other sites

Its funny what reading does.

 

 

[14:07:11] [server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

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

Ok I have found the EULA bit and fixed that but I do have another question. I have an event handler that is crashing the server. how would I get around this. I believe it does have to be Client side only but am not positive

 

the event handler in question

@SideOnly(Side.CLIENT)
public class EventPlayerInBatlle extends GuiScreen
{
private Minecraft mc;

private static final ResourceLocation customTexture = new ResourceLocation("custommod:textures/gui/custom.png");
private static final ResourceLocation custom2Texture = new ResourceLocation("custommod:textures/gui/custom2.png");

public EventPlayerInBatlle(Minecraft mc) {
	super();
	this.mc = mc;
	}
// here I include the following events

@SubscribeEvent(priority=EventPriority.NORMAL)
public void onRenderPre(RenderGameOverlayEvent.Pre event) {
}

@SubscribeEvent(priority=EventPriority.NORMAL)
public void RenderHUD(RenderGameOverlayEvent.Post event) {
}
@SubscribeEvent
public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) {
}

@SubscribeEvent
public void hurt (LivingHurtEvent event){
{

 

[EDIT] This handler is registered in a registerEvents method inside my CommonpProxy where the registerEvents Method is called inside Common Proxies Init method and Init() is called from MainModClass.java inside its

 

@EventHandler

public void init(FMLInitializationEvent event) {}

 

method

Link to comment
Share on other sites

This is the last of it I commented out my event and the server loaded the world (I cant seem to be able to join it though i get a Failed to login: Invalid session (Try restarting your game) message when I click join local host server after I start up my mod from eclipse on server then on client (and try to join the server it shows up with a green checkmark though).

 

the consol reads the following

 

[14:45:04] [server thread/INFO]: com.mojang.authlib.GameProfile@250f0723[id=<null>,name=Player303,properties={},legacy=false] (/(AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected

[14:45:11] [server thread/INFO]: com.mojang.authlib.GameProfile@4e119084[id=<null>,name=Player303,properties={},legacy=false] (/AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected

[14:46:16] [server thread/INFO]: com.mojang.authlib.GameProfile@6067de8[id=<null>,name=Player941,properties={},legacy=false] (/AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected

Link to comment
Share on other sites

Try putting the registration of the event handler in your client proxy?

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.