World Threat - Progressive Difficulty (Minecraft 1.21.5-1.21.6)
Stage + THREAT scaling (0–15)
==============================================

Overview
--------
World Threat is a vanilla-friendly datapack that makes your world progressively more dangerous.
As your world progresses and players become more active, hostile mobs scale up in power.
This keeps late-game survival challenging without relying on “days played” or distance from spawn.

This datapack is:
- Vanilla (no mods required)
- Multiplayer-friendly (server-side datapack; works for everyone)
- Global (one shared difficulty level for the whole world)
- No death penalty (difficulty does NOT drop when a player dies)

How difficulty is calculated
----------------------------
The global difficulty level is computed as:

  difficulty = MAX(stage, threatTier)

- STAGE: progression stage based on key vanilla advancements (never decreases).
- THREAT: "world threat points" gained from player activity (kills, mining, dimensions, bosses).
- threatTier: a tier derived from THREAT (+1 tier per 25 THREAT, max 15).

So difficulty can rise either because players progress through the game (STAGE),
or because they are highly active in combat/mining (THREAT).

STAGE progression (milestones)
------------------------------
STAGE is updated automatically and only goes up:

- Stage 3  : Acquire Hardware (smelt iron) OR Deflect an arrow
- Stage 6  : Diamonds!
- Stage 8  : Enchanter (enchant an item)
- Stage 10 : We Need to Go Deeper (enter the Nether)
- Stage 12 : Ancient Debris OR Netherite Armor
- Stage 14 : Enter the End
- Stage 15 : Free the End (kill dragon) OR Elytra OR Create a Beacon

THREAT system (what adds threat points)
---------------------------------------
THREAT is global “activity pressure” that grows when players do impactful actions.

Current sources (added into a buffer first):
- Kill any hostile mob: +1
- Mine a diamond ore block: +5
- Mine ancient debris: +10
- Enter the Nether: +10
- Enter the End: +15
- Kill a Warden: +15
- Kill the Wither: +25

Anti-farm throttle (buffer system)
----------------------------------
To prevent XP farms from instantly skyrocketing difficulty, THREAT uses a buffer:

- Points are first stored in: pd.threat_buf
- Then they are transferred into THREAT at a fixed rate:
  THREAT increases by at most +1 per second.

Meaning:
- Farms can fill up the buffer quickly,
- but difficulty increases smoothly over time, not in sudden spikes.

Mob scaling (applies to all hostiles)
-------------------------------------
All hostile mobs listed by the datapack are scaled once after spawning.

Base scaling by tier (moderate, linear):
- Increased max health, attack damage, armor, and movement speed per tier.

High-tier “spawn burst” bonuses (short duration):
- Small regeneration burst on spawn (helps mobs actually use the extra HP)
- Very high tiers also gain a brief Resistance / Strength burst on spawn

Important notes:
- Only newly spawned mobs are scaled.
- Already-existing mobs keep whatever stats they were given.
- For performance, the datapack processes a limited amount of new mobs per second.

Group-based tweaks (moderate)
---------------------------------
In addition to the base scaling, v4 adds “group flavor” buffs (kept moderate):

RANGED (skeleton/stray/pillager/blaze/ghast/guardian/shulker)
- Increased aggro range (follow range) at higher tiers
- Skeletons/Strays: Bow with Power I–II at high tiers
- Pillagers: Crossbow with Quick Charge I–II at high tiers

CASTERS (evoker/witch)
- Evoker gains modest Speed/Resistance at late game (tier-based)

BRUTES (vindicator/ravager/piglin brute/hoglin/zoglin)
- Knockback resistance in the late game (makes them harder to “stunlock”)

AGILE (spider/cave spider/silverfish/endermite/phantom)
- Speed I in mid tiers, Speed II in very high tiers

Individual mob tweaks (moderate)
--------------------------------
Some mobs also get careful, targeted tweaks:

Creeper
- Speed on mid tiers
- Larger explosion radius at high tiers
- Small chance to spawn charged at tier 15

Witch / Enderman / Shulker / Warden
- Mild late-game survivability or damage tweaks (kept reasonable)

Commands
--------
(Requires operator permission for /function)

- /function pd:status
  Shows current global values: difficulty, stage, THREAT, threatTier, buffer

- /function pd:help
  Shows this help text in-game

- /function pd:test/force15
  Forces max difficulty for testing and spawns a few test mobs

- /function pd:admin/reset
  Resets STAGE/THREAT back to 0 (does not “de-buff” already spawned mobs)

No OP permission?
-----------------
If players cannot use /function, they can still access info via triggers:

- /trigger pd_status
- /trigger pd_help

Installation
------------
1) Put the .zip into:
   <world>/datapacks/

2) In-game run:
   /reload
   /datapack list

Compatibility
-------------
- Vanilla datapack (no mods needed)
- Works on servers and in modpacks
- Designed to be lightweight and performance-friendly

Tip: Avoid stacking multiple “mob scaling” datapacks together,
because attribute boosts can add up and become too strong.
