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

Integration in mineflayer #116

Open
3 of 6 tasks
rom1504 opened this issue Jul 29, 2021 · 15 comments
Open
3 of 6 tasks

Integration in mineflayer #116

rom1504 opened this issue Jul 29, 2021 · 15 comments

Comments

@rom1504
Copy link
Member

rom1504 commented Jul 29, 2021

Related #65
Things to do :

  • Use Minecraft data #115 use Minecraft data
  • pchunk bedrock support
  • pblock and pitem support
  • Actual implementation in mineflayer, 2 choices. I prefer the first choice, but it depends on how difficult it would be in practice
      1. Build an abstraction layer for java and bedrock packets, build new mineflayer plugins relying on these stable clean and nice packets instead of raw packets
      1. Build mineflayer plugins for bedrock raw packets
@rom1504 rom1504 pinned this issue Jul 29, 2021
@rom1504 rom1504 mentioned this issue Jul 29, 2021
@extremeheat
Copy link
Member

extremeheat commented Aug 19, 2021

Progress Report, (trying to finally get this bedrock stuff out of the way)

For consideration:

  • New lib to do inventories and/or expand scope of p-windows ?
    • Inventory logic needs to be shared between the client and the server, and nickelpro is also working on revamping java edition inventories for pc 1.17.
    • https://extremeheat.github.io/bedrock-protocol/protocol/1.16.220.html#ItemStackRequest - on bedrock, the inventory actions are high level instead of being click based, so actions like take, place, swap, etc. are sent instead of individual clicks.
    • Clients can also batch inventory requests (e.g. click spreading in one packet), so it needs to be able to simulate these requests from the server. If the server rejects, client needs to discard and undo the batch.

@u9g
Copy link
Member

u9g commented Aug 20, 2021

In terms of inventory, nickelpro was talking about a similar way to do high level actions with p-window where you would be able to say window.swap(itemOne, itemTwo) and everything with slots would be handled by p-window

@extremeheat
Copy link
Member

extremeheat commented Aug 20, 2021

Yeah, that could be joined along with a transaction group API to batch many actions at once. Something like this is also needed for GUI inventories in Minecraft, and I've implemented it into minecraft-inventory-gui for creative mode (just not connected to network APIs) : https://github.com/extremeheat/minecraft-inventory-gui/blob/bedrock/web/CW2.js

For example, doing spread operations in the inventory, then cancelling it requires the client to simulate the spread, then if not cancelled, send the group to the server for confirmation (or rejection).

For the mineflayer side an API like this :

interface Inventory {
  // take from slot and put count into hand
  take({ from?: string, fromSlot?: number, count?: number })
  // take item from slot and put count into hand
  take({ from?: string, item?: ItemName, count?: number })
  // place from hand to slot specific if slot is specified, else distribute
  place({ toSlot?: number, count?: number })
  // move from slot to another slot
  move({ from?: string, fromSlot?: number, to?: string, toSlot?: number })
  // from item from one place to another place (specific slot if specified)
  move({ from?: string, item?: number, to?: string, toSlot?: number })
}
const tx = bot.inventory.startTransaction()
tx.take({ fromSlot: 0, count }) // put into hand
tx.place({ toSlot: 0, count }) // put from hand into slot
tx.swap({ fromSlot: 0, toSlot: 1 })
tx.move({ from: 'chest', fromSlot: 2, to: 'hand' })
tx.send()

There some duplicates APIs which do the same thing, I just added them from the bedrock protocol. For automation in agents, the action space can be simplified to just moving x item to y.

@u9g
Copy link
Member

u9g commented Aug 22, 2021

prismarine-item pr has been merged

@RUGMJ
Copy link

RUGMJ commented Oct 19, 2021

Any updates?

@extremeheat
Copy link
Member

Remaining work backlog

What's done

  • 1.17.30/1.18 update bedrock-provider#9 - support for 1.18 level format
  • mc-data updated with most essential data, biomes, blocks, items, collisions, etc.
  • prismarine-viewer kind of works, but needs some updates to block model mapping

Non-essential backlog

@neohunter
Copy link

PrismarineJS/mineflayer#2411

How to make mineflayer use bedrock-protocol instead of minecraft-protocol?

@rom1504
Copy link
Member Author

rom1504 commented Jan 20, 2022

by finishing this task, if you want to help @neohunter feel free to join #bedrock-protocol in discord and ask what you can do at this time to make things easier

@extremeheat
Copy link
Member

June 2022

Remaining work backlog

What's done

Non-essential backlog

Want to help?

  • Get a good understanding of how the prismarine projects work currently, specifically mineflayer.
  • Then take a look at the bedrock protocol documentation (on https://minecraft-data.prismarine.js.org)
  • use a bedrock-protocol proxy (called Relay) over a vanilla server and client to understand how the packets are used in correlation to ingame activity
  • Update packages in Remaining work backlog to implement in game features (the packages provide abstraction on topp of the game protocol)

@ATXLtheAxolotl
Copy link
Contributor

What problems are there currently with prismarine-physics that prevents it from supporting bedrock?

@extremeheat
Copy link
Member

What problems are there currently with prismarine-physics that prevents it from supporting bedrock?

Problems if any for physics will come up when making tests for it on bedrock to see what works / what needs changes

@extremeheat
Copy link
Member

Some notes from discord discussion:

  • prismarine-entity will likely need some changes to make it consistent across all versions (like effects, attributes, properties)
    • After looking at prismarine-physics/entity, one of the things we can do I think is make the effect/attribute/entity names consistent across all versions, that would simplify the code alot and remove alot of code like this: https://github.com/PrismarineJS/prismarine-physics/blob/708ff2341bbe8e542f9d29a82c9c102c33a02c02/index.js#L649
    • since effectNamesAreRegistryNames is only valid on pc1.17, mc-data can probably be updated to rename the effects to 1.19/1.16 naming. A protocolName field could be added to keep the actual protocol naming instead so name can be consistent across all pc versions / bedrock versions

Prismarine item will require loading item palette data from StartGame packet similar to pc dimension codec. Some work in PrismarineJS/prismarine-registry#26 (comment). Enchant data was added in PrismarineJS/minecraft-data#689, so all the data for pitem should now be in place.

Additionally, prismarine window handling will also likely require some changes to pitem

@rom1504
Copy link
Member Author

rom1504 commented Jul 22, 2023

pitem bedrock is done

@minidogg
Copy link

is this done yet?

@rom1504
Copy link
Member Author

rom1504 commented Jan 7, 2024

I think it would be great to get this one moving.

I wonder if we could do a minimal implementation in mineflayer with some basic stuff working (chat) and have the rest not work, and go from there

I think that may be a better approach than blocking on "be on par with pc"

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

No branches or pull requests

7 participants