Jump to content

[SOLVED][1.14.4] Error when starting server


deerangle

Recommended Posts

I have a packet that goes to the client in my code, that the server is for some reason trying to load... This causes a crash with this error:

[19:41:39] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [
	Laser Mod (lasermod) encountered an error during the common_setup event phase
§7Attempted to load class net/minecraft/client/world/ClientWorld for invalid dist DEDICATED_SERVER
]
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:201) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:154) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.server.ServerModLoader.begin(ServerModLoader.java:46) ~[?:?] {re:classloading}
	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:124) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222] {}

Here is where I reference a ClientWorld in my code:

public static void handle(PacketLaserLensUpdate message, Supplier<NetworkEvent.Context> ctx) {
    ctx.get().enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
        World world = Minecraft.getInstance().world;
        TileEntity te = world.getTileEntity(message.pos);
        if (te instanceof LaserTileEntity) {
            LaserTileEntity laser = (LaserTileEntity) te;
            laser.color = message.color;
            laser.direction = message.direction;
            laser.maxDistance = message.distance;
            laser.thickness = message.thickness;
            laser.active = message.active;
        }
    }));
    ctx.get().setPacketHandled(true);
}

As you can see I tried using DistExecutor, but that isn't working for some reason. Im registering the packets in the FMLCommonSetupEvent.

 

Edited by deerangle
solved
Link to comment
Share on other sites

Weirdly, when I inline the World in this part of the code

World world = Minecraft.getInstance().world;
TileEntity te = world.getTileEntity(message.pos);

the error disappears... But that isn't really a fix to the problem, as in some situations, inlining might not be possible.
What can I do to fix this error without inlining?

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.

Announcements



×
×
  • Create New...

Important Information

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