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

High level abstractions above nmp #231

Open
rom1504 opened this issue Sep 10, 2015 · 5 comments
Open

High level abstractions above nmp #231

rom1504 opened this issue Sep 10, 2015 · 5 comments
Labels

Comments

@rom1504
Copy link
Member

rom1504 commented Sep 10, 2015

So this is not really a nmp issue : there is nothing to fix in nmp in this issue, but it's an issue that can concern several nmp users.

The starting point of this issue is to see that mineflayer provide an high-level api for clients, flying-squid is starting to provide an high-level api for servers, and some things are common in these two implementations.

So what is common ?

There are 4 main things that are done with nmp :

  1. reading client bound packets
  2. writing server bound packets
  3. reading server bound packets
  4. writing client bound packets

Mineflayer is doing 1 and 2 and flying-squid is doing 3 and 4.

Now there's a third kind of nmp users : proxies, like the one @Egoscio is building. And proxies actually do these 4 things : they need to understand the 2 direction and send packets to the 2.

Mineflayer and flying-squid can both use certain type of representation to store information, for example prisimarine-block, prisimarine-entity, prisimarine-world, node-vec3.

Now the handling of reading and writing packets is different with just the storing information part.

I think what would be interesting for all these users would be to provide methods that would make it easier to read and write the packets at a higher level. For example the block_place packet contain a direction number and a reference block position, it would be interesting to transform that into an event containing the position of the future block, and a direction vector instead of the direction number. This is just one example ( and I will add more) but this is the kind of things that would make writing mineflayer and flying-squid easier.

So basically the idea is to provide methods to facilitate writing packets and reading packets from a higher level perspective.

In a second stage it might be interesting to have 2 back ends for that representation : mcpc and mcpe. That way it would be easier to write bots, servers and proxies that would work for both mcpc and mcpe.

This is the basic idea and I'll add more examples later to make sure and prove that having a higher level representation of these network operations make sense.

@rom1504
Copy link
Member Author

rom1504 commented Sep 10, 2015

Some ideas :

  • transform field type like block id, entity id, position to their corresponding classes (prismarine-block, prisimarine-entity, vec3)
  • group some packets like the spawn entity packet
  • compare mcpc and mcpe protocols to have ideas about how to build a common representation

I think that representation should be made available to users but the low level representation should still be available even if we would encourage users to use only the high level representation if possible.

@deathcap
Copy link
Member

Another possible use case:

@rom1504
Copy link
Member Author

rom1504 commented May 20, 2018

indeed the chunk layer is now completely abstracted in prismarine-chunk

@rom1504
Copy link
Member Author

rom1504 commented Jul 19, 2022

PrismarineJS/bedrock-protocol#116 kind of related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants