Bassebombecraft

Bassebombecraft

18.5k Downloads

Starting mod at server side fails due to attempt to load client side class net/minecraft/client/entity/player/ClientPlayerEntity from server side class MobRespawningEffectEventHandler.

Closed this issue ยท 2 comments

commented

Class net/minecraft/client/entity/player/ClientPlayerEntity is attempted to be loaded from class MobRespawningEffectEventHandler.

Stack trace:

[13Apr2020 21:02:26.803] [Server thread/ERROR] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: Exception caught during firing event: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER
	Index: 1
	Listeners:
		0: NORMAL
		1: ASM: class bassebombecraft.event.potion.MobRespawningEffectEventHandler handleLivingDeathEvent(Lnet/minecraftforge/event/entity/living/LivingDeathEvent;)V
		2: ASM: class bassebombecraft.event.entity.team.TeamMembershipEventHandler handleLivingDeathEvent(Lnet/minecraftforge/event/entity/living/LivingDeathEvent;)V
		3: ASM: class bassebombecraft.event.entity.target.TargetedEntitiesEventHandler handleLivingDeathEvent(Lnet/minecraftforge/event/entity/living/LivingDeathEvent;)V
		4: ASM: class bassebombecraft.event.charm.CharmedMobEventHandler handleEvent(Lnet/minecraftforge/event/entity/living/LivingDeathEvent;)V
java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER
	at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClass(RuntimeDistCleaner.java:71)
	at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:103)
	at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85)
	at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115)
	at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:239)
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:126)
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:96)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at bassebombecraft.event.potion.MobRespawningEffectEventHandler.handleLivingDeathEvent(MobRespawningEffectEventHandler.java:42)


commented

The logic is implemented with the assumption that the server is a single player. Furthermore the logic is written from a client side perspective:

	public static void handleLivingDeathEvent(LivingDeathEvent event) {

		// exit if player isn't defined
		if (!isPlayerDefined())
			return;

		// get player
		PlayerEntity player = getPlayer();

		// exit if effect isn't active
		Optional<EffectInstance> optEffect = getEffectIfActive(player, MOB_RESPAWNING_EFFECT);
		if (!optEffect.isPresent())
			return;

The logic should be rewritten to make no assumption about the number of players and from a server side perspective:

  1. Query if there is a player in the vicinity.
  2. Query if a player (in the vicinity) has the mob respawning effect active
commented

Resolved by removing the mob respawning potion (#705 ) and replacing it with a mob respawning idol (#706). Resolved with commit a3e6a93.