Skip to content

Commit

Permalink
add tag inventory.craftable_quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 30, 2020
1 parent 4247da1 commit 029b16d
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -2332,6 +2332,26 @@ else if (slot > object.getInventory().getSize() - 1) {
return new ElementTag(((Keyed) recipe).getKey().toString());
});

// <--[tag]
// @attribute <InventoryTag.craftable_quantity>
// @returns ElementTag(Number)
// @description
// Returns the quantity of items that would be received if this crafting inventory were fully crafted (eg via a shift click).
// -->
registerTag("craftable_quantity", (attribute, object) -> {
Recipe recipe;
if ((object.inventory instanceof CraftingInventory)) {
recipe = ((CraftingInventory) object.inventory).getRecipe();
}
else {
return null;
}
if (recipe == null) {
return null;
}
return new ElementTag(RecipeHelper.getMaximumOutputQuantity(recipe, (CraftingInventory) object.inventory) * recipe.getResult().getAmount());
});

// <--[tag]
// @attribute <InventoryTag.result>
// @returns ItemTag
Expand Down

0 comments on commit 029b16d

Please sign in to comment.