Progression - MarkusBordihn/BOs-Easy-NPC GitHub Wiki

Progression System 📊⬆️

The progression system lets NPCs gain XP, level up, and optionally scale attributes with their level.

Progression Display

Overview

Current progression limits in the code:

  • minimum level: 1
  • maximum level: 60
  • default progression data: level 1, XP 1, attribute scaling disabled

XP changes automatically recalculate the level. Level changes can also trigger optional attribute scaling.

Commands 🎮

/easy_npc progression get <NPC>
/easy_npc progression set <NPC> level <1-60>
/easy_npc progression set <NPC> xp <xp>
/easy_npc progression add <NPC> xp <xp>
/easy_npc progression scaling <NPC> <true|false>

Notes:

  • set xp accepts values starting at 1
  • add xp accepts positive and negative values
  • XP is clamped internally to the supported progression range

API Usage

Get progression data from an Easy NPC:

ProgressionDataCapable<?> progression = easyNPC.getEasyNPCProgressionData();
if (progression != null) {
  int level = progression.getExperienceLevel();
  int xp = progression.getExperience();
}

Useful methods:

progression.setExperience(250);
progression.addExperience(50);
progression.setExperienceLevel(10);
progression.setAttributeScalingEnabled(true);

Progress helpers:

int currentLevel = progression.getExperienceLevel();
int currentXp = progression.getExperience();
int nextLevelXp = progression.getExperienceForNextLevel();
int progressXp = progression.getExperienceProgressToNextLevel();
float progressPercent = progression.getProgressPercentageToNextLevel();
boolean maxLevel = progression.isMaxExperienceLevel();

Callbacks

ProgressionDataCapable provides these callbacks:

  • onProgressLevelUp(ProgressionData oldData, ProgressionData newData)
  • onProgressLevelDown(ProgressionData oldData, ProgressionData newData)
  • onProgressLevelChange(ProgressionData oldData, ProgressionData newData)

onProgressLevelChange(...) is the central callback and applies level-based attribute scaling after the level change.

XP Formula

The current XP table is generated from:

if (level <= 1) {
  return 1;
}
return (int) (Math.pow(level, 2.5) + (level * 10));

Examples from the current table:

Level XP for level
1 1
2 14
5 105
10 416
20 1988
40 10519
60 28485

Attribute Scaling

If attribute scaling is enabled, the current implementation reapplies level-based scaling whenever the progression state changes.

You can also use the built-in helper for your own scaling logic:

int adjustment = progression.getAttributeAdjustment(baseValue, maxValue);

This calculates a linear adjustment based on the current level and the configured max level.

Storage

Progression data is synchronized through synched entity data and stored in NBT through ProgressionData.

The current record shape is:

public record ProgressionData(
    int experience,
    int experienceLevel,
    boolean attributeScalingEnabled) {}

Notes

  • Progression does not award XP automatically. Your code or commands must change XP explicitly.
  • Setting XP can level an NPC up or down.
  • Level and XP are linked through ProgressionLevelMap.

See also:

⚠️ **GitHub.com Fallback** ⚠️