This is due to error "Attempted to load class net/minecraft/client/color/block/BlockColors for invalid dist DEDICATED_SERVER".
Full log:
[03:20:59] [main/INFO]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 39.0.9, --fml.mcVersion, 1.18.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20211210.034407]
[03:20:59] [main/INFO]: ModLauncher 9.0.7+91+master.8569cdf starting: java version 17.0.1 by Oracle Corporation
[03:20:59] [main/INFO]: OptiFineTransformationService.onLoad
[03:20:59] [main/INFO]: OptiFine ZIP file URL: union:/C:/Users/xordr/AppData/Roaming/.minecraft/server/mods/OptiFine_1.18.1_HD_U_H4_MOD.jar%2337!
[03:20:59] [main/INFO]: OptiFine ZIP file: C:\Users\xordr\AppData\Roaming\.minecraft\server\mods\OptiFine_1.18.1_HD_U_H4_MOD.jar
[03:20:59] [main/INFO]: Target.PRE_CLASS is available
[03:20:59] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/xordr/AppData/Roaming/.minecraft/server/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2319! Service=ModLauncher Env=SERVER
[03:20:59] [main/INFO]: OptiFineTransformationService.initialize
[03:20:59] [main/INFO]: Found mod file betterfoliage-3.0.0.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file BetterThirdPerson-Forge-1.18-1.6.0.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file ChiselsBits-forge-1.18.1-1.2.56.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file configured-1.5.1-1.18.1.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file CosmeticArmorReworked-1.18.1-v1.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file create-mc1.18.1_v0.4c.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file effective_for_forge-1.001.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file flywheel-forge-1.18-0.5.1.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file furniture-7.0.0-pre27-1.18.1.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file jei-1.18-9.0.0.40.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file journeymap-1.18.1-5.8.0beta4.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file mutil-1.18.1-4.1.0.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file ShoulderSurfing-1.18-2.2.2.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file Terralith_v2.0.10_Fabric+Forge.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file tetra-1.18.1-4.3.0.jar of type MOD with locator {mods folder locator at C:\Users\xordr\AppData\Roaming\.minecraft\server\mods}
[03:20:59] [main/INFO]: Found mod file fmlcore-1.18.1-39.0.9.jar of type LIBRARY with locator net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@c260bdc
[03:20:59] [main/INFO]: Found mod file javafmllanguage-1.18.1-39.0.9.jar of type LANGPROVIDER with locator net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@c260bdc
[03:20:59] [main/INFO]: Found mod file mclanguage-1.18.1-39.0.9.jar of type LANGPROVIDER with locator net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@c260bdc
[03:20:59] [main/INFO]: Found mod file server-1.18.1-20211210.034407-srg.jar of type MOD with locator net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@c260bdc
[03:20:59] [main/INFO]: Found mod file forge-1.18.1-39.0.9-universal.jar of type MOD with locator net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@c260bdc
[03:21:00] [main/INFO]: OptiFineTransformationService.transformers
[03:21:00] [main/INFO]: Targets: 342
[03:21:00] [main/INFO]: additionalClassesLocator: [optifine., net.optifine.]
[03:21:01] [main/INFO]: Compatibility level set to JAVA_17
[03:21:01] [main/INFO]: Launching target 'forgeserver' with arguments []
[03:21:02] [main/FATAL]: Attempted to load class net/minecraft/client/color/block/BlockColors for invalid dist DEDICATED_SERVER
How do I correct this?