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

Disabled recipes no longer count towards recipe limit #10235

Open
wants to merge 3 commits into
base: version/main
Choose a base branch
from

Conversation

uecasm
Copy link
Contributor

@uecasm uecasm commented Sep 19, 2024

Closes discord thought

Changes proposed in this pull request

  • Disabling a built-in recipe causes it to no longer count against the building's recipe limit.
    • e.g. a level 1 Cookery currently has 22 crafterrecipes, but a limit of 10. If you disable all the built-in recipes it will be back to 0/10 and you will be able to teach 10 other recipes.
  • But you cannot enable a built-in recipe if you're already at or above the limit.
    • which does mean that if you disable any recipe in the level 1 Cookery you won't be able to enable it again until you disable enough other recipes to bring it down to 9/10 or below. Or upgrade the hut/do research to increase the limit.
    • doing a research or upgrade that unlocks a new recipe is permitted to exceed the limit, as before.

Testing

  • Yes I tested this before submitting it.
  • I also did a multiplayer test.

Review please (should port)

This is overall intended as a rebalance to make crafterrecipes (especially from datapacks) less likely to completely "starve out" a low-level crafter and make it impossible to teach additional recipes. But the player is still forced to pick and choose, apart from automatic additions.

@@ -210,11 +210,13 @@ else if(recipe.getIntermediate() != Blocks.AIR)
{
rowPane.findPaneOfTypeByID("gradient", Gradient.class).setVisible(true);
rowPane.findPaneOfTypeByID(BUTTON_TOGGLE, Button.class).setText(Component.translatable("com.minecolonies.coremod.gui.recipe.enable"));
rowPane.findPaneOfTypeByID(BUTTON_TOGGLE, Button.class).setVisible(module.getActiveRecipes() < module.getMaxRecipes());
Copy link
Contributor

Choose a reason for hiding this comment

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

An overall thought about our code, in how far do we want to rely solely on client side validations to ensure everything is valid.

I'm always used that (outside of here) that you want to double up client and server side validations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, usually you should. I kinda deliberately didn't here because the consequences aren't all that bad (it just means the pre-PR behaviour still holds).

In order to actually exploit that you'd have to be running a modified client jar that omitted the check or that forged the packet. Which is not super hard to do with an addon. But why bother?

Now if it was a permissions check or something more serious, you absolutely want that on both sides.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have an extra flag for "pre-set recipes" and make them not count to the limit just?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There kind of already is a preset flag (if it has a recipe id then it's a preset recipe). That's easy on client side since it has the recipe definition but on server side it only has a token so would have to enumerate and look up all the recipes instead of just doing a quick size calculation, so it will have perf consequences.

And I'm not sure that the presets shouldn't count towards the limit, though; they're still something that they can craft so it makes sense that they count -- when not disabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think, I would store on the serverside some additional information together (e.g. if preset) and then not count these towards the limit. So, we can have it fast on both sides. What do you think @someaddons ?

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

Successfully merging this pull request may close these issues.

3 participants