Last active
April 21, 2018 03:33
-
-
Save Snow-Pyon/baedf900e8a0e9cf8f27a71b98105f06 to your computer and use it in GitHub Desktop.
Adds utilities for making recipes from drops!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Droppable recipes | |
# Recommended Skript version: 2.2-dev35 or above (https://github.com/bensku/Skript/releases/). | |
# Minecraft version: 1.12.2 (not guaranteed to work in lower versions) | |
# Addon dependencies: | |
# - skript-mirror (https://github.com/btk5h/skript-mirror/releases/) | |
# - (Optionally) Skellett or RandomSK | |
# Script dependencies: | |
# - Metadata.sk (https://gist.github.com/7fcd4be891b98e1432c9a12d54b16796) | |
# TODO: | |
# - Support for shaped recipes. | |
# - Add expressions to get the info of a recipe (ingredients, result, etc.) | |
# - Add a expression to get a recipe id from the result. | |
# - Add condition to check whether a recipe is registered. | |
# - Enhance crafting: | |
# * Better recipe detection when crafting. | |
# * (Possibly) stack-sensitive ingredients. | |
# - (Possibly) add a expression to get a recipe id from ingredients. | |
# ATTENTION: only use the script depend if you don't have any of the optional dependencies. | |
# Register Droppable Recipe | |
# Description: | |
# Registers a new droppable recipe. | |
# Droppable recipes work the exact same way as crafting/workbench recipes except that well, you have to drop them. | |
# Examples: | |
# on load: | |
# | |
# register a new recipe resulting in a stone pickaxe named "test" using 3 of stone and 2 stick | |
effect register [a [new]] droppable recipe (with [the] result|resulting in) %itemtype% [(with|and) [the] id %-number/string%] using [the [ingredients]] %itemtypes%: | |
trigger: | |
if expression-2 isn't set: | |
add 1 to {droppable-recipes::default-id} | |
set {_id} to {droppable-recipes::default-id} | |
else: | |
set {_id} to expression-2 | |
set {droppable-recipes::%{_id}%::ingredients::*} to expressions-1 | |
set {droppable-recipes::%{_id}%::result} to expression-1 | |
add {_id} to {droppable-recipes::registered-recipes::*} | |
# Logic, don't touch this. | |
on drop: | |
if player has metadata "drop-crafting": | |
set {_recipe} to metadata "drop-crafting" from player | |
# Base checks | |
if {droppable-recipes::%{_recipe}%::ingredients::*} doesn't contain the item: | |
delete metadata "drop-crafting" of player | |
stop | |
if {droppable-recipes::%player's uuid%::currently-crafting-items::*} contains the item: | |
delete metadata "drop-crafting" of player and {droppable-recipes::%player's uuid%::currently-crafting-items::*} | |
stop | |
if {droppable-recipes::%player's uuid%::currently-crafting-items::*} is {droppable-recipes::%{_recipe}%::ingredients::*}: | |
delete {droppable-recipes::%player's uuid%::currently-crafting-items::*} | |
give {droppable-recipes::%{_recipe}%::result} to player | |
else: | |
loop {droppable-recipes::registered-recipes::*}: | |
if {droppable-recipes::%loop-value%::ingredients::*} contains the item: | |
set metadata "drop-crafting" of player to loop-value | |
add the item to {droppable-recipes::%player's uuid%::currently-crafting-items::*} | |
exit loop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment