Skip to content

Commit

Permalink
add an optional item context to location.drops
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 19, 2018
1 parent 14160f4 commit 97b90c9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -741,13 +741,21 @@ public String getAttribute(Attribute attribute) {
}

// <--[tag]
// @attribute <l@location.drops>
// @attribute <l@location.drops[(<item>)]>
// @returns dList(dItem)
// @description
// Returns what items the block at the location would drop if broken naturally.
// Optionally specifier a breaker item.
// -->
if (attribute.startsWith("drops")) {
Collection<ItemStack> its = getBlock().getDrops();
Collection<ItemStack> its;
if (attribute.hasContext(1)) {
dItem item = dItem.valueOf(attribute.getContext(1));
its = getBlock().getDrops(item.getItemStack());
}
else {
its = getBlock().getDrops();
}
dList list = new dList();
for (ItemStack it : its) {
list.add(new dItem(it).identify());
Expand Down

0 comments on commit 97b90c9

Please sign in to comment.