Interface Vault

All Superinterfaces:
BlockState, Metadatable, PersistentDataHolder, PersistentDataViewHolder, TileState

@NullMarked public interface Vault extends TileState
Represents a captured state of a vault.
  • Method Details

    • getActivationRange

      double getActivationRange()
      Gets the range in blocks at which this vault will become active when a player is near.
      Returns:
      This vault's activation range.
    • setActivationRange

      void setActivationRange(double activationRange)
      Sets the range in blocks at which the vault will become active when a player is near.
      Parameters:
      activationRange - The new activation range.
      Throws:
      IllegalArgumentException - if the new range is not a number, or if the new range is more than getDeactivationRange().
    • getDeactivationRange

      double getDeactivationRange()
      Gets the range in blocks at which this vault will become inactive when a player is not near.
      Returns:
      This vault's deactivation range.
    • setDeactivationRange

      void setDeactivationRange(double deactivationRange)
      Sets the range in blocks at which this vault will become inactive when a player is not near.
      Parameters:
      deactivationRange - The new deactivation range
      Throws:
      IllegalArgumentException - if the new range is not a number, or if the new range is less than getActivationRange().
    • getKeyItem

      ItemStack getKeyItem()
      Gets the ItemStack that players must use to unlock this vault.
      Returns:
      The item that players must use to unlock this vault.
    • setKeyItem

      void setKeyItem(ItemStack key)
      Sets the ItemStack that players must use to unlock this vault.
      Parameters:
      key - The key item.
    • getLootTable

      LootTable getLootTable()
      Gets the LootTable that this vault will select rewards from.
      Returns:
      The loot table.
    • setLootTable

      void setLootTable(LootTable lootTable)
      Sets the LootTable that this vault will select rewards from.
      Parameters:
      lootTable - The new loot table.
    • getDisplayedLootTable

      @Nullable LootTable getDisplayedLootTable()
      Gets the loot table that this vault will display items from.

      Falls back to the regular loot table if unset.

      Returns:
      The LootTable that will be used to display items.
    • setDisplayedLootTable

      void setDisplayedLootTable(@Nullable LootTable lootTable)
      Sets the loot table that this vault will display items from.
      Parameters:
      lootTable - The new loot table to display, or null to clear this display override.
    • getNextStateUpdateTime

      long getNextStateUpdateTime()
      Gets the next time (in game time) that this vault block will be updated/ticked at.
      Returns:
      The next time that this vault block will be updated/ticked at.
      See Also:
    • setNextStateUpdateTime

      void setNextStateUpdateTime(long nextStateUpdateTime)
      Sets the next time that this vault block will be updated/ticked at, if this value is less than or equals to the current World.getGameTime(), then it will be updated in the first possible tick.
      Parameters:
      nextStateUpdateTime - The next time that this vault block will be updated/ticked at.
      See Also:
    • getRewardedPlayers

      @Unmodifiable Collection<UUID> getRewardedPlayers()
      Gets the players who have used a key on this vault and unlocked it.
      Returns:
      An unmodifiable collection of player uuids.
      API Note:
      Only the most recent 128 player UUIDs will be stored by vault blocks.
    • addRewardedPlayer

      boolean addRewardedPlayer(UUID playerUUID)
      Adds a player as rewarded for this vault.
      Parameters:
      playerUUID - The player's uuid.
      Returns:
      true if this player was previously not rewarded, and has been added as a result of this operation.
      API Note:
      Only the most recent 128 player UUIDs will be stored by vault blocks. Attempting to add more will result in the first player UUID being removed.
    • removeRewardedPlayer

      boolean removeRewardedPlayer(UUID playerUUID)
      Removes a player as rewarded for this vault, allowing them to use a key item again to receive rewards.
      Parameters:
      playerUUID - The player's uuid.
      Returns:
      true if this player was previously rewarded, and has been removed as a result of this operation.
      API Note:
      Only the most recent 128 player UUIDs will be stored by vault blocks.
    • hasRewardedPlayer

      boolean hasRewardedPlayer(UUID playerUUID)
      Returns whether a given player has already been rewarded by this vault.
      Parameters:
      playerUUID - The player's uuid.
      Returns:
      Whether this player was previously rewarded by this vault.
    • getConnectedPlayers

      @Unmodifiable Set<UUID> getConnectedPlayers()
      Gets an unmodifiable set of "connected players"; players who are inside this vault's activation range and who have not received rewards yet.
      Returns:
      An unmodifiable set of connected player uuids.
      API Note:
      Vaults will only periodically scan for nearby players, so it may take until the next update time for this collection to be updated upon a player entering its range.
    • hasConnectedPlayer

      boolean hasConnectedPlayer(UUID playerUUID)
      Returns whether a given player is currently connected to this vault.
      Parameters:
      playerUUID - the player's uuid
      Returns:
      true if this player is currently connected to this vault.
      See Also:
    • getDisplayedItem

      ItemStack getDisplayedItem()
      Gets the item currently being displayed inside this vault. Displayed items will automatically cycle between random items from the getDisplayedLootTable() or getLootTable() loot tables while this vault is active.
      Returns:
      The item currently being displayed inside this vault.
    • setDisplayedItem

      void setDisplayedItem(ItemStack displayedItem)
      Sets the item to display inside this vault until the next cycle.
      Parameters:
      displayedItem - The item to display