╔══════════════════════════════════════════════════════════════════╗
║       PILLARS OF FORTUNE v3.0 — COMPLETE SETUP GUIDE            ║
║       All Issues Fixed | Bedrock Edition                         ║
╚══════════════════════════════════════════════════════════════════╝

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 1 — INSTALL & ACTIVATE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Double-click PillarsOfFortune_v3.mcpack
→ Minecraft imports it automatically.

Activate in: World Settings → Behavior Packs
Enable CHEATS on the world.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 2 — ONE-TIME INIT (run ONCE in chat)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/function setup/init


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 3 — LOBBY BUTTON (1 command block)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Place ONE command block:
  Type:     Impulse
  Redstone: Needs Redstone

Command:
  /function game/start

Connect a Button to it. Done.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 4 — DEATH DETECTION COMMAND BLOCK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Place a SECOND command block (hide it away):
  Type:     Repeat
  Redstone: Always Active

Command:
  /execute as @a[tag=pof_ingame,tag=!pof_dead,m=!survival] run function death/on_death

WHY: doImmediateRespawn=true causes players to respawn
instantly in survival. This block catches them before they
can move and forces spectator mode + shows death title.

The tick_controller also calls death/check every tick
as a backup, but this command block is faster.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 5 — SPECTATOR ENFORCER COMMAND BLOCK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Place a THIRD command block (hide it away):
  Type:     Repeat
  Redstone: Always Active

Command:
  /gamemode spectator @a[tag=pof_dead,m=!spectator]

WHY: This is the final guarantee. Even if doImmediateRespawn
fires before the death check, this block forces dead players
back into spectator every single tick. Dead players can NEVER
escape spectator mode while this block is running.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STEP 6 — TICKING AREA
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Cover your lobby + map area so functions keep running:

/tickingarea add -270 -60 160 360 30 380 "pof_zone"

Adjust coordinates to cover your actual build area.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WHAT WAS FIXED IN v3.0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ MAP RANDOMNESS FIXED
   pof_maptick runs freely every tick while in lobby.
   The exact moment a player presses the button is
   unpredictable → genuine random map every round.
   Maps cycle via maptick ranges (100-tick bands across 0-700).

✅ PER-PLAYER DIFFERENT ITEMS FIXED
   Every player has their own pof_seed (0-99).
   Seeds start at different values (7, 23, 41, 59, 13, 67, 31, 83).
   Each player's seed advances by a different PRIME number per tick
   (7, 11, 13, 17, 19, 23, 29, 31 — one per slot).
   Result: seeds diverge immediately and stay diverged.
   Player 1 and Player 2 will NEVER be at the same seed value
   at loot-drop time.

✅ SPAWN EGGS FIXED
   Only 3 spawn eggs in the entire loot table (Rare tier, 15%).
   Total spawn egg chance = 15% × 3/15 = ~3% per drop.
   Eggs are creeper, zombie, skeleton — the three most fun.
   No egg repeating since each player has a different seed.

✅ LOOT BALANCE FIXED
   Tier breakdown:
     50% COMMON     — blocks, food, torches, basic survival
     25% UNCOMMON   — basic tools, weapons, leather armor
     15% RARE       — iron gear, potions, 3 spawn eggs
      7% EPIC       — diamonds, ender pearls, diamond gear
      2% LEGENDARY  — totem, netherite sword
      1% MYTHIC     — enchanted golden apple (1 in 100 chance)

✅ DEATH SYSTEM FIXED
   3-layer death detection:
   Layer 1: tick_controller checks for spectator mode every tick
   Layer 2: Repeat command block (faster detection)
   Layer 3: Spectator enforcer command block (ultimate guarantee)
   Title shows: "YOU DIED!" + "Better luck next round!"
   Global message shows who was eliminated + how many remain.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ADMIN COMMANDS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/function setup/init          → One-time init (run once)
/function setup/force_reset   → Emergency reset
/function setup/debug         → Show all scores + player seeds
/function game/start          → Manually start game


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CUSTOMIZATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

SPAWN COORDINATES:
  Edit: functions/players/teleport_all.mcfunction

LOBBY COORDINATE:
  Edit: functions/reset/full_reset.mcfunction
  Edit: functions/setup/force_reset.mcfunction
  Current: -237 -52 178

STRUCTURE PLACEMENT:
  Edit: functions/game/phase_loading.mcfunction
  Replace 200 64 200 with your corner XYZ

LOOT ITEMS:
  Edit: functions/loot/tier_common.mcfunction   (50%)
        functions/loot/tier_uncommon.mcfunction (25%)
        functions/loot/tier_rare.mcfunction     (15%)
        functions/loot/tier_epic.mcfunction      (7%)
        functions/loot/tier_legendary.mcfunction (2%)
        functions/loot/tier_mythic.mcfunction    (1%)

LOOT DROP RATE:
  Edit: functions/game/phase_active.mcfunction
  Change "30" to adjust seconds (20=1s, 40=2s, 60=3s)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
FILE STRUCTURE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

POF_BP/
├── manifest.json
└── functions/
    ├── tick.json
    ├── setup/
    │   ├── init.mcfunction
    │   ├── force_reset.mcfunction
    │   └── debug.mcfunction
    ├── game/
    │   ├── tick_controller.mcfunction
    │   ├── start.mcfunction          ← LOBBY BUTTON COMMAND
    │   ├── begin.mcfunction
    │   ├── phase_loading.mcfunction
    │   ├── phase_spawning.mcfunction
    │   ├── begin_countdown.mcfunction
    │   ├── activate_match.mcfunction
    │   ├── phase_active.mcfunction
    │   └── phase_ending.mcfunction
    ├── countdown/
    │   └── tick.mcfunction
    ├── players/
    │   └── teleport_all.mcfunction
    ├── loot/
    │   ├── tick_seed.mcfunction      ← Per-player RNG engine
    │   ├── distribute.mcfunction
    │   ├── give_by_seed.mcfunction   ← Weighted loot router
    │   ├── tier_common.mcfunction    (50%)
    │   ├── tier_uncommon.mcfunction  (25%)
    │   ├── tier_rare.mcfunction      (15%)
    │   ├── tier_epic.mcfunction       (7%)
    │   ├── tier_legendary.mcfunction  (2%)
    │   └── tier_mythic.mcfunction     (1%)
    ├── death/
    │   ├── check.mcfunction
    │   └── on_death.mcfunction
    ├── spectator/
    │   └── enforce.mcfunction
    ├── winner/
    │   ├── check.mcfunction
    │   ├── declare.mcfunction
    │   └── declare_draw.mcfunction
    ├── reset/
    │   └── full_reset.mcfunction
    └── maps/
        └── README.mcfunction

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Pillars of Fortune v3.0 — Bedrock Edition
All issues fixed. Multiplayer optimized.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
