PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
5.15k stars 926 forks source link

Move the whole world state to prismarine-world for better packaging #334

Open rom1504 opened 9 years ago

rom1504 commented 9 years ago

This will make blockAt async and break everything depending on it. But it's for the good cause of being able to implement a world representation with any kind of backend (especially async backend like databases)

https://github.com/PrismarineJS/prismarine-world

https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/blocks.js

rom1504 commented 9 years ago

One way to make the transition smoother is to just deprecate blockAt, implement it using prismarine-world-sync and use bot.world for everything else.

rom1504 commented 9 years ago

Something interesting about this is a prismarine-world-blockfinder could be made and used in mineflayer-blockfinder that would then be just a few lines.

rom1504 commented 8 years ago

requires https://github.com/PrismarineJS/prismarine-chunk/issues/16#issuecomment-169614381

rom1504 commented 8 years ago

(using prismarine-world-sync would break mineflayer in the browser though, maybe it should be an optional dependency and we'd have no blockAt function for the no-prismarine-world-sync case, or maybe we could just remove blockAt altogether, but that would mean doing PRs on all projects using mineflayer)

rom1504 commented 8 years ago

Related idea : have a prismarine-world-snapshot that would take a snapshot of a given region and allow a sync api on that region. That might be useful to speed up blockfinder. (or maybe doing it asyncly would be fast enough, better benchmark before doing that)

rom1504 commented 8 years ago

Alright, let's start with using prismarine-chunk in mineflayer. That will give us cross platform chunk (https://github.com/PrismarineJS/prismarine-chunk/issues/19) + we don't have to deal with the async problem for now.

rom1504 commented 7 years ago

p-chunk is now used. using prismarine-world could be considered but would involve a lot of async everywhere. Not not obvious to do

rom1504 commented 4 years ago

https://github.com/PrismarineJS/mineflayer/pull/1145 made this happen

Follow up :

rom1504 commented 3 years ago

deprecating blockAt would be really useful

issuehunt-oss[bot] commented 3 years ago

@rom1504 has funded $10.00 to this issue.


introquest commented 3 years ago

Faced with the fact that mineflayer duplicates some things from prusmarine such as Block, Item, Recipe, etc. Is it about reusing all of this from prismarine? And what remains to be done on this task?

TheDudeFromCI commented 3 years ago

@introquest Mineflayer does not duplicate anything from those libraries, but imports then. The goal of Mineflayer is to move as much code out of Mineflayer as possible into micro-modules. (prismarine-block, primsarine-item, etc) Ideally, by making many very small libraries, they become very easy to maintain and reuse since they are so small.

As for this issue, prismarine-world should contain all of the world states, with Mineflayer acting solely as a stateless transformer for the world. The world contains submodules that further divide the state. Prismarine-chunk, Prismarine-Entity, etc.

issuehunt-oss[bot] commented 3 years ago

@sauberesache has funded $20.00 to this issue.


issuehunt-oss[bot] commented 2 years ago

@sauberesache has cancelled funding for this issue.(Cancelled amount: $20.00) See it on IssueHunt

issuehunt-oss[bot] commented 2 years ago

@rom1504 has cancelled funding for this issue.(Cancelled amount: $10.00) See it on IssueHunt

rom1504 commented 2 years ago

signs and block entities are done

next step deciding what to do with paintings

rom1504 commented 2 years ago

once paintings is gone we can merge https://github.com/PrismarineJS/mineflayer/pull/2453

rom1504 commented 2 years ago

new plan after discussion in discord:

move everything to pchunk

since entities can move between chunks,

once this is done, mineflayer should contain no state and be only a packet <-> world and action <-> packet/world synchronization layer it will allow

rom1504 commented 2 years ago

since we have some funding now, any significant PR towards that goal is eligible to $20 of reward (using open collective money)

of course working on it because it's cool stays a great reason :)

Gjum commented 2 years ago

why would entities be part of a chunk, and not just part of the world? their id is unique in the entire world, most entities move freely between chunks all the time, and accessing entities through their current chunk is rather useless as you typically want to find entities nearby regardless of what chunk they are in.

rom1504 commented 2 years ago

the world abstraction (pworld) would expose the ability to search for an entity by its id or to look for an entity in a location based on properties (by looking and/or indexing the information stored in chunks) having the entities in the chunk make it natural to save/load them to disk (anvil) and to load/unload them when chunks get loaded/unloaded. It also does a clean separation of concern between chunk storing the data, and world just exposing and doing the orchestration

having the entities be part of the chunk should make it easier to scale the world to large sizes