Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail

# Resolve the previous nightly tag position for incremental changelog.
# Falls back to the latest stable (v*) tag if nightly tag does not exist.
prev_sha=""
compare_base=""

if git rev-parse nightly >/dev/null 2>&1; then
prev_sha=$(git rev-parse nightly)
fi

if [ -n "$prev_sha" ] && [ "$prev_sha" != "$GITHUB_SHA" ]; then
compare_base="$prev_sha"
else
last_tag=$(git describe --tags --abbrev=0 --match='v*' 2>/dev/null || true)
if [ -n "$last_tag" ]; then
compare_base="$last_tag"
fi
fi

if [ -n "$compare_base" ]; then
changelog=$(git log --pretty=format:"- %s (%h)" "${compare_base}..HEAD")
compare_url="https://github.com/${GITHUB_REPOSITORY}/compare/${compare_base}...${GITHUB_SHA}"
else
changelog="- Initial nightly build"
compare_url=""
fi

{
echo "body<<BODY_EOF"
echo "## Nightly \`${SHORT_SHA}\`"
echo ""
echo "**Date:** $(date -u '+%Y-%m-%d %H:%M UTC')"
echo "**Commit:** ${GITHUB_SHA}"
[ -n "$compare_url" ] && echo "**Changes:** [compare](${compare_url})"
echo ""
echo "### What's Changed"
echo "$changelog"
echo "BODY_EOF"
} >> "$GITHUB_OUTPUT"
4 changes: 4 additions & 0 deletions .github/templates/start.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ if errorlevel 1 (
)

java -jar packwiz-installer-bootstrap.jar -g -s server "@PACK_URL@"
if errorlevel 1 (
echo Pack update failed.
exit /b 1
)
java -jar "@FORGE_JAR@" nogui
23 changes: 21 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ on:
push:
branches:
- 'main'
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- 'NOTICE.md'
- 'CLAUDE.md'
- '.github/ISSUE_TEMPLATE/**'

env:
MANIFEST_REPO: GregTechLite/gregtechlite.github.io
Expand All @@ -29,7 +36,13 @@ jobs:
ref: ${{ github.ref_name }}

- name: Install Nix
uses: cachix/install-nix-action@v31
uses: nixbuild/nix-quick-install-action@v34

- name: Cache Nix store
uses: nix-community/cache-nix-action@v7
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-

- name: Load devShell
uses: rrbutani/use-nix-shell-action@v1
Expand Down Expand Up @@ -62,6 +75,10 @@ jobs:
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: "Nightly ${{ env.SHORT_SHA }}"

- name: Generate changelog
id: changelog
run: bash .github/scripts/changelog.sh

- name: Update nightly tag
run: |
git tag -f nightly
Expand All @@ -72,13 +89,14 @@ jobs:
with:
tag: nightly
name: Nightly ${{ env.SHORT_SHA }}
body: ${{ steps.changelog.outputs.body }}
prerelease: true
artifacts: |
${{ steps.package.outputs.curseforge_zip }}
${{ steps.package_server.outputs.server_zip }}
allowUpdates: true
updateOnlyUnreleased: true
generateReleaseNotes: true
removeArtifacts: true

- name: Upload nightly artifacts
uses: actions/upload-artifact@v4
Expand All @@ -87,4 +105,5 @@ jobs:
path: |
${{ steps.package.outputs.curseforge_zip }}
${{ steps.package_server.outputs.server_zip }}
retention-days: 7
if-no-files-found: error
65 changes: 65 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: PR Build

on:
pull_request:
branches:
- 'main'
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- 'NOTICE.md'
- 'CLAUDE.md'
- '.github/ISSUE_TEMPLATE/**'

permissions:
contents: read

concurrency:
group: ci-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Nix
uses: nixbuild/nix-quick-install-action@v34

- name: Cache Nix store
uses: nix-community/cache-nix-action@v7
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-

- name: Load devShell
uses: rrbutani/use-nix-shell-action@v1
with:
devShell: .#default

- name: Resolve metadata
run: bash .github/scripts/meta.sh

- name: Package client
id: package
run: bash .github/scripts/client.sh "${SLUG}-pr${{ github.event.pull_request.number }}-${SHORT_SHA}"

- name: Package server
id: package_server
run: bash .github/scripts/server.sh "${SLUG}-pr${{ github.event.pull_request.number }}-${SHORT_SHA}" "https://raw.githubusercontent.com/${{ github.event.pull_request.head.repo.full_name }}/${{ github.event.pull_request.head.sha }}/pack.toml"

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: "${{ env.SLUG }}-pr${{ github.event.pull_request.number }}-${{ env.SHORT_SHA }}"
path: |
${{ steps.package.outputs.curseforge_zip }}
${{ steps.package_server.outputs.server_zip }}
retention-days: 3
if-no-files-found: error
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ jobs:
ref: ${{ github.ref_name }}

- name: Install Nix
uses: cachix/install-nix-action@v31
uses: nixbuild/nix-quick-install-action@v34

- name: Restore Nix store cache
uses: nix-community/cache-nix-action/restore@v7
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-

- name: Load devShell
uses: rrbutani/use-nix-shell-action@v1
Expand Down
4 changes: 4 additions & 0 deletions .packwizignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ flake.lock

# GitHub
/.github/

# Claude
CLAUDE.md
/.claude/
96 changes: 96 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

GregTech Lite (GTLite) is a Minecraft 1.12.2 Forge modpack centered around GregTech CE Unofficial (GTCEu). It uses **PackWiz** for mod management and distribution, **GroovyScript** for recipe customization, and **BetterQuesting** for progression.

- Pack metadata: `pack.toml` (name, version, Minecraft/Forge versions)
- File manifest: `index.toml` (SHA256 hashes of all packed files)
- Mod definitions: `mods/*.pw.toml` (PackWiz metadata referencing CurseForge)
- Three local JARs in `mods/`: `gregtech-*.jar` (GTCEu), `gtlitecore-*.jar` (custom core mod), `morphismlib-*.jar` (dependency library)

## Development Environment

Requires Nix. Enter the dev shell with:
```bash
nix develop
```
This provides: JDK 8, tomlq (yq), packwiz, zip.

## Common Commands

```bash
# Export CurseForge client package
packwiz curseforge export -o dist/output.zip

# Add a mod from CurseForge
packwiz curseforge install <mod-slug>

# Update a mod
packwiz update <mod-name>

# Refresh index.toml after file changes
packwiz refresh
```

## Architecture

### GroovyScript Recipes (`groovy/`)

Recipe loading is configured in `groovy/runConfig.json` with two phases:
- **preInit**: `event/` (MaterialEventHandler, TooltipEventHandler), `util/` (GroovyUtil)
- **postInit**: `loader/` — OreDictionaryLoader, `loader/hooks/`, `loader/recipe/`

Each file in `loader/recipe/` handles recipe modifications for a specific mod (e.g., `AppliedEnergistics2.groovy`, `EnderIO.groovy`, `GregTech.groovy`). All recipes are redesigned to follow GregTech's philosophy.

**Recipe syntax patterns:**
- Machine recipes: `recipemap('assembler').recipeBuilder().inputs(...).outputs(...).duration(...).EUt(VA[LV]).buildAndRegister()`
- Crafting: `crafting.addShapeless(...)`, `crafting.shapedBuilder(...).key(...).build()`
- Item references: `metaitem('circuit.good')`, `ore('plateSteel')`, `item('minecraft:stone')`, `fluid('water')`
- Energy tiers: `VA[ULV]` through `VA[MAX]`, duration constants like `SECOND`

### Quest System (`config/betterquesting/DefaultQuests/`)

- `QuestLines/*.json` — Quest line definitions (20 lines covering LV through MAX voltage tiers)
- `Quests/<questline-id>/<quest-id>.json` — Individual quest data

Quest JSON uses a NBT-like format with type suffixes: `:2` = short, `:3` = int, `:7` = byte array, `:8` = string, `:9` = tag list, `:10` = compound tag, `:11` = int array.

### Config (`config/`)

Mod configuration files. Key ones:
- `gregtech/gregtech.cfg` — GregTech balance and features
- `AppliedEnergistics2/AppliedEnergistics2.cfg` — AE2 settings
- `betterquesting.cfg` — Quest UI and behavior

### Resources (`resources/`)

Resource pack overrides: custom textures, lang files, and JEI integration. Organized by mod namespace (e.g., `gregtech/`, `appliedenergistics2/`, `minecraft/`).

## CI/CD

Three GitHub Actions workflows (all use Nix dev shell):

- **pr.yml** ("PR Build"): Triggered on PRs to `main`. Ignores docs-only changes. Uses PR number and short SHA in artifact names (e.g., `gregtech-lite-pr42-a1b2c3d-curseforge.zip`). Concurrency groups by PR number to cancel stale builds. 3-day artifact retention.
- **nightly.yml**: Triggered on push to `main` (+ `workflow_dispatch`). Builds artifacts, deploys manifest to `GregTechLite/gregtechlite.github.io` under `nightly/`, generates changelog from git history, force-updates `nightly` tag, publishes prerelease. 7-day artifact retention.
- **release.yml**: Triggered by `v*` tags. Validates tag matches `pack.toml` version, builds artifacts, deploys manifest to `releases/{VERSION}/`, publishes GitHub Release.

### Build Scripts (`.github/scripts/`)

- `meta.sh` — Extracts metadata from `pack.toml` via `tomlq` and exports to `$GITHUB_ENV`: `NAME`, `SLUG`, `VERSION`, `MINECRAFT_VERSION`, `FORGE_VERSION`, `SHORT_SHA`
- `client.sh` — Runs `packwiz curseforge export` into `dist/`
- `server.sh` — Downloads Forge installer + packwiz-installer-bootstrap, runs Forge install, generates start scripts from `.github/templates/` (`start.sh.in`, `start.bat.in`, `eula.txt`, `README.txt.in`), creates server ZIP
- `manifest.sh` — Copies `pack.toml`, `index.toml`, and all indexed files to `dist/manifest/` for deployment
- `changelog.sh` — Generates incremental nightly changelog by diffing from previous `nightly` tag or latest `v*` tag

## File Exclusions

`.packwizignore` excludes development-only files (docs/, .github/, flake.nix, CLAUDE.md, logo.png, IDE metadata, etc.) from pack exports. Only game-relevant files ship to players.

## Licensing

- Modpack code: GNU AGPL 3.0
- Assets: CC BY-NC-SA 3.0
- Questbook content: CC BY-NC-ND 3.0
Loading