Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port to multiloader #8

Merged
merged 5 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 18 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
name: build

on: [push, pull_request]
on:
push:
branches: ["*"]
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: grant execute permission for gradlew
run: chmod +x gradlew
- name: build with gradle
cache: 'gradle'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v3
- name: Upload build artifacts
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs/
name: ${{ github.event.repository.name }}-${{ github.sha }}
path: |
**/build/libs/*.jar
174 changes: 83 additions & 91 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,115 +1,107 @@
plugins {
id "fabric-loom" version "1.6+"
id "com.github.johnrengelman.shadow" version "8.1+"
id "maven-publish"
id "me.modmuss50.mod-publish-plugin" version "0.5.2"
id 'idea'
id 'maven-publish'
id 'me.modmuss50.mod-publish-plugin' version '0.7.4' apply false
id 'net.neoforged.moddev' version '2.0.34-beta' apply false
}

version = project.mod_version
version = "${project.mod_version}+mc${project.minecraft_version}"
group = project.maven_group

repositories {
maven { url = "https://maven.quiltmc.org/repository/release/" }
maven { url = "https://maven.terraformersmc.com/releases/" }
maven { url = "https://repo.sleeping.town/" }
}

configurations {
shadow
api.extendsFrom shadow
}

dependencies {
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings("org.quiltmc:quilt-mappings:${project.minecraft_version}+build.${project.quilt_mappings}:intermediary-v2")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")

implementation("folk.sisby:kaleido-config:${project.kaleido_config_version}")
include("folk.sisby:kaleido-config:${project.kaleido_config_version}")

modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
}

processResources {
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
inputs.property "loader_version", project.loader_version
filteringCharset "UTF-8"

filesMatching("fabric.mod.json") {
expand "version": project.version,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version
def targetJavaVersion = 21

subprojects {
apply plugin: 'java-library'
project.group = rootProject.group
project.version = rootProject.version

repositories {
maven { url = 'https://maven.quiltmc.org/repository/release' }
maven { url = 'https://maven.terraformersmc.com/releases' }
maven { url = 'https://repo.sleeping.town' }
maven {
name = "ParchmentMC"
url = "https://maven.parchmentmc.org"
content {
includeGroupAndSubgroups "org.parchmentmc"
}
}
}
}

publishMods {
displayName = "ramel ${project.version}"
file = remapJar.archiveFile
changelog = rootProject.file("CHANGELOG.md").getText()
type = STABLE

modLoaders.add("quilt")
modLoaders.add("fabric")

dryRun = !providers.environmentVariable("MODRINTH_TOKEN").isPresent()
|| !providers.environmentVariable("CURSEFORGE_TOKEN").isPresent()
|| property("pub.should_publish") == "false"
dryRun = false

var mcVersions = [project.minecraft_version]
mcVersions.addAll(property("pub.additional_versions").toString().split(" ").findAll { !it.empty })

modrinth {
projectId = "4Uw92C2y"
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
mcVersions.forEach(minecraftVersions::add)
java {
withSourcesJar()
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}

requires("fabric-api")
optional("modmenu")
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = targetJavaVersion
}

curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
projectId = "877074"
mcVersions.forEach(minecraftVersions::add)
javadoc {
// need this so javadoc doesnt complain about mixin's @reason
options.tags = ['reason']
}

clientRequired = true
serverRequired = false
base {
archivesName = "${rootProject.archives_base_name}-${project.name}"
}

requires("fabric-api")
optional("modmenu")
jar {
from('LICENSE') {
rename { "LICENSE_${rootProject.archives_base_name}"}
}
}
}

def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
sourcesJar {
from('LICENSE') {
rename { "LICENSE_${rootProject.archives_base_name}" }
}
}
}

java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
processResources {
filteringCharset 'UTF-8'

def expandProps = [
'version': version,
'minecraft_version': project.minecraft_version,
'mod_id': project.mod_id,
'maven_group_id': project.maven_group,
'website_url': project.website_url,
'sources_url': project.sources_url,
'issue_tracker_url': project.issue_tracker_url,
'discord_url': project.discord_url,

'fabric_loader_version': project.fabric_loader_version,
'neoforge_version': project.neoforge_version,
'java_version': targetJavaVersion
]

filesMatching(['pack.mcmeta', '*.mod.json', 'META-INF/*mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}
archivesBaseName = project.archives_base_name
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
publishing {
publications {
"mavenJava_${project.name}"(MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
allprojects {
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
}
21 changes: 21 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'net.neoforged.moddev'
}

dependencies {
compileOnly("org.jetbrains:annotations:${project.jetbrains_annotations_version}")
compileOnly("net.fabricmc:sponge-mixin:${project.mixin_version}")
compileOnly("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}")
annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}")

compileOnly("folk.sisby:kaleido-config:${project.kaleido_config_version}")
}

neoForge {
neoFormVersion = project.neoform_version

parchment {
minecraftVersion = project.parchment_minecraft_version
mappingsVersion = project.parchment_mappings_version
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import folk.sisby.kaleido.api.ReflectiveConfig;
import folk.sisby.kaleido.lib.quiltconfig.api.annotations.Comment;
import folk.sisby.kaleido.lib.quiltconfig.api.annotations.FloatRange;
import folk.sisby.kaleido.lib.quiltconfig.api.serializers.TomlSerializer;
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue;
import folk.sisby.kaleido.lib.quiltconfig.implementor_api.ConfigEnvironment;
import net.fabricmc.loader.api.FabricLoader;
import io.ix0rai.ramel.service.ConfigProvider;

public class Config extends ReflectiveConfig {
private static final String FORMAT = "toml";
private static final String FAMILY = "ramel";
private static final ConfigEnvironment ENVIRONMENT = new ConfigEnvironment(FabricLoader.getInstance().getConfigDir(), FORMAT, TomlSerializer.INSTANCE);
public static final Config INSTANCE = create(ENVIRONMENT, FAMILY, "ramel", Config.class);
private static final String FAMILY = Ramel.MODID;
public static final Config INSTANCE = create(ConfigProvider.load().createConfigEnvironment(), FAMILY, "ramel", Config.class);

@Comment("The amount of extra range beyond the camel's normal hitbox, in blocks, that the ramming effect will apply.")
@Comment("Value will be halved for baby camels.")
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/io/ix0rai/ramel/Ramel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.ix0rai.ramel;

public class Ramel {

public static final String MODID = "ramel";
}
49 changes: 49 additions & 0 deletions common/src/main/java/io/ix0rai/ramel/client/RamelConfigScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.ix0rai.ramel.client;

import com.mojang.serialization.Codec;
import folk.sisby.kaleido.lib.quiltconfig.api.Constraint;
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue;
import io.ix0rai.ramel.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;

import java.util.stream.StreamSupport;

public class RamelConfigScreen extends OptionsSubScreen {
public RamelConfigScreen(@Nullable Screen parent) {
super(parent, Minecraft.getInstance().options, Component.translatable("ramel.config.title"));
}

@Override
@SuppressWarnings({"unchecked", "DataFlowIssue"})
protected void addOptions() {
this.list.addSmall(StreamSupport.stream(Config.INSTANCE.values().spliterator(), false)
.map(value -> createOptional((TrackedValue<Float>) value)).toArray(OptionInstance[]::new));
}

private static OptionInstance<Float> createOptional(TrackedValue<Float> trackedValue) {
Constraint.Range<Float> range = null;

for (Constraint<Float> c : trackedValue.constraints()) {
if (c instanceof Constraint.Range<Float> constraintRange) {
range = constraintRange;
}
}

String stringValue = trackedValue.key().toString();

if (range == null) {
throw new RuntimeException("value must have float range constraint: " + stringValue);
}

float min = range.min();
float max = range.max();

return new OptionInstance<>("ramel.config." + stringValue, OptionInstance.cachedConstantTooltip(Component.translatable("ramel.config.tooltip." + stringValue)), (text, value) -> Options.genericValueLabel(text, Component.translatable("ramel.config.value." + stringValue, value)), (new OptionInstance.IntRange((int) (min * 10), (int) (max * 10))).xmap((intValue) -> intValue / 10.0F, (doubleValue) -> (int) (doubleValue * 10.0D)), Codec.floatRange(min, max), trackedValue.value(), trackedValue::setValue);
}
}
Loading