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

Feture: CraftRecipeRequest #421

Open
Miro-Andrin opened this issue May 11, 2021 · 1 comment
Open

Feture: CraftRecipeRequest #421

Miro-Andrin opened this issue May 11, 2021 · 1 comment

Comments

@Miro-Andrin
Copy link
Contributor

Feature Request

Handle the CraftRecipeRequest in feather/server/src/packet_handlers.rs

Description

This packet is sent when a player clicks a recipe in the crafting book that is craftable (white border). 

Wiki

To implement handle this packet we need to have a list of every Minecraft recipe. We also want this list to be viewable and editable by plugins. As far as i know feather currently does not have any knowledge of recipes. And implementing this feature would require multiple steps.

a) Add recipes to libcraft

In /libcraft we have definitions on minecraft related data. This is probably were we want to add a definition containing all vanilla recipes. (Ask someone on discord to make sure).

minecraft-data is a awesome project that collects minecraft related data. They keep up to date sources for stuff like recipes. You would have to implement a rust macro that converts the json into rust structs.
This is somewhat difficult for beginners, as macros are tricky.

b) Add recipe handling to quill.

For this step i am not a 100% certain on how it should be implemented. But my idea is that we put recipes into the ECS. Every recipe is just a entity with a recipe component. The file quill/common/src/components.rs has defined a couple of components that might be a starting point for anyone interested in implementing this feature. Another solution is that we manage recopies through host-calls.
Host calls are defined in quill/sys. They're FFI functions that plugins can call to do things on the server. Host calls have to be implemented in feather/plugin-host/src/host_calls.rs. To invoke a function on the plugin, you have to export it with #[no_mangle]. See the macro in quill/api/src/lib.rs for an example for how this works.

@Miro-Andrin Miro-Andrin changed the title CraftRecipeRequest Feture: CraftRecipeRequest May 11, 2021
@caelunshun
Copy link
Member

caelunshun commented May 11, 2021

minecraft-data is a awesome project that collects minecraft related data. They keep up to date sources for stuff like recipes. You would have to implement a rust macro that converts the json into rust structs.

Recipes are stored in datapacks, so ideally we'd load them from the vanilla datapack at runtime. feather-datapacks is already a WIP crate in the source tree, so adding recipe support to it should be possible.

But my idea is that we put recipes into the ECS. Every recipe is just a entity with a recipe component.

Not sure I agree with this—the ECS isn't a silver bullet. We'll need to do lookups on the recipe set to efficiently compute crafting results, for example, and this is harder with the ECS than it needs to be. IMO a RecipeRegistry stored in the Game would be better; we can provide access to it through host calls.

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

2 participants