# AdvancementHelper

`com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper`

**Since:** 1.8.4

Represents an advancement definition and its position in the advancement tree. Use
 [getParent()](#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getParent-) and [getChildren()](#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getChildren-) to navigate the tree; rewards and requirements
 describe the definition, while [getProgress()](#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getProgress-) reports local-player progress.  
 
 Obtain advancements from the player's advancement manager.  
 ```js
const player = Player.getPlayer();  
if (player !== null) {
  const manager = player.getAdvancementManager();  

  // one advancement by identifier, and what it awards
  const root = manager.getAdvancement("minecraft:story/root");  
  if (root.getRaw() !== null) {
    Chat.log(`${root.getId()} gives ${root.getExperience()} xp`);  
    if (root.getLoot().length > 0) {
      Chat.log(`and loot: ${root.getLoot().join(", ")}`);  
    }

    // walk the tree downwards from there
    for (const child of root.getChildren()) {
      Chat.log(`  child ${child.getId()}`);  
    }

    // and how far the player has got on it
    const progress = root.getProgress();  
    if (progress.getRaw() !== null) {
      Chat.log(`${Math.round(progress.getPercentage() * 100)} percent`);  
    }
  }
}
 ```

## Constructors

### new AdvancementHelper {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_constructor-AdvancementNode-}

```js
new AdvancementHelper(AdvancementNode base)
```

Wraps the supplied advancement node.

**Parameters:**
- `base`: raw advancement node to wrap

## Methods

### getChildren {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getChildren-}

```js
getChildren(): List<AdvancementHelper>
```

Returns this node's direct children, not their descendants. A leaf has no children.

**Returns:** a list of all child advancements.

**Since:** 1.8.4

### getExperience {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getExperience-}

```js
getExperience(): int
```

Returns the experience points awarded when this advancement is earned.

**Returns:** the experience awarded by this advancement.

**Since:** 1.8.4

### getId {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getId-}

```js
getId(): String
```

Returns the advancement's data-pack identifier.

**Returns:** the identifier of this advancement.

**Since:** 1.8.4

### getLoot {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getLoot-}

```js
getLoot(): String[]
```

Returns the identifiers of loot tables granted by this advancement.  
 Inline loot tables on Minecraft 26.3 and later have no registry identifier and are omitted.

**Returns:** the loot table ids for this advancement's rewards.

**Since:** 1.8.4

### getParent {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getParent-}

```js
getParent(): AdvancementHelper
```

Returns this advancement's parent in the tree, or `null` if it is a root.

**Returns:** the parent advancement or `null` if there is none.

**Since:** 1.8.4

### getProgress {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getProgress-}

```js
getProgress(): AdvancementProgressHelper
```

Returns the local player's progress for this advancement, from the progress data received
 from the server. If no progress entry exists, the returned helper wraps `null`; its
 progress methods cannot be used in that state.

**Returns:** the local player's progress, or a helper wrapping `null` if no progress entry exists.

**Since:** 1.8.4

### getRecipes {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getRecipes-}

```js
getRecipes(): String[]
```

Returns identifiers of recipes unlocked by this advancement; empty when it has no recipe rewards.

**Returns:** the recipes unlocked through this advancement.

**Since:** 1.8.4

### getRequirementCount {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getRequirementCount-}

```js
getRequirementCount(): int
```

Returns the number of requirement groups, not the number of individual criteria.

**Returns:** the amount of requirements.

**Since:** 1.8.4

### getRequirements {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_getRequirements-}

```js
getRequirements(): List<List<String>>
```

Returns the advancement's criterion requirements grouped by completion rule.  
 
 Every group must be satisfied; satisfying any one criterion in a group satisfies that group.  
 ```js
const player = Player.getPlayer();  
if (player === null) { throw new Error("not in a world"); }
const manager = player.getAdvancementManager();  
const adv = manager.getAdvancement("minecraft:story/mine_stone");  
for (const group of adv.getRequirements()) {
  // one of these is enough for this group, and every group is needed
  Chat.log(`needs one of: ${group.join(" or ")}`);  
}
 ```

**Returns:** the requirements of this advancement.

**Since:** 1.8.4

### toJson {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_toJson-}

```js
toJson(): String
```

Returns this advancement's definition encoded as a JSON string.

**Returns:** this advancement's JSON definition.

**Since:** 1.9.0

### toString {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation containing this advancement's identifier.

**Returns:** diagnostic representation of this advancement
