-
Notifications
You must be signed in to change notification settings - Fork 119
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
base: main
Are you sure you want to change the base?
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
|
||
@[code lang=java transcludeWith=::use_poisonous_potato_payload](@/reference/latest/src/main/java/com/example/docs/networking/basic/UsePoisonousPotatoPayload.java) | ||
|
||
Note the usage of `PacketCodec.tuple` to combine two values, a `String` and a `BlockPos`. |
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.
I know this is done for the sake of example, but this example is inefficient and dangerous:
- Sending any data about the player is pointless because the server already knows which player sent it and can access any information it needs there.
- If the client or server want to refer to another entity in a packet, they should use it's numerical ID (not UUID)
- A malicious client can exploit this because the server doesn't check that any data is factually correct (data validation in C2S packets is also an important topic).
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.
- Yes, this I figured. I wanted a simple example.
- I believe we can overlook this for the sake of simplicity.
- This however is concerning. I was not aware and didn't think that far as we're dealing with the basics. I'm open for a better example that could address above 2 points as well.
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.
If I were to write this, I would add a situation where a player is casting some sort of spell to another entity. In this situation, efficient networking can be showcased (see 2) and proper data validation can be showcased with checks like "does the entity actually exist and is not invulnerable?" "is the player close enough to the entity?"
- 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
14472b6
to
0e99dc2
Compare
- add more info about `PlayerLookup` and adjust the code - limt the `UseItemCallback` to the logical client
Ports Networking.
Differences:
Note: PR is marked as draft till docs are updated to 1.21.4. Feel free to review till then.