-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
base: dev/feature
Are you sure you want to change the base?
Recipe Support #7150
Conversation
# Conflicts: # src/main/java/ch/njol/skript/classes/data/BukkitClasses.java # src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java # src/main/java/ch/njol/skript/classes/data/DefaultComparators.java # src/main/resources/lang/default.lang
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this 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?
nada |
src/main/java/ch/njol/skript/conditions/CondDiscoveredRecipes.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprRecipeCookingTime.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprRecipeCookingTime.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprRecipeCookingTime.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprRecipeCookingTime.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprRecipeExperience.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
if (delayed.get()) { | ||
Skript.error("Delays cannot be used within a 'register recipe' section."); | ||
return false; |
There was a problem hiding this comment.
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
src/main/java/org/skriptlang/skript/bukkit/recipes/RecipeModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/recipes/RecipeModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/recipes/RecipeModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/recipes/RecipeModule.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Outdated
Show resolved
Hide resolved
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookin' better
@@ -1422,6 +1431,14 @@ public ItemStack get(CraftItemEvent e) { | |||
return e.getRecipe().getResult(); | |||
} | |||
}, 0); | |||
|
|||
EventValues.registerEventValue(CraftItemEvent.class, Recipe.class, new Getter<Recipe, CraftItemEvent>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to your event registration or the module's #load
, same as the rest of em
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be moved to the module's package under util
or just in the base package
if (usingMinecraft) | ||
namespacedKey = NamespacedKey.fromString(key); | ||
else | ||
namespacedKey = NamespacedKey.fromString(key, Skript.getInstance()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (usingMinecraft) | |
namespacedKey = NamespacedKey.fromString(key); | |
else | |
namespacedKey = NamespacedKey.fromString(key, Skript.getInstance()); | |
if (usingMinecraft) { | |
namespacedKey = NamespacedKey.fromString(key); | |
} else { | |
namespacedKey = NamespacedKey.fromString(key, Skript.getInstance()); | |
} |
more readable imo
* @param usingMinecraft whether to have it as Skript or Minecraft namespace | ||
* @return the resulting NamespacedKey | ||
*/ | ||
public static NamespacedKey getNamespacedKey(String key, Boolean usingMinecraft) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static NamespacedKey getNamespacedKey(String key, Boolean usingMinecraft) { | |
public static NamespacedKey getNamespacedKey(String key, boolean usingMinecraft) { |
usingMinecraft has no reason to be nullable
else | ||
namespacedKey = NamespacedKey.fromString(key, Skript.getInstance()); | ||
if (namespacedKey != null) | ||
return namespacedKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return namespacedKey; | |
return namespacedKey; | |
@Since("INSERT VERSION") | ||
public class SecRegisterRecipe extends Section { | ||
|
||
private static final boolean RUNNING_1_20 = Skript.isRunningMinecraft(1, 20, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to SUPPORTS_SMITHING
as this better represents what the variable is used for
private boolean isEvent = false; | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per statement
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return "the recipe result item of " + getExpr().toString(event, debug); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ststata
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return "the recipe type of " + getExpr().toString(event, debug); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
Description
This PR aims to add support for recipes including:
Target Minecraft Versions: any
Requirements: none
Related Issues: #5261