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
1 change: 1 addition & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fire==0.4.0
requests>=2.31.0
curseuploadpy @ git+https://github.com/MrTJP/curseuploadpy.git@dev
modrinthpy @ git+https://github.com/MrTJP/modrinthpy.git@dev
78 changes: 78 additions & 0 deletions .github/version_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import fire
import requests
import logging
import sys

# Logging
fmt_str = '[%(asctime)s] %(levelname)s %(lineno)d: %(message)s'
logging.basicConfig(level=logging.INFO, format=fmt_str)
log = logging.getLogger(__name__)


def mark_version(mod_id: str, mc_version: str, mod_version: str, homepage: str, api_key: str, type: str):
"""
Marks a mod version as either 'latest' or 'recommended' in the version checker API.

Parameters:
-----------
mod_id: The mod identifier (e.g., 'project-red-core')
mc_version: The Minecraft version (e.g., '1.21.1')
mod_version: The mod version to mark (e.g., '5.0.0-beta+1')
homepage: The homepage URL for the mod
api_key: API key for authentication
type: Either 'latest' or 'recommended'
"""

# Validate type parameter
if type not in ['latest', 'recommended']:
log.error(f"Invalid type: {type}. Must be 'latest' or 'recommended'")
sys.exit(1)

# Construct the API endpoint
endpoint = f"https://version-check.covers1624.net/api/v2/mark_{type}"

# Build request payload
payload = {
"modId": mod_id,
"mcVersion": mc_version,
"modVersion": mod_version,
"homepage": homepage
}

# Build headers
headers = {
"API-Key": api_key,
"Content-Type": "application/json"
}

log.info(f"Marking {mod_id} v{mod_version} (MC {mc_version}) as {type}...")
log.debug(f"POST {endpoint}")
log.debug(f"Payload: {payload}")

try:
response = requests.post(endpoint, json=payload, headers=headers, timeout=30)
response.raise_for_status()
log.info(f"Successfully marked {mod_id} as {type}")
return True

except requests.exceptions.HTTPError as e:
log.error(f"HTTP error occurred: {e}")
log.error(f"Response status: {response.status_code}")
log.error(f"Response body: {response.text}")
sys.exit(1)

except requests.exceptions.ConnectionError as e:
log.error(f"Connection error occurred: {e}")
sys.exit(1)

except requests.exceptions.Timeout as e:
log.error(f"Request timed out: {e}")
sys.exit(1)

except requests.exceptions.RequestException as e:
log.error(f"An error occurred: {e}")
sys.exit(1)


if __name__ == '__main__':
fire.Fire(mark_version)
60 changes: 58 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -r .github/requirements.txt

- name: Extract Minecraft version
id: mc_version
run: |
mc_version=$(grep '^mc_version=' gradle.properties | cut -d'=' -f2)
echo "mc_version=$mc_version"
echo "mc_version=$mc_version" >> $GITHUB_OUTPUT

- name: Generate version
id: versioning
run: |
Expand Down Expand Up @@ -135,7 +142,7 @@ jobs:
-k $API_TOKEN \
-rt $RELEASE_TYPE \
-v 'Java 17' \
-v 1.21.1 \
-v $MC_VERSION \
-v NeoForge \
-c ./CHANGELOG.md \
--required-dep codechicken-lib-1-8 \
Expand Down Expand Up @@ -164,6 +171,7 @@ jobs:
python -m curseuploadpy "${MODULE_ARGS[@]}" -p 478939 -f transmission/build/libs/*-transmission.jar

env:
MC_VERSION: ${{ steps.mc_version.outputs.mc_version }}
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
API_TOKEN: ${{ secrets.CURSE_TOKEN }}

Expand All @@ -177,7 +185,7 @@ jobs:
create-version \
-v "$MOD_VERSION" \
-c ./CHANGELOG.md \
-gv 1.21.1 \
-gv $MC_VERSION \
-vt $RELEASE_TYPE \
-l neoforge \
--required-dep codechicken-lib \
Expand Down Expand Up @@ -206,6 +214,7 @@ jobs:
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-transmission -n "Project Red Transmission v$MOD_VERSION" -f transmission/build/libs/*-transmission.jar

env:
MC_VERSION: ${{ steps.mc_version.outputs.mc_version }}
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
API_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MOD_VERSION: ${{ steps.versioning.outputs.version }}
Expand All @@ -222,6 +231,53 @@ jobs:
CHANGELOG.md
CHANGELOG.txt

- name: Mark versions in version checker
if: ${{ steps.release_type.outputs.publish_launchers == 'true' }}
run: |
# Function to mark a version in the version checker
mark_version() {
local mod_id=$1
local type=$2
echo "Marking $mod_id as $type..."
python .github/version_checker.py \
--mod_id "$mod_id" \
--mc_version "$MC_VERSION" \
--mod_version "$MOD_VERSION" \
--homepage "https://github.com/MrTJP/ProjectRed" \
--api_key "$API_KEY" \
--type "$type"
}

# List of all modules with their mod IDs
# Note: Mod name "ProjectRed" marked as well for backwards compatibility
MODS=(
"ProjectRed"
"projectred_core"
"projectred_expansion"
"projectred_exploration"
"projectred_fabrication"
"projectred_illumination"
"projectred_integration"
"projectred_transmission"
)

# Mark all modules as latest
for MOD_ID in "${MODS[@]}"; do
mark_version "$MOD_ID" "latest"
done

# Also mark as recommended if this is a full release
if [ "$PUBLISH_GH_RELEASE" = "true" ]; then
for MOD_ID in "${MODS[@]}"; do
mark_version "$MOD_ID" "recommended"
done
fi
env:
MC_VERSION: ${{ steps.mc_version.outputs.mc_version }}
MOD_VERSION: ${{ steps.versioning.outputs.version }}
PUBLISH_GH_RELEASE: ${{ steps.release_type.outputs.publish_gh_release }}
API_KEY: ${{ secrets.VERSION_CHECK_API_KEY }}

- name: Update badge
continue-on-error: true
uses: schneegans/dynamic-badges-action@v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Minecraft Forge mod all about Redstone circuity.
## Latest Versions
| MC Version | Branch | Latest Release | Latest Beta | Status |
|:----------:|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| 1.21.1 | `1.21.1` | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/638175d28f3bf15f4e5c0b964153a3ae/raw/projectred-badge-1.21.1-release.json) | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/638175d28f3bf15f4e5c0b964153a3ae/raw/projectred-badge-1.21.1-beta.json) | Active |
| 1.21.1 | `1.21.1` | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.21.1-release.json) | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.21.1-beta.json) | Active |
| 1.20.4 | `1.20.4` | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.20.4-release.json) | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.20.4-beta.json) | Active |
| 1.20.1 | `1.20.1` | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.20.1-release.json) | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.20.1-beta.json) | Active |
| 1.19.2 | `1.19.x` | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.19.2-release.json) | ![badge](https://img.shields.io/endpoint?logo=.&url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.19.2-beta.json) | End-of-Life |
Expand Down
23 changes: 14 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,22 @@ subprojects { p ->

// Replace version tokens in mods.toml
processResources {
inputs.property 'mod_version', mod_version
inputs.property 'mc_version', mc_version
def expandMap = [
'file': ['jarVersion': mod_version],
'mod_id': "projectred_${p.name}",
'mod_version': mod_version,
'mc_version': mc_version,
'forge_version': forge_version,
'lang_version': forge_version.split('\\.')[0],
'ccl_version': ccl_version,
'cbm_version': cbm_version,
'cct_version': cct_version
]

inputs.properties(expandMap)

filesMatching('META-INF/neoforge.mods.toml') {
expand 'file': ['jarVersion': mod_version],
'mc_version': mc_version,
'forge_version': forge_version,
'lang_version': forge_version.split('\\.')[0],
'ccl_version': ccl_version,
'cbm_version': cbm_version,
'cct_version': cct_version
expand(expandMap)
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.data.BlockTagsProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;
Expand Down Expand Up @@ -69,7 +67,6 @@ public ProjectRedCore(ModContainer container, IEventBus modEventBus) {
// Register config
container.registerConfig(ModConfig.Type.SERVER, Configurator.serverSpec, "projectred-server.toml");
container.registerConfig(ModConfig.Type.CLIENT, Configurator.clientSpec, "projectred-client.toml");
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);

// Register config event handlers
modEventBus.addListener(Configurator::onLoad);
Expand All @@ -79,7 +76,7 @@ public ProjectRedCore(ModContainer container, IEventBus modEventBus) {
modEventBus.addListener(this::onRegisterCaps);

if (FMLEnvironment.dist.isClient()) {
CoreClientInit.init(modEventBus);
CoreClientInit.init(container, modEventBus);
}

// Init packet handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import mrtjp.projectred.core.gui.screen.inventory.ElectrotineGeneratorScreen;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.client.event.RegisterShadersEvent;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.NeoForge;

import static mrtjp.projectred.core.ProjectRedCore.MOD_ID;
Expand All @@ -20,7 +23,10 @@ public class CoreClientInit {

public static CCShaderInstance HALO_SHADER;

public static void init(IEventBus modEventBus) {
public static void init(ModContainer container, IEventBus modEventBus) {
// Enable in-game config screen
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);

modEventBus.addListener(CoreClientInit::clientSetup);
modEventBus.addListener(CoreClientInit::onRegisterShaders);
modEventBus.addListener(CoreClientInit::onRegisterScreens);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Core"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/zIlxygxr/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand All @@ -32,7 +32,7 @@ Redstone. The way it was meant to be.
side="BOTH"
[[dependencies.projectred_core]]
modId="codechickenlib"
type="required"
type="required"
versionRange="[${ccl_version},)"
ordering="AFTER"
side="BOTH"
Expand Down
2 changes: 1 addition & 1 deletion expansion/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Expansion"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/fn5zBLFv/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down
2 changes: 1 addition & 1 deletion exploration/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Exploration"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/TVQMH6pX/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down
2 changes: 1 addition & 1 deletion fabrication/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Fabrication"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/5H1VMCiY/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Illumination"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/9a4Zqq1k/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down
2 changes: 1 addition & 1 deletion integration/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Integration"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/3JruZJb0/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license="MIT"
displayName="ProjectRed Transmission"
version="${file.jarVersion}"

updateJSONURL = "https://api.modrinth.com/updates/dXmH4rEw/forge_updates.json?neoforge=only"
updateJSONURL="https://version-check.covers1624.net/check/?mod=${mod_id}&mc=${mc_version}"
displayURL="https://github.com/MrTJP/ProjectRed"
authors="MrTJP, Chicken Bones, covers1624"
description='''
Expand Down