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

support for crafting #670

Open
maxomatic458 opened this issue Oct 24, 2024 · 4 comments
Open

support for crafting #670

maxomatic458 opened this issue Oct 24, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@maxomatic458
Copy link
Contributor

maxomatic458 commented Oct 24, 2024

As crafting is a core part of the game, i believe valenece should in some way include support for handling crafting.
Ideally this would be implemented in a way that makes it possible to craft items in any menu (not just the vanilla menus).

Maybe a CraftingRecipe struct could look like this:

struct CraftingRecipe {
    /// Items to be used for crafting (slots in the OpenInventory, item stack)
    cost: HashMap<u16, ItemStack>,
    /// The item(s) that will be crafted (slots in the OpenInventory, item stack)
    result: HashMap<u16, ItemStack>,
    /// If the item(s) should be crafted as soon as all the required items are in the slots (if false, you will have to take one of the result items for the cost items to be used)
    instant_craft: bool,
    // some more stuff
    ...
}

and for furnaces some extra logic (maybe a seperate struct) would be required.

those recipes would be attached to OpenInventories as a component (maybe like a Recipes Component)

Any thoughts on that?

@maxomatic458 maxomatic458 added the enhancement New feature or request label Oct 24, 2024
@dyc3
Copy link
Collaborator

dyc3 commented Oct 24, 2024

I agree, it would be silly not to support crafting. I don't think attaching the recipes to the inventory entities themselves is a good idea. There should be a crafting registry that can be used to easily lookup the inputs to see if they match a recipe.

Take a moment to list out all the requirements before we discuss implementation. We'll end up with a much better first draft. To get us started:

  • Recipes take items to produce a result item
  • Would be nice to be able to support forge item tags in recipes
  • Some mods have recipes that take more than one item in a particular slot
  • Crafting tables
    • produce the result instantly
    • has both shaped and shapeless recipes
    • shape is position independent -- eg. a torch can be crafted in any 2 slots, as long as its a coal above a stick
    • some shapeless recipes are more dynamic -- mods have recipes that let you repair tools by putting 2 damaged ones in the table, and you get a new tool with the durability combined.
  • Furnace
    • consumes fuel
    • produces result after a time

@lukashermansson
Copy link
Contributor

I also agree that it would be nice!

One thing that should be considered too is that it might be useful to have client dependant crafting recipes, (I can think of cases where teams etc get different results for the same items for example), Maybe it makes sense that its a component on the Client with the available recipes for that client? I'm not sure about the best design is here, but it would be awesome if the implementation allowed for such flexibility.

Also I think its wise to define the scope of this implementation and if it considers implementing any recipe book related stuff too or not. (I'm guessing its out of scope with the recipe book sync)

@maxomatic458
Copy link
Contributor Author

One thing that should be considered too is that it might be useful to have client dependant crafting recipes, (I can think of cases where teams etc get different results for the same items for example), Maybe it makes sense that its a component on the Client with the available recipes for that client? I'm not sure about the best design is here, but it would be awesome if the implementation allowed for such flexibility.

i fully agree with that.

I think crafting should be implemented so that its flexible enough to allow for something like this:
Workbench A can only craft item X, and Workbench B can only craft item Y

not sure if there is any use for something like that, but i do think you should be able to do something like that.

And i also think crafting should be possible in non-crafting inventories, like chests for example.

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

No branches or pull requests

5 participants
@dyc3 @andrewgazelka @lukashermansson @maxomatic458 and others