Jump to content

Server failed to start


Tavi007

Recommended Posts

Hello,

I wanted try my mod in a server enviroment, but it crashed on startup. Here is the crash log:

 

-- Head --
Thread: main
Stacktrace:
        at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[forge-1.16.4-35.1.4.jar:35.1] {}
-- MOD elementalcombat --
Details:
        Mod File: elementalcombat-forge-1.16.4-1.0.jar
        Failure message: Elemental Combat (elementalcombat) encountered an error during the common_setup event phase
                java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER
        Mod Version: 1.0
        Mod Issue URL: NOT PROVIDED
        Exception message: java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER
Stacktrace:
        at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[forge-1.16.4-35.1.4.jar:35.1] {}
        at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) ~[modlauncher-8.0.6.jar:?] {}
        at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:119) ~[modlauncher-8.0.6.jar:?] {}
        at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) ~[modlauncher-8.0.6.jar:?] {}
        at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) ~[modlauncher-8.0.6.jar:?] {re:classloading}
        at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-8.0.6.jar:?] {re:classloading}
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.invoke.MethodHandleNatives.resolve(Native Method) ~[?:1.8.0_271] {}
        at java.lang.invoke.MemberName$Factory.resolve(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.invoke.MemberName$Factory.resolveOrFail(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(Unknown Source) ~[?:1.8.0_271] {}
        at Tavi007.ElementalCombat.StartupCommon.onCommonSetup(StartupCommon.java:29) ~[elementalcombat:1.16.4-1.0] {re:classloading}
        at net.minecraftforge.eventbus.ASMEventHandler_2_StartupCommon_onCommonSetup_FMLCommonSetupEvent.invoke(.dynamic) ~[?:?] {}
        at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-3.0.5-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.5-service.jar:?] {}
        at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:120) ~[forge:35.1] {re:classloading}
        at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:121) ~[forge:?] {re:classloading}
        at java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[?:1.8.0_271] {}


and here is the failing file:
 

package Tavi007.ElementalCombat;

import Tavi007.ElementalCombat.capabilities.defense.DefenseDataCapability;
import Tavi007.ElementalCombat.network.EntityMessage;
import Tavi007.ElementalCombat.network.ItemMessage;
import Tavi007.ElementalCombat.network.PackageHandlerOnClient;
import Tavi007.ElementalCombat.network.PackageHandlerOnServer;

import java.util.Optional;

import Tavi007.ElementalCombat.capabilities.attack.AttackDataCapability;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkRegistry;

public class StartupCommon {
	private static final byte ENTITYDATA_MESSAGE_TO_CLIENT_ID = 1; 
	private static final byte ITEMDATA_MESSAGE_TO_CLIENT_ID = 2; 
	public static final String MESSAGE_PROTOCOL_VERSION = "1.0"; 
	
	@SubscribeEvent
	public static void onCommonSetup(FMLCommonSetupEvent event){
		//capabilities
		AttackDataCapability.register();
		DefenseDataCapability.register();

		//networking
		ElementalCombat.simpleChannel = NetworkRegistry.newSimpleChannel(ElementalCombat.simpleChannelRL, () -> MESSAGE_PROTOCOL_VERSION,
				PackageHandlerOnClient::isThisProtocolAcceptedByClient,
				PackageHandlerOnServer::isThisProtocolAcceptedByServer);
		
		ElementalCombat.simpleChannel.registerMessage(ENTITYDATA_MESSAGE_TO_CLIENT_ID, EntityMessage.class,
				EntityMessage::encode, EntityMessage::decode,
				PackageHandlerOnClient::onMessageReceived,
	            Optional.of(NetworkDirection.PLAY_TO_CLIENT));

		ElementalCombat.simpleChannel.registerMessage(ITEMDATA_MESSAGE_TO_CLIENT_ID, ItemMessage.class,
				ItemMessage::encode, ItemMessage::decode,
				PackageHandlerOnClient::onMessageReceived,
	            Optional.of(NetworkDirection.PLAY_TO_CLIENT));
		
		ElementalCombat.LOGGER.info("setup method registered.");
	}

}


Line 29 is the one right below the comment '//networking'. I don't understand, why the game tries to load ClientPlayerEntity here. Also this part was actually working in previous version of my mod (see here: https://github.com/Tavi007/ElementalCombat/blob/master/src/main/java/Tavi007/ElementalCombat/StartupCommon.java), tho this was for minecraft 1.16.3.

Link to comment
Share on other sites

Might be because you tried to load the ClientPlayerEntity on the server:

https://github.com/Tavi007/ElementalCombat/blob/cbd2054ce35659d97fb9ff7a100e0b5f39df0ecd/src/main/java/Tavi007/ElementalCombat/network/PackageHandlerOnClient.java#L63

 

You should properly side off your client code within another class, not the packet handler itself. The handling can be with the message itself, you can then enqueue work and use DistExecutor to force it to run only on the physical client. This will guarantee that the physical client and server are isolated.

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.