Posted August 7, 20205 yr runClient worked, but runServer crashed. How do I fix? Code: https://github.com/kyazuki/DietMod/tree/37d228d98922fb2d498414dcd2db04f744a2b8f1 Error: Quote [0882020 03:56:44.493] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmluserdevserver, --fml.mcpVersion, 20200625.160719, --fml.mcVersion, 1.16.1, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 32.0.75] [0882020 03:56:44.497] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 5.1.2+70+master.2845bb9 starting: java version 1.8.0_231 by Oracle Corporation [0882020 03:56:44.847] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [0882020 03:56:44.883] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8 Source=file:/C:/Users/kazuki/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8/dbe9e5db694a7c3cd644d5bb98f8a21295c75048/mixin-0.8.jar Service=ModLauncher Env=SERVER [0882020 03:56:46.193] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmluserdevserver' with arguments [--gameDir, .] [0882020 03:57:02.308] [modloading-worker-1/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Forge mod loading, version 32.0.75, for MC 1.16.1 with MCP 20200625.160719 [0882020 03:57:02.308] [modloading-worker-1/INFO] [net.minecraftforge.common.MinecraftForge/FORGE]: MinecraftForge v32.0.75 Initialized [0882020 03:57:02.590] [modloading-worker-2/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER [0882020 03:57:02.591] [modloading-worker-2/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Failed to create mod instance. ModID: dietmod, class com.github.kyazuki.dietmod.DietMod 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) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-launcher.jar:32.0] at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:103) ~[modlauncher-5.1.2.jar:5.1.2+70+master.2845bb9] at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) ~[modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115) ~[modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:247) ~[modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:134) ~[modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:96) ~[modlauncher-5.1.2.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_231] at java.lang.invoke.MethodHandleNatives.resolve(Native Method) ~[?:1.8.0_231] at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975) ~[?:1.8.0_231] at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000) ~[?:1.8.0_231] at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394) ~[?:1.8.0_231] at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750) ~[?:1.8.0_231] at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477) ~[?:1.8.0_231] at com.github.kyazuki.dietmod.network.PacketHandler.register(PacketHandler.java:21) ~[?:?] at com.github.kyazuki.dietmod.DietMod.<init>(DietMod.java:25) ~[?:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_231] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_231] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_231] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_231] at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_231] at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:131) ~[?:32.0] at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_231] at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_231] at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) ~[?:?] at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:135) ~[?:?] at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) [?:1.8.0_231] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) [?:1.8.0_231] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_231] at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) [?:1.8.0_231] at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) [?:1.8.0_231] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_231] at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_231] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_231] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_231] [0882020 03:57:02.669] [main/FATAL] [net.minecraftforge.fml.ModLoader/LOADING]: Failed to complete lifecycle event CONSTRUCT, 1 errors found [0882020 03:57:02.669] [main/FATAL] [net.minecraft.server.Main/]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [ Diet Mod (dietmod) has failed to load correctly §7Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER ] at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:218) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:200) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] at net.minecraftforge.fml.server.ServerModLoader.load(ServerModLoader.java:49) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] at net.minecraft.server.Main.main(Main.java:95) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_231] at net.minecraftforge.userdev.FMLUserdevServerLaunchProvider.lambda$launchService$0(FMLUserdevServerLaunchProvider.java:54) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.2.jar:?] at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.1-32.0.75_mapped_snapshot_20200723-1.16.1-recomp.jar:?] Edited August 9, 20205 yr by kyazuki
August 7, 20205 yr 6 minutes ago, kyazuki said: java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/player/ClientPlayerEntity for invalid dist DEDICATED_SERVER Show your code, but this is probably a case of Reaching Across Sides. Yep, here: https://github.com/kyazuki/DietMod/blob/1.16.1-forge/src/main/java/com/github/kyazuki/dietmod/network/CapabilityPacket.java#L29 Your packet exists on both sides. The context contains a reference to the relevant player. Edited August 7, 20205 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 7, 20205 yr Author I don't understand the packet system fully... This packet is always sent to client from server. Can I solve this problem with changing PacketHandler? Or should I change CapabilityPacket#handle?
August 7, 20205 yr The packet class must exist on both sides. On the sender, its used to construct the binary data, on the receiver its used to read the binary data. This is why a Context object is passed to the packet handler. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 9, 20205 yr Author What should I do here? I know there’s the “OnlyIn” annotation, but I hear it’s not ideal.
August 9, 20205 yr Do not use only-in. Get the player from the context. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 9, 20205 yr Author 10 minutes ago, Draco18s said: Get the player from the context. Context#getSender()? I want to change ClientPlayer capability. getSender() returns ServerPlayerEntity...
August 9, 20205 yr Use the player provided in Minecraft instance. Edited August 9, 20205 yr by poopoodice
August 9, 20205 yr Author 7 minutes ago, poopoodice said: Use the player provided in Minecraft instance. Yes, but it causes server crash... https://github.com/kyazuki/DietMod/blob/37d228d98922fb2d498414dcd2db04f744a2b8f1/src/main/java/com/github/kyazuki/dietmod/network/CapabilityPacket.java#L29 Edited August 9, 20205 yr by kyazuki
August 9, 20205 yr Author It works! Thanks for the help! public static void handle(CapabilityPacket pkt, Supplier<NetworkEvent.Context> contextSupplier) { NetworkEvent.Context context = contextSupplier.get(); context.enqueueWork(() -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> Handle.handleClient(pkt.playerEntityID, pkt.scale))); context.setPacketHandled(true); } public static class Handle { public static DistExecutor.SafeRunnable handleClient(int playerEntityID, float scale) { return new DistExecutor.SafeRunnable() { @Override public void run() { PlayerEntity player = (PlayerEntity) Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null) return; player.getCapability(ScaleProvider.SCALE_CAP).orElseThrow(IllegalArgumentException::new).setScale(scale); } }; } }
August 9, 20205 yr Author Is this correct? Entity player = Minecraft.getInstance().world.getEntityByID(playerEntityID); if (player == null || !(player instanceof PlayerEntity)) return; Edited August 10, 20205 yr by kyazuki
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.