Skip to content

Enhancement Process

This page provides a detailed description of EmakiStrengthen's complete enhancement process, success rate calculation, failure handling, data storage, and item refresh mechanism.

Complete Enhancement Process

1. Open GUI
   └── Player executes /estrengthen open or opens the enhancement interface through other means

2. Place Equipment
   └── Player places equipment into the target_item slot (slot 13)

3. Recipe Resolution (Recipe Resolve)
   ├── StrengthenRecipeResolver iterates through all loaded recipes
   ├── Matches against match rules one by one (source_types → source_ids → source_patterns → slot_groups → lore_contains → stats_any)
   ├── Match found → Load the corresponding recipe, display current star level and next stage info
   └── No match → Prompt that the equipment cannot be enhanced

4. Place Materials
   └── Player places materials into material_input slots (slots 19/20/29/30)

5. Material Plan Resolution (Material Plan Resolve)
   ├── MaterialPlanResolver reads the materials requirements for the current star stage
   ├── Checks material slots one by one to see if items match
   ├── Match found → Mark materials as consumable, update preview
   └── Match failed → Prompt for missing materials

6. Preview Calculation
   ├── Calculate stat changes after enhancement
   ├── Calculate success rate (including temper bonus)
   ├── Calculate economy cost
   └── Display preview in the preview_display slot (slot 15)

7. Confirm Enhancement
   └── Player clicks the confirm button (slot 40)

8. Execute Enhancement Attempt
   ├── ChanceCalculator computes the final success rate
   ├── Random roll for success/failure
   ├── Success → Enter success flow
   └── Failure → Enter failure flow

9. Success Flow
   ├── Increase star level
   ├── StrengthenSnapshotBuilder rebuilds the enhancement layer
   ├── Write new stats and attributes
   ├── Update structured_presentation
   ├── Execute success_actions
   └── Reset temper level to 0

10. Failure Flow
    ├── Check for protection items
    ├── Protected → Consume protection item, no star loss
    ├── Unprotected → Reduce star or generate crack based on configuration
    ├── Temper level +1 (up to max_temper)
    └── Execute failure_actions

11. PDC Write
    ├── StrengthenPdcAttributeWriter updates PDC data
    ├── Write current star level, temper level, crack level, etc.
    └── Update audit data

12. Economy Deduction
    └── StrengthenEconomyService deducts fees based on cost_formula

13. Consume Materials
    └── Deduct the corresponding amount of materials from material slots

14. Broadcast
    ├── Star level ≥ local_stars → Local broadcast (visible to players within radius)
    └── Star level ≥ global_stars → Global broadcast (visible server-wide)

ChanceCalculator Success Rate Calculation

Base Formula

Final Success Rate = min(base_rate + temper_bonus, success_chance_cap)
VariableDescriptionSource
base_rateBase success rateRecipe success_rates or global config.yml
temper_bonusTemper bonustemper × temper_chance_bonus_per_level
success_chance_capSuccess rate capRecipe limits.success_chance_cap

Calculation Example

Assume:

  • Base success rate for target star 7 = 40%
  • Current temper level = 5
  • Temper bonus per level = 1.5%
  • Success rate cap = 95%
temper_bonus = 5 × 1.5 = 7.5%
Final Success Rate = min(40 + 7.5, 95) = 47.5%

Temper Mechanism

Temper is a compensation mechanism that accumulates on failure:

  • Each enhancement failure increases temper level by 1 (up to max_temper)
  • Each temper level provides temper_chance_bonus_per_level success rate bonus
  • Temper level resets to 0 after a successful enhancement
  • Temper level is stored in the equipment's PDC data

Failure Handling

With Protection Item

Enhancement failed

Protection item detected

Consume protection item

Star level unchanged, no crack generated

Temper level +1

Execute failure_actions

Without Protection Item

Enhancement failed

No protection item

Execute penalty based on configuration:
    ├── Star loss (star level -1, minimum 0)
    └── Generate crack (crack_level +1)

Temper level +1

Execute failure_actions

Crack is a damage state on equipment that may affect the equipment's stats or appearance. Admins can clear it using the /estrengthen clearcrack command.

Data Storage

Enhancement data is stored on the equipment item via PDC (PersistentDataContainer). Data travels with the item and does not depend on external databases. See the API & Integration page for detailed data structures and access methods.

StrengthenRefreshService

The item refresh service is responsible for automatically refreshing the display state of equipment when the enhancement layer data signature changes.

Trigger Timing

  • When a player opens their inventory
  • When a player switches held items
  • When an admin executes /estrengthen refresh
  • After recipe resources are reloaded

Refresh Flow

Check if the item contains strengthen layer data

Read the strengthen audit map from item PDC

Get recipe_id, look up the corresponding recipe
    ├── Recipe not found → Skip refresh
    └── Recipe found ↓
Calculate the signature of the current recipe definition

Compare with the materials_signature stored on the item
    ├── Signatures match → Skip refresh
    └── Signatures differ → Execute refresh

    Get the structured_presentation for the corresponding star stage based on current_star

    Rebuild item display via AssemblyService

    Update materials_signature

Tip

The refresh service only updates the item's display layer (name, Lore) and does not change already-written stat values. To reset stats, use the /estrengthen setstar command to re-set the star level.

Released under the GPL-3.0 License