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

Recipe Rewrite (API Only) #4256

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

SchnTgaiSpock
Copy link
Contributor

Description

The long awaited recipe rewrite (supersedes #4093)

Proposed changes

In short, adds true shaped/shapeless crafting, tagged inputs, and json (de)serialization (custom recipes)

Full ADR here

Related Issues (if applicable)

N/A

Checklist

  • I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • I followed the existing code standards and didn't mess up the formatting.
  • I did my best to add documentation to any public classes or methods I added.
  • I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • I added sufficient Unit Tests to cover my code.

@github-actions github-actions bot added the 🔧 API This Pull Request introduces API changes. label Nov 4, 2024
Copy link
Contributor

github-actions bot commented Nov 4, 2024

Your Pull Request was automatically labelled as: "🔧 API"
Thank you for contributing to this project! ❤️

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Slimefun preview build

A Slimefun preview build is available for testing!
Commit: fa7e33a

https://preview-builds.walshy.dev/download/Slimefun/4256/fa7e33aa

Note: This is not a supported build and is only here for the purposes of testing.
Do not run this on a live server and do not report bugs anywhere but this PR!

@SchnTgaiSpock
Copy link
Contributor Author

I'm going to throw together a showcase addon sometime next week to facilitate testing since I don't want to migrate any Slimefun stuff in this PR.

Copy link
Member

@WalshyDev WalshyDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and comments my side but very excited for this, thank you!

@@ -0,0 +1,254 @@
# 2. Recipe rewrite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial review is just on the adr - thank you for this by the way, it makes large changes like this much better :)

docs/adr/0002-recipe-rewrite.md Outdated Show resolved Hide resolved
the recipe should be matched to items in a multiblock/machine when crafting. The base ones are:

- Shaped/Shapeless: Exactly the same as vanilla
- Subset: How the current smeltery, etc. craft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we expand and say what this actually is

`RecipeInput`s are a list of `RecipeInputItem`s plus a `MatchProcedure` -- how the inputs of
the recipe should be matched to items in a multiblock/machine when crafting. The base ones are:

- Shaped/Shapeless: Exactly the same as vanilla
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Shaped/Shapeless: Exactly the same as vanilla
- Shaped/Shapeless: Exactly the same as vanilla. Shaped recipes need to be crafted exactly as defined. Shapeless need to be in the same order but can move (e.g. 3 sticks down the y axis could be on any x axis)

(ngl shaped + shapeless are both wrong in mc...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we have differing definitions of shaped/shapeless; for me:

  • shaped means as long as the order and relative positions of the items are the same, they can be moved anywhere on the crafting grid and it will be crafted
  • shapeless means as long as the all the specified items (and nothing extra) are there it will be crafted regardless of order

these are what mc does and i want to keep the naming consistent. i also don't see why they are 'wrong' per se, although ordered and orderless might have been a better name tbh

what you defined as shaped i think i would call smth like 'fixed', and as a player i dislike those kinds of recipes -- copper wire for example needs 3 copper ingots in the middle row, which means i can't shift click them in (to the top row), whereas if it were 'shaped' i could.

i probably wasn't clear enough that i wanted to move away from those recipes since they are pretty annoying as a player to use

ill add it in (albeit w/ different name), but i don't see a reason to use it over mc shaped


- Shaped/Shapeless: Exactly the same as vanilla
- Subset: How the current smeltery, etc. craft
- Shaped-flippable: The recipe can be flipped on the Y-axis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give an example

moved to `plugins/Slimefun/recipes/` (unless a file with its name already exists).

Addons should do the same. (We recommend saving to
`plugins/Slimefun/recipes/<your-addon-name>/` but it's not required).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonder if we just make this required - otherwise i think we just have people overriding eachother.

Comment on lines +214 to +217
On the first server tick, all recipes in the `plugins/Slimefun/recipes` folder
are read and added to the `RecipeService`, removing all recipes with the
same filename. This is why recipes should ideally be *defined* in JSON,
to prevent unnecessary work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err interesting...

any reason to not just make plugins register their recipes? avoids the whole 1 tick thing.
Also ideally we just don't ever depend on a filename, that's not great.

RecipeService.registerRecipes(Path.of(getPluginFolder(), "recipes", "recipes.json"));
(this is reading from addon folder which i also think is fine)

same filename. This is why recipes should ideally be *defined* in JSON,
to prevent unnecessary work.

When loading JSON recipes, we also need to be able to tell the difference between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to do this? what's the use case?


While the server is running, recipes can be modified in code, saved to disk, or
re-loaded from disk. New recipes can also be added, however not to any existing
file (unless forced, which is not recommended)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?


### Stage 4

On server shutdown (or `/sf recipe save`), **all** recipes are saved to disk.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this include ones where addons register them without a file? If so, why?
I like owners being able to change but I'd also like to not force that to be the case.

SchnTgaiSpock and others added 3 commits November 10, 2024 15:55
Co-authored-by: Daniel Walsh <walshydev@gmail.com>
Co-authored-by: Daniel Walsh <walshydev@gmail.com>
Co-authored-by: Daniel Walsh <walshydev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 API This Pull Request introduces API changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants