Trigger after player opens village loot chest 10 times
OriginalNovember 10, 2024Less than 1 minute
Trigger after player opens village loot chest 10 times
const dataKey = "villageChestsOpened";
const maxOpenTimes = 10;
BlockEvents.rightClicked("chest", (event) => {
const { player, block } = event;
if (block.entityData.getString("LootTable").includes("chests/village/")) {
player.persistentData.putLong(
dataKey,
player.persistentData.getLong(dataKey) + 1
);
player.tell("You've opened a village chest!");
if (player.persistentData.getLong(dataKey) >= maxOpenTimes) {
player.tell("You've opened 10 village chests!");
player.persistentData.putLong(dataKey, 0);
}
}
});