Skip to content

Commit 875a14a

Browse files
authored
Merge pull request #8 from UpcraftLP/multiloader
port to multiloader
2 parents 1f15540 + ddaa181 commit 875a14a

File tree

31 files changed

+688
-266
lines changed

31 files changed

+688
-266
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
name: build
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: ["*"]
6+
pull_request:
47

58
jobs:
69
build:
710
runs-on: ubuntu-latest
811

912
steps:
10-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1114
- name: set up JDK 21
12-
uses: actions/setup-java@v3
15+
uses: actions/setup-java@v4
1316
with:
1417
distribution: 'temurin'
1518
java-version: '21'
16-
- name: grant execute permission for gradlew
17-
run: chmod +x gradlew
18-
- name: build with gradle
19+
cache: 'gradle'
20+
- name: Validate Gradle wrapper
21+
uses: gradle/actions/wrapper-validation@v4
22+
- name: Grant execute permission for gradlew
23+
run: chmod +x ./gradlew
24+
- name: Build with Gradle
1925
run: ./gradlew build
20-
- name: capture build artifacts
21-
uses: actions/upload-artifact@v3
26+
- name: Upload build artifacts
27+
continue-on-error: true
28+
uses: actions/upload-artifact@v4
2229
with:
23-
name: artifacts
24-
path: build/libs/
30+
name: ${{ github.event.repository.name }}-${{ github.sha }}
31+
path: |
32+
**/build/libs/*.jar

build.gradle

Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,107 @@
11
plugins {
2-
id "fabric-loom" version "1.6+"
3-
id "com.github.johnrengelman.shadow" version "8.1+"
4-
id "maven-publish"
5-
id "me.modmuss50.mod-publish-plugin" version "0.5.2"
2+
id 'idea'
3+
id 'maven-publish'
4+
id 'me.modmuss50.mod-publish-plugin' version '0.7.4' apply false
5+
id 'net.neoforged.moddev' version '2.0.34-beta' apply false
66
}
77

8-
version = project.mod_version
8+
version = "${project.mod_version}+mc${project.minecraft_version}"
99
group = project.maven_group
1010

11-
repositories {
12-
maven { url = "https://maven.quiltmc.org/repository/release/" }
13-
maven { url = "https://maven.terraformersmc.com/releases/" }
14-
maven { url = "https://repo.sleeping.town/" }
15-
}
16-
17-
configurations {
18-
shadow
19-
api.extendsFrom shadow
20-
}
21-
22-
dependencies {
23-
minecraft("com.mojang:minecraft:${project.minecraft_version}")
24-
mappings("org.quiltmc:quilt-mappings:${project.minecraft_version}+build.${project.quilt_mappings}:intermediary-v2")
25-
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
26-
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
27-
28-
implementation("folk.sisby:kaleido-config:${project.kaleido_config_version}")
29-
include("folk.sisby:kaleido-config:${project.kaleido_config_version}")
30-
31-
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
32-
}
33-
34-
processResources {
35-
inputs.property "version", project.version
36-
inputs.property "minecraft_version", project.minecraft_version
37-
inputs.property "loader_version", project.loader_version
38-
filteringCharset "UTF-8"
39-
40-
filesMatching("fabric.mod.json") {
41-
expand "version": project.version,
42-
"minecraft_version": project.minecraft_version,
43-
"loader_version": project.loader_version
11+
def targetJavaVersion = 21
12+
13+
subprojects {
14+
apply plugin: 'java-library'
15+
project.group = rootProject.group
16+
project.version = rootProject.version
17+
18+
repositories {
19+
maven { url = 'https://maven.quiltmc.org/repository/release' }
20+
maven { url = 'https://maven.terraformersmc.com/releases' }
21+
maven { url = 'https://repo.sleeping.town' }
22+
maven {
23+
name = "ParchmentMC"
24+
url = "https://maven.parchmentmc.org"
25+
content {
26+
includeGroupAndSubgroups "org.parchmentmc"
27+
}
28+
}
4429
}
45-
}
46-
47-
publishMods {
48-
displayName = "ramel ${project.version}"
49-
file = remapJar.archiveFile
50-
changelog = rootProject.file("CHANGELOG.md").getText()
51-
type = STABLE
52-
53-
modLoaders.add("quilt")
54-
modLoaders.add("fabric")
55-
56-
dryRun = !providers.environmentVariable("MODRINTH_TOKEN").isPresent()
57-
|| !providers.environmentVariable("CURSEFORGE_TOKEN").isPresent()
58-
|| property("pub.should_publish") == "false"
59-
dryRun = false
6030

61-
var mcVersions = [project.minecraft_version]
62-
mcVersions.addAll(property("pub.additional_versions").toString().split(" ").findAll { !it.empty })
63-
64-
modrinth {
65-
projectId = "4Uw92C2y"
66-
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
67-
mcVersions.forEach(minecraftVersions::add)
31+
java {
32+
withSourcesJar()
33+
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
34+
if (JavaVersion.current() < javaVersion) {
35+
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
36+
}
37+
}
6838

69-
requires("fabric-api")
70-
optional("modmenu")
39+
tasks.withType(JavaCompile).configureEach {
40+
it.options.encoding = 'UTF-8'
41+
it.options.release = targetJavaVersion
7142
}
7243

73-
curseforge {
74-
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
75-
projectId = "877074"
76-
mcVersions.forEach(minecraftVersions::add)
44+
javadoc {
45+
// need this so javadoc doesnt complain about mixin's @reason
46+
options.tags = ['reason']
47+
}
7748

78-
clientRequired = true
79-
serverRequired = false
49+
base {
50+
archivesName = "${rootProject.archives_base_name}-${project.name}"
51+
}
8052

81-
requires("fabric-api")
82-
optional("modmenu")
53+
jar {
54+
from('LICENSE') {
55+
rename { "LICENSE_${rootProject.archives_base_name}"}
56+
}
8357
}
84-
}
8558

86-
def targetJavaVersion = 17
87-
tasks.withType(JavaCompile).configureEach {
88-
it.options.encoding = "UTF-8"
89-
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
90-
it.options.release = targetJavaVersion
59+
sourcesJar {
60+
from('LICENSE') {
61+
rename { "LICENSE_${rootProject.archives_base_name}" }
62+
}
9163
}
92-
}
9364

94-
java {
95-
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
96-
if (JavaVersion.current() < javaVersion) {
97-
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
65+
processResources {
66+
filteringCharset 'UTF-8'
67+
68+
def expandProps = [
69+
'version': version,
70+
'minecraft_version': project.minecraft_version,
71+
'mod_id': project.mod_id,
72+
'maven_group_id': project.maven_group,
73+
'website_url': project.website_url,
74+
'sources_url': project.sources_url,
75+
'issue_tracker_url': project.issue_tracker_url,
76+
'discord_url': project.discord_url,
77+
78+
'fabric_loader_version': project.fabric_loader_version,
79+
'neoforge_version': project.neoforge_version,
80+
'java_version': targetJavaVersion
81+
]
82+
83+
filesMatching(['pack.mcmeta', '*.mod.json', 'META-INF/*mods.toml', '*.mixins.json']) {
84+
expand expandProps
85+
}
86+
inputs.properties(expandProps)
9887
}
99-
archivesBaseName = project.archives_base_name
100-
}
10188

102-
jar {
103-
from("LICENSE") {
104-
rename { "${it}_${project.archivesBaseName}"}
89+
publishing {
90+
publications {
91+
"mavenJava_${project.name}"(MavenPublication) {
92+
artifactId base.archivesName.get()
93+
from components.java
94+
}
95+
}
10596
}
10697
}
10798

108-
// configure the maven publication
109-
publishing {
110-
publications {
111-
mavenJava(MavenPublication) {
112-
from components.java
99+
allprojects {
100+
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
101+
idea {
102+
module {
103+
downloadSources = true
104+
downloadJavadoc = true
113105
}
114106
}
115107
}

common/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
id 'net.neoforged.moddev'
3+
}
4+
5+
dependencies {
6+
compileOnly("org.jetbrains:annotations:${project.jetbrains_annotations_version}")
7+
compileOnly("net.fabricmc:sponge-mixin:${project.mixin_version}")
8+
compileOnly("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}")
9+
annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}")
10+
11+
compileOnly("folk.sisby:kaleido-config:${project.kaleido_config_version}")
12+
}
13+
14+
neoForge {
15+
neoFormVersion = project.neoform_version
16+
17+
parchment {
18+
minecraftVersion = project.parchment_minecraft_version
19+
mappingsVersion = project.parchment_mappings_version
20+
}
21+
}

src/main/java/io/ix0rai/ramel/Config.java renamed to common/src/main/java/dev/rosebud/ramel/Config.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
package io.ix0rai.ramel;
1+
package dev.rosebud.ramel;
22

33
import folk.sisby.kaleido.api.ReflectiveConfig;
44
import folk.sisby.kaleido.lib.quiltconfig.api.annotations.Comment;
55
import folk.sisby.kaleido.lib.quiltconfig.api.annotations.FloatRange;
6-
import folk.sisby.kaleido.lib.quiltconfig.api.serializers.TomlSerializer;
76
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue;
8-
import folk.sisby.kaleido.lib.quiltconfig.implementor_api.ConfigEnvironment;
9-
import net.fabricmc.loader.api.FabricLoader;
7+
import dev.rosebud.ramel.service.ConfigProvider;
108

119
public class Config extends ReflectiveConfig {
12-
private static final String FORMAT = "toml";
13-
private static final String FAMILY = "ramel";
14-
private static final ConfigEnvironment ENVIRONMENT = new ConfigEnvironment(FabricLoader.getInstance().getConfigDir(), FORMAT, TomlSerializer.INSTANCE);
15-
public static final Config INSTANCE = create(ENVIRONMENT, FAMILY, "ramel", Config.class);
10+
private static final String FAMILY = Ramel.MODID;
11+
public static final Config INSTANCE = create(ConfigProvider.load().createConfigEnvironment(), FAMILY, "ramel", Config.class);
1612

1713
@Comment("The amount of extra range beyond the camel's normal hitbox, in blocks, that the ramming effect will apply.")
1814
@Comment("Value will be halved for baby camels.")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package dev.rosebud.ramel;
2+
3+
public class Ramel {
4+
5+
public static final String MODID = "ramel";
6+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package dev.rosebud.ramel.client;
2+
3+
import com.mojang.serialization.Codec;
4+
import folk.sisby.kaleido.lib.quiltconfig.api.Constraint;
5+
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue;
6+
import dev.rosebud.ramel.Config;
7+
import net.minecraft.client.Minecraft;
8+
import net.minecraft.client.OptionInstance;
9+
import net.minecraft.client.Options;
10+
import net.minecraft.client.gui.screens.Screen;
11+
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
12+
import net.minecraft.network.chat.Component;
13+
import org.jetbrains.annotations.Nullable;
14+
15+
import java.util.stream.StreamSupport;
16+
17+
public class RamelConfigScreen extends OptionsSubScreen {
18+
public RamelConfigScreen(@Nullable Screen parent) {
19+
super(parent, Minecraft.getInstance().options, Component.translatable("ramel.config.title"));
20+
}
21+
22+
@Override
23+
@SuppressWarnings({"unchecked", "DataFlowIssue"})
24+
protected void addOptions() {
25+
this.list.addSmall(StreamSupport.stream(Config.INSTANCE.values().spliterator(), false)
26+
.map(value -> createOptional((TrackedValue<Float>) value)).toArray(OptionInstance[]::new));
27+
}
28+
29+
private static OptionInstance<Float> createOptional(TrackedValue<Float> trackedValue) {
30+
Constraint.Range<Float> range = null;
31+
32+
for (Constraint<Float> c : trackedValue.constraints()) {
33+
if (c instanceof Constraint.Range<Float> constraintRange) {
34+
range = constraintRange;
35+
}
36+
}
37+
38+
String stringValue = trackedValue.key().toString();
39+
40+
if (range == null) {
41+
throw new RuntimeException("value must have float range constraint: " + stringValue);
42+
}
43+
44+
float min = range.min();
45+
float max = range.max();
46+
47+
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);
48+
}
49+
}

0 commit comments

Comments
 (0)