Implement unregister functions in CraftingManager#5809
Implement unregister functions in CraftingManager#5809ShockedPlot7560 wants to merge 12 commits intopmmp:major-nextfrom
Conversation
dktapps
left a comment
There was a problem hiding this comment.
Code looks OK, although I haven't tested this myself.
|
Things to watch out for:
|
|
Does this PR require any further development action or is it just testing? |
|
no, I think the PR code is probably okay. |
|
Fixed #5286 |
|
The code in the PR looks functional. The thing I'm dubious about is that this code expects plugin devs will have to get the exact instance of the recipe they want to unregister, in order to unregister it. I'm not sure this is the best way to go about it. May well result in some painful headaches if someone does something like this: $craftingManager->unregisterShapedRecipe(new ShapedRecipe(
[
"WWW",
"W W",
"WWW",
],
[
"W" => new ExactRecipeIngredient(VanillaBlocks::OAK_PLANKS()->asItem()),
],
[VanillaBlocks::CHEST()->asItem()]
));This code looks fine, but it would not produce the intended result. Basically, I think we need a better way to compare recipes before implementing this. |
|
For me, this is blocked until we find a way to compare recipes (probably in an other Pr, this is why I labelled this one as blocked). |
|
@dktapps I've implemented a new way to compare ShapelessRecipes (for the moment) to make the unregister function accurate. Do we follow the same for others recipes or another system need to be found. |
Not sure. I'll have to dig into the shapeless logic a bit further, but I'm hoping there's a way to simplify this. I really don't like using __toString() for the RecipeIngredient comparisons though... |
|
For |
|
I don't think it's reliable for custom recipe types. Best we push this back until PM6 if that's going to be a problem. |
|
Sadly it will be the solution, I don't see a better way to do it without breaking BC. |
The base branch was changed.
|
We could probably say that in pm6, we are introducing a new method in the ingredient interface to allow two recipes to be compared with each other? This remove the use of __toString |
Introduction
Actually, if we want to delete or replace a recipe, we have to go through Reflection.
This PR provides a means of deleting a recipe to make it disappear, or replacing it by register it immediately afterwards.
There's no need to provide any functions other than this one, as the rest does the job:
Relevant issues
Changes
API changes
Add the following functions to the
CraftingManagerclass:unregisterShapedRecipeunregisterShapelessRecipeunregisterPotionTypeRecipeunregisterPotionContainerChangeRecipeAdd the following function to the
FurnaceRecipeManagerclass:unregisterBackwards compatibility
I didn't want to do it directly, to get an opinion, but the observers should be renamed. It now only listens to the registration but also to the deletion.
Follow-up
Tests
Will remove all craft for Crafting table