-
Notifications
You must be signed in to change notification settings - Fork 183
Networking Guide #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Networking Guide #249
Conversation
✅ Deploy Preview for nimble-elf-d9d491 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
.../java/com/example/docs/networking/basic/FabricDocsReferenceNetworkingBasicDataGenerator.java
Outdated
Show resolved
Hide resolved
14472b6
to
0e99dc2
Compare
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
reference/latest/src/main/java/com/example/docs/networking/basic/LightningTaterItem.java
Outdated
Show resolved
Hide resolved
Hi! The documentation has been updated to version 1.21.4. Please rebase your PR and update your code to align with the latest version. Alternatively, you can create a new branch based on the latest commit from the Once you've completed the updates and are confident everything is ready, feel free to unmark this as a draft. Thanks again for your contribution! |
2a3708b
to
4b11494
Compare
Hello @dicedpixels, are you still working on this? |
- remove dedicated data generator - add lightning tater item model generator to the shared pack - fix offset line numbers - fix broken link in damage types doc
- add more info about `PlayerLookup` and adjust the code - limt the `UseItemCallback` to the logical client
- attempted to improve the c2s section to align with review comments
2140ab1
to
d2edbef
Compare
I guess so 😅. Haven't had time to sit and look back at it. I believe I've addressed all the comments, PR should be up-to-date. I will undraft it so more people can review. |
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
...test/src/main/java/com/example/docs/networking/basic/FabricDocsReferenceNetworkingBasic.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good quality page! Well done. Just a very minor nitpick and then LGTM I think!
...src/client/java/com/example/docs/network/basic/FabricDocsReferenceNetworkingBasicClient.java
Outdated
Show resolved
Hide resolved
still not convinced with the diagram being an image, but there's not much to do about it |
not applicable (the example is intentionally wrong and as such can't be in the mod)
Upon testing, you will see a lightning bolt being summoned and nothing crashes. Now you want to show the mod to your | ||
friend, you boot up a dedicated server and invite your friend on with the mod installed. | ||
|
||
You use the item and the server crashes. You will probably notice in the crash log an error similar to this: | ||
|
||
```log | ||
[Server thread/FATAL]: Error executing task on Server | ||
java.lang.RuntimeException: Cannot load class net.minecraft.client.MinecraftClient in environment type SERVER | ||
``` | ||
|
||
### Why Does the Server Crash? {#why-does-the-server-crash} | ||
|
||
The code calls logic only present on the client distribution of the Minecraft. The reason for Mojang distributing the | ||
game in this way is to cut down on the size of the Minecraft Server JAR file. There isn't really a reason to include an | ||
entire rendering engine when your own machine will render the world. | ||
|
||
In a development environment, client-only classes are indicated by the `@Environment(EnvType.CLIENT)` annotation. | ||
|
||
### How Do We Fix the Crash? {#how-do-we-fix-the-crash} | ||
|
||
To fix this issue, you need to understand how the game client and dedicated server communicate: | ||
|
||
 | ||
|
||
The diagram above shows that the game client and dedicated server are separate systems, bridged together using | ||
_packets_. Packets can contain data which we refer to as the _payload_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine I guess, it just doenst have anything to do with networking. Packets are still sent between the logicial client and server even in single player, or when on a LAN world. A better example would be to cause desync by setting something only the logicial client. Maybe try adding a block to the hotbar from a keybind or something.
Ports Networking.
Differences: