Description
Suggestion
Add a new "craftable" expression to the Skript plugin to allow checking and manipulating craftable items in Minecraft. This feature would enable scripters to identify whether an item can be crafted, retrieve craftable items, or loop through all craftable items in the game, enhancing crafting-related scripting capabilities.
Proposed Syntax:
set {_test} to a craftable item
- Sets a variable to a random craftable item.loop all craftable items
- Iterates through all items that have a crafting recipe in the game.if %item% is craftable
- Checks if a specific item has a valid crafting recipe.
Details:
- The expression should check if an item has a registered crafting recipe (shaped, shapeless, or other recipe types) in the server's recipe book, similar to discussions in this Spigot thread (https://www.spigotmc.org/threads/check-if-an-item-is-craftable.340252/), where users sought ways to verify craftable items using Material or ItemStack.
- It should integrate with Bukkit/Spigot's recipe API (e.g.,
org.bukkit.inventory.Recipe
andorg.bukkit.Server.getRecipesFor()
- Javadoc: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#getRecipesFor(org.bukkit.inventory.ItemStack)) to determine if an item is craftable. - The expression should support both vanilla Minecraft recipes and custom recipes added by plugins.
- For the
loop all craftable items
syntax, it should iterate over all items that have at least one associated recipe, returning theirItemStack
orMaterial
type. - The condition
if %item% is craftable
should return true if the item has a recipe, false otherwise, and handle cases like invalid or non-item Materials (e.g., air or non-craftable blocks). - Example usage:
set {_test} to a craftable item broadcast "%{_test}% is craftable!" loop all craftable items: broadcast "Craftable: %loop-item%" if {item} is craftable: send "You can craft %item%!" to player
Use Case:
This feature would simplify scripting for plugins involving crafting mechanics, such as custom crafting systems, recipe guides, or automated crafting checks, addressing the need expressed in the Spigot thread for a straightforward way to check if an item is craftable without complex API calls.
Implementation Notes:
- Leverage
Server.getRecipesFor()
to check if an item has associated recipes. - Ensure compatibility with Minecraft versions 1.13+ (as older versions may handle recipes differently, as noted in related Spigot discussions).
- Handle edge cases like items with no recipes or custom items from other plugins.
- Provide an option to filter by recipe type (e.g., shaped, shapeless) if feasible, though the base expression should prioritize simplicity.
This addition would make Skript more powerful for crafting-related tasks, aligning with community needs for easier recipe handling.
Why?
I want the "craftable" expression added to the Skript plugin because it would greatly simplify scripting for crafting-related mechanics, addressing a common need among developers. Currently, checking if an item is craftable requires complex workarounds using Bukkit's recipe API, as discussed in the Spigot thread (https://www.spigotmc.org/threads/check-if-an-item-is-craftable.340252/), which is cumbersome and error-prone for Skript users. This feature would provide a straightforward, user-friendly way to identify craftable items, loop through them, or use them in conditions, enabling easier creation of custom crafting systems, recipe guides, or automated crafting checks. It would save time, reduce scripting complexity, and enhance Skript's utility for both novice and advanced developers working on Minecraft servers.
Other
The "craftable" expression would significantly enhance Skript's accessibility for server administrators who rely on its intuitive syntax to manage complex game mechanics without deep Java knowledge. By integrating with Bukkit’s recipe API (e.g., org.bukkit.Server.getRecipesFor()
- Javadoc: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#getRecipesFor(org.bukkit.inventory.ItemStack)), it ensures compatibility with both vanilla and custom recipes, making it versatile for diverse server setups. Additionally, supporting this expression could pave the way for future crafting-related features, like querying specific recipe types or ingredients, further expanding Skript’s capabilities. This feature aligns with the community’s expressed need for streamlined crafting checks, as seen in the referenced Spigot thread, and would make Skript a more robust tool for crafting-focused plugins.
Agreement
- I have read the guidelines above and affirm I am following them with this suggestion.