# MSpawn Hub - Custom Dimension & Spawn Datapack

This datapack generates a custom Hub in an empty dimension that serves as the default spawn point for your world. It is designed to be lightweight, secure, and fully customizable.

## 📖 Overview
*   **Automatic Generation:** The first player to join the world triggers the Hub's generation sequence.
*   **Hardcore Safe:** Players are granted temporary, invisible resistance during dimension transfers to completely prevent "loading fall" deaths.
*   **Anti-Void Security:** If a player falls below Y=70, they are automatically teleported back to the platform.
*   **Return Portals:** The platform includes default portal integrations:
    *   **Green Particles Portal:** Teleports the player to the Overworld Origin (the original world spawn).
    *   **Blue Particles Portal:** Teleports the player to their Personal Spawn Point (e.g., bed, respawn anchor).
*   **Adventure Mode Lock:** Players are forced into Adventure Mode while inside the Hub to prevent griefing, and restored to Survival Mode upon leaving.
*   **Command Access:** Players can use `/trigger hub` at any time to return to the Hub.

> **⚠️ IMPORTANT NOTE FOR MODPACK MAKERS:**
> While this datapack requires NO MODS to function, the default structure provided uses blocks from specific mods. If you install this in a pure Vanilla environment or a different modpack, the structure will generate, but modded blocks will be missing (replaced by air). 
> **You are highly encouraged to import your own structure!**

---

## 🛠️ Customization & Installation Guide

If you wish to change the Hub's appearance, size, or portal locations, everything can be customized.

### 1. Changing the Hub Structure
The Hub is generated using Minecraft's structure system (NBT files). The default Hub is divided into multiple pieces to avoid generation lag.
*   **Location:** `data/mspawn/structure/` (or `structures/`)
*   **How to replace:** 
    1. Build your own Hub in a creative world.
    2. Use Structure Blocks to save your build.
    3. Replace the `.nbt` files in the datapack's folder with your own.
    4. *Note: If your new structure has a different size, you MUST update the placement coordinates in the code (see below).*

### 2. Modifying the Code (`tick.mcfunction`)
All the core logic is handled in a single file: `data/mspawn/functions/tick.mcfunction`. Open this file with any text editor to adjust the settings.

#### A. Adjusting the Landing Coordinates
If your custom Hub has a different center or height, you must change where players are teleported.
Look for `PHASE C: FINAL LANDING` and update the coordinates (default is `0 104 0`):
    execute as @a[tag=wait_tp,scores={hub_timer=-380}] in mspawn:hub run tp @s 0 104 0 180 0
*(Make sure to also update the `/trigger hub` section at the bottom of the file!)*

#### B. Adjusting the Anti-Void Security
If you build a deeper Hub, you need to adjust the void security system.
Look for `ANTI-VOID SECURITY SYSTEM`:
    execute as @a[tag=has_joined] at @s if dimension mspawn:hub if entity @s[y=-64,dy=134] run tp @s 0 104 0 180 0
*Modify `dy=134` (which defines the height limit) based on your new Hub's lowest point.*

#### C. Adjusting Portal Locations
If you move the portals in your custom build, the code needs to know where the new detection zones are.
Look for `RETURN PORTALS TO OVERWORLD` -> `B. Portal Detection`:
    # World Spawn Portal (Default: X = 10 to 11)
    execute as @a at @s if dimension mspawn:hub if entity @s[x=10,y=96,z=-7,dx=1,dy=5,dz=0] run tag @s add in_world_portal

    # Personal Spawn Portal (Default: X = -11 to -10)
    execute as @a at @s if dimension mspawn:hub if entity @s[x=-11,y=96,z=-7,dx=1,dy=5,dz=0] run tag @s add in_personal_portal
*Change the `x=`, `y=`, and `z=` values to match the exact coordinates of your new portal frames.*

### 3. Disabling the Adventure Mode Lock
If you want players to be able to build or break blocks inside the Hub, scroll to the very bottom of `tick.mcfunction` and delete or comment out (using `#`) the `HUB SECURITY: AUTO-ADVENTURE MODE` section.

---
*Created for the community. Feel free to unpack, modify, and use this in your own modpacks!*