Skip to content

Commit

Permalink
add mechanism LocationTag.clear_loot_table
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 12, 2020
1 parent c997161 commit 6e78cf0
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -2907,6 +2907,7 @@ else if (attribute.startsWith("vertical", 2)) {
// <--[tag]
// @attribute <LocationTag.has_loot_table>
// @returns ElementTag(Boolean)
// @mechanism LocationTag.clear_loot_table
// @description
// Returns an element indicating whether the chest at this location has a loot-table set.
// -->
Expand Down Expand Up @@ -3725,6 +3726,26 @@ else if (state instanceof Dropper) {
}
}

// <--[mechanism]
// @object LocationTag
// @name clear_loot_table
// @input None
// @description
// Removes the loot table from the chest at this location.
// @tags
// <LocationTag.has_loot_table>
// -->
if (mechanism.matches("clear_loot_table")) {
BlockState state = getBlockState();
if (state instanceof Lootable) {
((Lootable) state).setLootTable(null);
state.update();
}
else {
Debug.echoError("'clear_loot_table' mechanism can only be called on a lootable block (like a chest).");
}
}

CoreUtilities.autoPropertyMechanism(this, mechanism);
}
}

0 comments on commit 6e78cf0

Please sign in to comment.