Jump to content

[Solved][1.16.5] Attempted to load Screen for invalid dist DEDICATED_SERVER


Recommended Posts

Posted (edited)

I'm getting 

[00:59:39] [Server thread/FATAL] [ne.mi.fm.lo.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/gui/screen/Screen for invalid dist DEDICATED_SERVER
[00:59:39] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server
java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/screen/Screen for invalid dist DEDICATED_SERVER
	at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[forge-1.16.5-36.2.20_mapped_snapshot_20210309-1.16.5-launcher.jar:36.2] {}
	at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) ~[modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) ~[modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) ~[modlauncher-8.0.9.jar:?] {re:classloading}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-8.0.9.jar:?] {re:classloading}
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_302] {}
	at io.github.davidqf555.minecraft.towerofgod.common.blocks.FloorTeleportationTerminalBlock.onBlockActivated(FloorTeleportationTerminalBlock.java:56) ~[?:?] {re:classloading}
	at net.minecraft.block.AbstractBlock$AbstractBlockState.onBlockActivated(AbstractBlock.java:732) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:347) ~[forge:?] {re:classloading}
	at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:986) ~[forge:?] {re:classloading}
	at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:45) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading}
	at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[forge:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:759) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:742) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:736) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:722) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:668) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_302] {}

for this mod when playing it on dedicated servers. I understand that Screens should not be used on dedicated servers, but I was using packets to make sure that the screen only opened on client. I'm wondering if I need to add checks or something elsewhere to make sure that the packet is only handled on clients. 

Edited by DavidQF555
Solved
Posted
2 minutes ago, diesieben07 said:

The packet class is still loaded on both sides. You have to use DistExecutor when accessing dist-only classes from common code.

I updated my handle method to: 

private void handle(NetworkEvent.Context context) {
        NetworkDirection dir = context.getDirection();
        if (dir == NetworkDirection.PLAY_TO_CLIENT) {
            context.enqueueWork(() -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().displayGuiScreen(new FloorTeleportationTerminalScreen(level, teleporter, direction))));
            context.setPacketHandled(true);
        }
    }

Just to check, is the way I'm using DistExecutor correct in terms of convention?

  • DavidQF555 changed the title to [Solved][1.16.5] Attempted to load Screen for invalid dist DEDICATED_SERVER
Posted
12 minutes ago, diesieben07 said:

No (and safeRunWhenOn should yell at you). The actual code must be in a separate class.

Ok I think I got it. Basically, I can't import any client only code (marked with OnlyIn) in any of my common code?

Posted
3 minutes ago, diesieben07 said:

Imports are entirely irrelevant.

What I mean is using OnlyIn client methods/classes. For classes though, I can usually tell whether I'm using client only classes by just looking at imports. 

Posted

Is it necessary to use DistExecutor? It seems like the main issue is that I was using client only classes in my packets but moving them to another class solved that. Is using DistExecutor in my packet handling methods that already check directions just for safety?

Posted
8 minutes ago, diesieben07 said:

You should not check the network direction, instead specify it when registering your packet, then FML will disconnect when the packet is sent in an invalid manner.

Ok, I'll do that. Is there any point in using DistExecutor for handling then?

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.

Announcements



×
×
  • Create New...

Important Information

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