Skip to content
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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Networking Guide #249

wants to merge 4 commits into from

Conversation

dicedpixels
Copy link
Contributor

Ports Networking.

Differences:

  • Actual working item, Lightning Tater.
  • Along with S2C, a C2S example is also included.

Note: PR is marked as draft till docs are updated to 1.21.4. Feel free to review till then.

Copy link

netlify bot commented Dec 31, 2024

Deploy Preview for nimble-elf-d9d491 ready!

Name Link
🔨 Latest commit 2a3708b
🔍 Latest deploy log https://app.netlify.com/sites/nimble-elf-d9d491/deploys/6776b76c48b58f00072ccddc
😎 Deploy Preview https://deploy-preview-249--nimble-elf-d9d491.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@IMB11 IMB11 added new-content A new page or set of pages stage:verification This should be verified labels Dec 31, 2024
develop/networking.md Outdated Show resolved Hide resolved
develop/networking.md Outdated Show resolved Hide resolved
develop/networking.md 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`.
Copy link
Contributor

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:

  1. 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.
  2. If the client or server want to refer to another entity in a packet, they should use it's numerical ID (not UUID)
  3. 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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yes, this I figured. I wanted a simple example.
  2. I believe we can overlook this for the sake of simplicity.
  3. 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.

Copy link
Contributor

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
- add more info about `PlayerLookup` and adjust the code
- limt the `UseItemCallback` to the logical client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-content A new page or set of pages stage:verification This should be verified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants