Skip to content

Commit

Permalink
fully re-written port
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Dec 30, 2024
1 parent 063e239 commit b604cab
Show file tree
Hide file tree
Showing 27 changed files with 537 additions and 455 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Validate gradlew integrity
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down Expand Up @@ -44,8 +44,8 @@ jobs:
echo "${SIGNING_KEY}" | gpg --import -
gpg --local-user "Violet Moon Signing Key" --armor \
--detach-sign ${{ steps.calculate_artifact_names.outputs.forge }}
- name: Archive Forge Artifacts
uses: actions/upload-artifact@v2
- name: Archive NeoForge Artifacts
uses: actions/upload-artifact@v4
with:
name: Forge
path: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thumbs.db

## ForgeGradle
/run
/runs

## eclipse
/.settings
Expand Down
83 changes: 25 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'pmd'
id 'com.diffplug.spotless' version '5.12.5'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7.+'
id 'com.diffplug.spotless' version '6.25.0'
id 'net.neoforged.gradle.userdev' version '7.0.145'
}

ext.configFile = file('build.properties')
Expand All @@ -15,58 +13,30 @@ version = "${config.version}-${config.build_number}"
group = "vazkii.${config.mod_id}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = config.mod_name

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
repositories {
mavenLocal()
}

base {
archivesName = config.mod_name
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

compileJava.options.compilerArgs << "-Xlint:all,-classfile,-processing,-deprecation" << "-Werror"

if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.

mappings channel: "${config.mapping_channel}", version: "${config.mapping_version}"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

mods {
akashictome {
source sourceSets.main
}
}
}

server {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
runs {
configureEach {
systemProperty 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
}

mods {
akashictome {
source sourceSets.main
}
}
}
client {
}
}

Expand All @@ -77,10 +47,9 @@ repositories {
}

dependencies {
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}"
implementation fg.deobf("curse.maven:curios-309927:5367944")
implementation fg.deobf("curse.maven:patchouli-306770:4966125")
implementation fg.deobf("curse.maven:botania-225643:5594997")
implementation "net.neoforged:neoforge:21.1.1"
implementation "curse.maven:patchouli-306770:5683901"
implementation "curse.maven:forcecraft-454802:6020123"
}

spotless {
Expand All @@ -96,10 +65,8 @@ spotless {
}

pmd {
toolVersion '6.22.0'
// no way around this warning unless we upgrade Gradle, apparently
//incrementalAnalysis.set(true)
ruleSets.clear()
toolVersion '6.35.0'
incrementalAnalysis.set(true)
ruleSetFiles = files("spotless/pmd-ruleset.xml")
}

Expand All @@ -118,7 +85,7 @@ task incrementBuildNumber {

import java.util.regex.Pattern
task sortArtifacts(type: Copy) {
from jar.destinationDir
from jar.getDestinationDirectory()
into config.dir_output
//Put each jar with a classifier in a subfolder with the classifier as its name
eachFile {
Expand All @@ -145,7 +112,7 @@ def parseConfig(File config) {

jar {
//rename the default output, for some better... sanity with scipts
archiveName = "${baseName}-${version}.${extension}"
//archiveName = "${baseName}-${version}.${extension}"

manifest {
attributes([
Expand Down
10 changes: 5 additions & 5 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Wed Aug 07 18:14:17 UTC 2024
mapping_channel=parchment
forge_version=47.2.0
neoforge_version=21.1.90
mod_id=akashictome
dir_repo=./
build_number=28
dir_output=../Build Output/AkashicTome/
mapping_version=2023.09.03-1.20.1
version=1.7
version=1.8
mod_name=AkashicTome
mc_version=1.20.1
mc_version=1.21.1
neogradle.subsystems.parchment.minecraftVersion=1.21
neogradle.subsystems.parchment.mappingsVersion=2024.11.17
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
38 changes: 19 additions & 19 deletions scripts/upload_releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ function release_github() {
-f tag_name="${TAGNAME}")"
GH_RELEASE_PAGE=$(echo "$GH_RELEASE_RESPONSE" | jq -r .html_url)

echo >&2 'Uploading Forge Jar and Signature to GitHub'
gh release upload "${TAGNAME}" "${FORGE_JAR}#Forge Jar"
gh release upload "${TAGNAME}" "${FORGE_JAR}.asc#Forge Signature"
echo >&2 'Uploading NeoForge Jar and Signature to GitHub'
gh release upload "${TAGNAME}" "${NEOFORGE_JAR}#NeoForge Jar"
gh release upload "${TAGNAME}" "${NEOFORGE_JAR}.asc#NeoForge Signature"
}

function release_modrinth() {
echo >&2 'Uploading Forge Jar to Modrinth'
local MODRINTH_FORGE_SPEC
MODRINTH_FORGE_SPEC=$(cat <<EOF
echo >&2 'Uploading NeoForge Jar to Modrinth'
local MODRINTH_NEOFORGE_SPEC
MODRINTH_NEOFORGE_SPEC=$(cat <<EOF
{
"dependencies": [],
"version_type": "release",
"loaders": ["forge"],
"loaders": ["neoforge"],
"featured": false,
"project_id": "JBthPdnp",
"file_parts": [
Expand All @@ -42,24 +42,24 @@ function release_modrinth() {
EOF
)

MODRINTH_FORGE_SPEC=$(echo "${MODRINTH_FORGE_SPEC}" | \
MODRINTH_NEOFORGE_SPEC=$(echo "${MODRINTH_NEOFORGE_SPEC}" | \
jq --arg name "${VERSION}" \
--arg mcver "${MC_VERSION}" \
--arg changelog "${GH_RELEASE_PAGE}" \
'.name=$ARGS.named.name | .version_number=$ARGS.named.name | .game_versions=[$ARGS.named.mcver] | .changelog=$ARGS.named.changelog')
curl 'https://api.modrinth.com/v2/version' \
-H "Authorization: $MODRINTH_TOKEN" \
-F "data=$MODRINTH_FORGE_SPEC" \
-F "jar=@${FORGE_JAR}" # TODO modrinth doesn't allow asc files. Remember to readd "signature" to the spec when reenabling this. \ -F "signature=@${FORGE_JAR}.asc"
-F "data=$MODRINTH_NEOFORGE_SPEC" \
-F "jar=@${NEOFORGE_JAR}" # TODO modrinth doesn't allow asc files. Remember to readd "signature" to the spec when reenabling this. \ -F "signature=@${NEOFORGE_JAR}.asc"
}

function release_curseforge() {
# Java versions, Loaders, and Environment tags are actually "game versions" (lmfao), as are real game versions.

# Hardcoded from https://minecraft.curseforge.com/api/game/version-types (which is undocumented, btw)
# I'm not betting on these changing any time soon, so hardcoding is ok
local CURSEFORGE_JAVA_VERSION=8326 # Java 17
local CURSEFORGE_FORGE_VERSION=7498
local CURSEFORGE_JAVA_VERSION=11135 # Java 21
local CURSEFORGE_NEOFORGE_VERSION=10150
local CURSEFORGE_CLIENT_VERSION=9638
local CURSEFORGE_SERVER_VERSION=9639
# For the Minecraft one, don't hardcode so we don't have to remember to come change this every time.
Expand All @@ -73,9 +73,9 @@ function release_curseforge() {
jq --arg mcver "${MC_VERSION}" \
'map(select(.name == $ARGS.named.mcver and .gameVersionTypeID != 1 and .gameVersionTypeID != 615)) | first | .id')

echo >&2 'Uploading Forge Jar to CurseForge'
local CURSEFORGE_FORGE_SPEC
CURSEFORGE_FORGE_SPEC=$(cat <<EOF
echo >&2 'Uploading NeoForge Jar to CurseForge'
local CURSEFORGE_NEOFORGE_SPEC
CURSEFORGE_NEOFORGE_SPEC=$(cat <<EOF
{
"changelogType": "text",
"releaseType": "release"
Expand All @@ -87,17 +87,17 @@ EOF
$CURSEFORGE_JAVA_VERSION,\
$CURSEFORGE_CLIENT_VERSION,\
$CURSEFORGE_SERVER_VERSION,\
$CURSEFORGE_FORGE_VERSION,\
$CURSEFORGE_NEOFORGE_VERSION,\
$CURSEFORGE_GAME_VERSION]"

CURSEFORGE_FORGE_SPEC=$(echo "$CURSEFORGE_FORGE_SPEC" | \
CURSEFORGE_NEOFORGE_SPEC=$(echo "$CURSEFORGE_NEOFORGE_SPEC" | \
jq --arg changelog "$GH_RELEASE_PAGE" \
--argjson gamevers "$CURSEFORGE_FORGE_GAMEVERS" \
'.gameVersions=$ARGS.named.gamevers | .changelog=$ARGS.named.changelog')
curl 'https://minecraft.curseforge.com/api/projects/250577/upload-file' \
-H "X-Api-Token: $CURSEFORGE_TOKEN" \
-F "metadata=$CURSEFORGE_FORGE_SPEC" \
-F "file=@$FORGE_JAR"
-F "metadata=$CURSEFORGE_NEOFORGE_SPEC" \
-F "file=@$NEOFORGE_JAR"
# TODO: Upload the asc as an 'Additional file'
}

Expand Down
10 changes: 6 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pluginManagement {
repositories {
gradlePluginPortal()
jcenter()
mavenCentral()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
mavenLocal()
maven { url = 'https://maven.neoforged.net/releases' }
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
36 changes: 11 additions & 25 deletions src/main/java/vazkii/akashictome/AkashicTome.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package vazkii.akashictome;

import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;

import vazkii.akashictome.network.NetworkHandler;
import vazkii.akashictome.proxy.ClientProxy;
import vazkii.akashictome.proxy.CommonProxy;
Expand All @@ -19,27 +16,16 @@ public class AkashicTome {
public static final String MOD_ID = "akashictome";
public static CommonProxy proxy;

public AkashicTome() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(this::commonSetup);
public AkashicTome(IEventBus bus, ModContainer modContainer, Dist dist) {
bus.addListener(NetworkHandler::registerPayloadHandler);

Registries.ITEMS.register(bus);
Registries.DATA_COMPONENTS.register(bus);
Registries.SERIALIZERS.register(bus);

bus.addListener(this::addToCreativeTab);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.CONFIG_SPEC);
modContainer.registerConfig(ModConfig.Type.COMMON, ConfigHandler.CONFIG_SPEC);

proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy = dist.isClient() ? new ClientProxy() : new CommonProxy();
proxy.preInit();
}

public void commonSetup(FMLCommonSetupEvent event) {
NetworkHandler.register();
}

private void addToCreativeTab(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
event.accept(Registries.TOME);
}
}
}
Loading

0 comments on commit b604cab

Please sign in to comment.