Skip to content

Commit

Permalink
add mech item.remove_nbt
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 20, 2019
1 parent c76f23b commit e3872a4
Showing 1 changed file with 30 additions and 0 deletions.
Expand Up @@ -124,6 +124,36 @@ public String getPropertyId() {
@Override
public void adjust(Mechanism mechanism) {

// <--[mechanism]
// @object dItem
// @name remove_nbt
// @input dList
// @description
// Removes the Denizen NBT keys specified, or all Denizen NBT if no value is given.
// @tags
// <i@item.has_nbt[<key>]>
// <i@item.nbt_keys>
// <i@item.nbt[<key>]>
// -->
if (mechanism.matches("remove_nbt")) {
if (item.getMaterial().getMaterial() == Material.AIR) {
dB.echoError("Cannot apply NBT to AIR!");
return;
}
ItemStack itemStack = item.getItemStack();
List<String> list;
if (mechanism.hasValue()) {
list = mechanism.getValue().asType(dList.class);
}
else {
list = CustomNBT.listNBT(itemStack, CustomNBT.KEY_DENIZEN);
}
for (String string : list) {
itemStack = CustomNBT.removeCustomNBT(itemStack, string, CustomNBT.KEY_DENIZEN);
}
item.setItemStack(itemStack);
}

// <--[mechanism]
// @object dItem
// @name nbt
Expand Down

0 comments on commit e3872a4

Please sign in to comment.