Skip to content

AdvancementManagerHelper ​

com.jsmacrosce.jsmacros.client.api.helper.AdvancementManagerHelper

Since1.8.4

Provides the client's advancement tree and, when a player is available, that player's progress.

Progress queries use the local player's advancement progress; the unfiltered tree queries do not.

js
const player = Player.getPlayer();  
if (player !== null) {
 const manager = player.getAdvancementManager();  

 // the progress views
 Chat.log(`${manager.getCompletedAdvancements().length} done`);  
 Chat.log(`${manager.getStartedAdvancements().length} partly done`);  
 Chat.log(`${manager.getMissingAdvancements().length} not done`);  

 // one advancement, looked up by identifier
 const root = manager.getAdvancement("minecraft:story/root");  
 if (root.getRaw() !== null) {
   const progress = root.getProgress();  
   if (progress.getRaw() !== null) {
     Chat.log(`root is ${progress.isDone() ? "done" : "not done"}`);  
   } else {
     Chat.log("root has no progress entry");  
   }
 }
}

Constructors ​

new AdvancementManagerHelper ​

new AdvancementManagerHelper(AdvancementTree advancementManager)#
Wraps the supplied advancement tree.

Parameters:

  • advancementManager: raw advancement tree to wrap

Methods ​

getAdvancement ​

getAdvancement(String identifier): AdvancementHelperSince1.8.4#
Looks up an advancement by identifier; an omitted namespace defaults to minecraft. The wrapper has no underlying node if the identifier is absent from the tree; check its raw value before using the wrapper.
const player = Player.getPlayer();
if (player === null) { throw new Error("not in a world"); }
const manager = player.getAdvancementManager();
// both spellings work, the namespace is optional
const a = manager.getAdvancement("minecraft:story/root");
const b = manager.getAdvancement("story/root");
if (a.getRaw() !== null) {
  if (b.getRaw() !== null) {
    Chat.log(`${a.getId()} is ${b.getId()}`);
  }
}

Parameters:

  • identifier: the advancement identifier; the minecraft namespace may be omitted
Returns: a wrapper for the matching advancement, with no underlying node if it is absent

getAdvancementProgress ​

getAdvancementProgress(String identifier): AdvancementProgressHelperSince1.8.4#
Returns local-player progress for an advancement identifier; an omitted namespace defaults to minecraft. The advancement must exist in the tree. If it has no progress entry, the returned wrapper has no underlying progress; check its raw value before using it.

Parameters:

  • identifier: the advancement identifier
Returns: a wrapper for the advancement's progress entry, which may have no underlying progress

getAdvancements ​

getAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns every advancement node in the tree; the list order is unspecified.
Returns: the advancement nodes

getAdvancementsForIdentifiers ​

getAdvancementsForIdentifiers(): Map<String, AdvancementHelper>Since1.8.4#
Returns the advancement tree keyed by each identifier's namespace:path string.
Returns: a map containing every advancement; identifiers use the namespace:path form

getAdvancementsProgress ​

getAdvancementsProgress(): Map<AdvancementHelper, AdvancementProgressHelper>Since1.8.4#
Returns the local player's progress entries, keyed by their advancement nodes.
Returns: progress entries present in the local player's progress store

getCompletedAdvancements ​

getCompletedAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns local-player progress entries that are complete.
Returns: the matching advancement nodes

getMissingAdvancements ​

getMissingAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns local-player progress entries that are not complete, including entries with no criteria obtained.
Returns: the matching advancement nodes

getRootAdvancements ​

getRootAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns root advancements, which have no parent.
Returns: the root advancement nodes

getStartedAdvancements ​

getStartedAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns local-player progress entries that are incomplete and have at least one criterion obtained.
Returns: the matching advancement nodes

getSubAdvancements ​

getSubAdvancements(): List<AdvancementHelper>Since1.8.4#
Returns a flat list of non-root advancements.
Returns: the non-root advancement nodes

toString ​

toString(): String#
Returns a diagnostic representation with started, missing, and completed advancement counts. Counts are obtained from the local player's progress lists; started entries are also included in the missing count. A local player is required.
Returns: diagnostic representation containing started, missing, and completed counts