Skip to content

Commit

Permalink
add discover_ and forget_ recipe mechs, also some meta info
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 18, 2019
1 parent e169598 commit 5822a66
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Expand Up @@ -4,6 +4,7 @@
import com.denizenscript.denizen.objects.properties.entity.EntityHealth;
import com.denizenscript.denizen.scripts.commands.player.SidebarCommand;
import com.denizenscript.denizen.utilities.DenizenAPI;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizen.utilities.entity.BossBarHelper;
Expand Down Expand Up @@ -3433,6 +3434,28 @@ else if (split.length > 1) {
EquipmentSlot.OFF_HAND, getPlayerEntity().getEquipment().getItemInOffHand());
}

// <--[mechanism]
// @object PlayerTag
// @name discover_recipe
// @input Element
// @description
// Causes the player to discover a recipe. Input is in the Namespace:Key format, for example "minecraft:gold_nugget".
// -->
if (mechanism.matches("discover_recipe")) {
getPlayerEntity().discoverRecipe(Utilities.parseNamespacedKey(mechanism.getValue().asString()));
}

// <--[mechanism]
// @object PlayerTag
// @name forget_recipe
// @input Element
// @description
// Causes the player to forget ('undiscover') a recipe. Input is in the Namespace:Key format, for example "minecraft:gold_nugget".
// -->
if (mechanism.matches("forget_recipe")) {
getPlayerEntity().undiscoverRecipe(Utilities.parseNamespacedKey(mechanism.getValue().asString()));
}

// <--[mechanism]
// @object PlayerTag
// @name edit_sign
Expand Down
Expand Up @@ -71,6 +71,7 @@ public class ItemScriptContainer extends ScriptContainer {
//
// # You can specify the items required to craft your item. For an empty slot, use "air".
// # You are allowed to have non-3x3 shapes (can be any value 1-3 x 1-3, so for example 1x3, 2x1, and 2x2 are fine).
// # Recipe internal IDs will be of the form "denizen:shaped_recipe_<script.name>_<id>" where ID is the recipe list index (starting at 1, counting up).
// recipes:
// 1:
// - ItemTag|ItemTag|ItemTag
Expand All @@ -89,13 +90,15 @@ public class ItemScriptContainer extends ScriptContainer {
//
// # You can specify a list of materials that make up a shapeless recipe.
// # Note: This can overwrite existing shapeless recipes.
// # Recipe internal IDs will be of the form "denizen:shapeless_recipe_<script.name>_<id>" where ID is the recipe list index (starting at 1, counting up).
// shapeless_recipes:
// 1: ItemTag|...
// # Add more shapeless recipes if you want.
// 2: ...
//
// # You can specify a material that can be smelted into your item.
// # Note: This can overwrite existing furnace recipes.
// # Recipe internal IDs will be of the form "denizen:furnace_recipe_<script.name>_<id>" where ID is the recipe list index (starting at 1, counting up).
// furnace_recipes:
// 1:
// # The input item
Expand Down
Expand Up @@ -80,7 +80,7 @@ public void registerShapedRecipe(ItemScriptContainer container, List<String> rec
}
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13)) {
NamespacedKey key = new NamespacedKey("denizen", "item_" + CoreUtilities.toLowerCase(container.getName()) + "_shaped_recipe_" + id);
NamespacedKey key = new NamespacedKey("denizen", "shaped_recipe_" + CoreUtilities.toLowerCase(container.getName()) + "_" + id);
ShapedRecipe recipe = new ShapedRecipe(key, container.getCleanReference().getItemStack());
String shape1 = "ABC".substring(0, width);
String shape2 = "DEF".substring(0, width);
Expand Down

1 comment on commit 5822a66

@mcmonkey4eva
Copy link
Member Author

Choose a reason for hiding this comment

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

This is for #2031

Please sign in to comment.