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 Support #7150

Open
wants to merge 22 commits into
base: dev/feature
Choose a base branch
from

Conversation

TheAbsolutionism
Copy link

@TheAbsolutionism TheAbsolutionism commented Oct 16, 2024

Description

This PR aims to add support for recipes including:

  • BukkitClasses#Recipe
  • SkriptClasses#RecipeType
  • DefaultComparators#RecipeType->RecipeType
  • CondDiscoveredRecipes
  • CondRecipeExists
  • EffDiscoverRecipe
  • EffRemoveRecipe
  • EffResetRecipes
  • ExprAllRecipes
  • ExprGetRecipe
  • ExprRecipeCategory
  • ExprRecipeCookingTime
  • ExprRecipeExperience
  • ExprRecipeGroup
  • ExprRecipeIngredients
  • ExprRecipeKey
  • ExprRecipeKeyConverter
  • ExprRecipeResult
  • ExprRecipeType
  • SecRegisterRecipe
  • Utils#NamespacedUtils
  • Utils#RecipeUtils

Target Minecraft Versions: any
Requirements: none
Related Issues: #5261

@Fusezion

This comment was marked as resolved.

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

So uuh thinking about moving this to a module?

@TheAbsolutionism
Copy link
Author

So uuh thinking about moving this to a module?

nada

src/main/java/ch/njol/skript/util/RecipeUtils.java Outdated Show resolved Hide resolved
@Efnilite Efnilite added the feature Pull request adding a new feature. label Oct 16, 2024
src/main/java/ch/njol/skript/util/RecipeUtils.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/util/RecipeUtils.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/util/RecipeUtils.java Outdated Show resolved Hide resolved
Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

I decided more changes were needed, we're aiming for 100

src/main/resources/lang/default.lang Outdated Show resolved Hide resolved
Comment on lines +110 to +112
if (delayed.get()) {
Skript.error("Delays cannot be used within a 'register recipe' section.");
return false;
Copy link
Contributor

@Fusezion Fusezion Oct 16, 2024

Choose a reason for hiding this comment

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

Why not? Maybe I wanna add user input for these, there's nothing here that breaks

on jump:
	set {_player} to player
	register a new furnace recipe with id "why&*($^#&$(*^#&$*#":
		set recipe result to bedrock
		set recipe cooking time to 1 hour
		set recipe experience to 100
		set recipe group to "hand_holders"

		set {-RecipeBuilder::%{_player}%::waiting} to true
		send "What should be the recipe input (item), you have 5 seconds to respond":
		set {_now} to 5 second later
		while {-RecipeBuilder::%{_player}%::waiting} is true:
			if now >= {_now}:
				send "You didn't define the input in time, speed up your typing" to {_player}
				delete {-RecipeBuilder::%{_player}%::*}
				stop
			wait a tick
		set recipe input to {-RecipeBuilder::%{_player}%::waiting}
	delete {-RecipeBuilder::%{_player}%::*}

on chat:
	{-RecipeBuilder::%player%::waiting} is true
	set {_input} to uncolored message parsed as item
	if {_input} is set:
		set {-RecipeBuilder::%player%::waiting} to {_input}
		stop
	send "'%uncolored message%' is an invalid item"

More accurately I just don't see why a wait can't be done, this isn't a consumer like spawn event or anything else, this is a trigger, supporting waits should be fine and will not cause any issues

@Fusezion
Copy link
Contributor

I mentioned it to smurf once, but mentioning it in the pr itself will be good, what's the thought about a proper RecipeChoice implementation to have more support of ingredients.

If this goes through a custom ItemTypeChoice should be created to enable skript's item types correctly and not converting to an itemstack always.

This should be pretty safe due to the fact recipes and these can't be serialized by default

Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

lookin' better


static {
Skript.registerEffect(EffResetRecipes.class,
"reset [the] server['s] recipes");
Copy link
Member

Choose a reason for hiding this comment

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

remove, reset, etc makes me thing maybe the server's recipes should be an expression with changers

Comment on lines +83 to +90
this.pattern = "[the] " + pattern + " [of %-recipes%]";
this.toString = toString;
this.eventClass = eventClass;
this.error = error;
}

RecipePattern(String pattern, String toString, Class<? extends Event>[] eventClasses, String error) {
this.pattern = "[the] " + pattern + " [of %-recipes%]";
Copy link
Member

Choose a reason for hiding this comment

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

again, shouldn't be nullable


static {
Skript.registerExpression(ExprRecipeResult.class, ItemStack.class, ExpressionType.PROPERTY,
"[the] recipe result[ing] [item] [of %-recipes%]");
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't be nullable

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 the idea here is that the expression can be used in a recipe section, and therefor no need to specify the recipe?!?!?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but that should be done via a default value: [of %recipe%] that's filled in by the section's event-recipe

Copy link
Contributor

Choose a reason for hiding this comment

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

oh right, duh... my bad.

Copy link
Author

Choose a reason for hiding this comment

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

Sovde, so I did attempt to make a event value for the section, however, not all recipes are able to be modified after creation, i.e. Smithing Recipe + sub recipes. I was unsure how to go about it as it would be inconsistent.
Let me know what you think I should do

Copy link
Member

Choose a reason for hiding this comment

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

You should wrap them in a mutable wrapper, then

Copy link
Author

Choose a reason for hiding this comment

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

How would I go about doing this? Is there a reference by chance?

Copy link
Member

Choose a reason for hiding this comment

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

Not off the top of my head
you just make your own recipe class that wraps the actual recipe

private static final boolean RUNNING_1_20 = Skript.isRunningMinecraft(1, 20, 0);

static {
Skript.registerSection(SecRegisterRecipe.class, "(register|create) [a] [new] %*recipetype% with [the] (key|id) %string%");
Copy link
Member

Choose a reason for hiding this comment

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

What if I want to create a recipe without registering it? I think that this should wait for secspressions and utilise that feature instead. An expression section to create the recipe, and an effect to register a recipe (could just be the server recipe's expression changer i mentioned before (could support set, add, remove, reset, clear, etc))

Copy link
Contributor

Choose a reason for hiding this comment

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

Is your idea behind it just this?? Since if so I'd agree it's nice, but I think it could be added as a future thing unless it's confirmed Secpressions are 2.10

set {_recipeCopy} to a new %recipetype% with [the] (id|key) %string%:
    set recipe cook time to 10 seconds
    return recipe#???

Copy link
Member

@sovdeeth sovdeeth Oct 17, 2024

Choose a reason for hiding this comment

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

set {_recipeCopy} to a new %recipetype% with [the] (id|key) %string%:
    set recipe cook time to 10 seconds

just this

Copy link
Member

Choose a reason for hiding this comment

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

And they are feature-ready, but just waiting on a double check by walrus

Comment on lines +263 to +265
private void customError(String message) {
Skript.info("Line " + thisNode.getLine() + ": (" + thisScript + ")\n\t" + message + "\n\t" + thisNode.getKey());
}
Copy link
Member

Choose a reason for hiding this comment

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

please either do this properly or don't do it at all
properly would entail an api that all syntaxes could use that uses proper lang nodes and colours like all the rest of the error formats.

Copy link
Contributor

@ShaneBeee ShaneBeee left a comment

Choose a reason for hiding this comment

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

Just a few lil nitpicky things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants