Skip to content

Commit

Permalink
LibX 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
noeppi-noeppi committed Jan 26, 2025
1 parent 93a0300 commit ff0722f
Show file tree
Hide file tree
Showing 369 changed files with 4,823 additions and 5,207 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ body:
validations:
required: true
- type: input
id: forge-version
id: neoforge-version
attributes:
label: Forge version
label: Neoforge version
validations:
required: true
- type: input
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Deploy Javadoc 📖'
on:
push:
branches:
- '1.20'
- '1.21'

jobs:
deploy:
Expand All @@ -13,18 +13,16 @@ jobs:
uses: 'actions/checkout@v3'
with:
persist-credentials: false

- name: 'Install Java 🍵'
uses: 'actions/setup-java@v3'
uses: 'actions/setup-java@v4'
with:
distribution: 'temurin'
java-version: '17'

java-version: '21'
- name: 'Install and Build 🔧'
run: './gradlew javadoc'

- name: 'Deploy 🚀'
uses: 'JamesIves/github-pages-deploy-action@v4.4.1'
uses: 'JamesIves/github-pages-deploy-action@15de0f09300eea763baee31dff6c6184995c5f6a'
with:
branch: gh-pages
folder: 'build/docs/javadoc'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: 'Test pull request 📋'
on:
pull_request:
branches:
- '1.20'
- '1.21'

jobs:
test:
if: startsWith(github.repository, 'ModdingX/') # don't run this in forks
runs-on: ubuntu-latest
steps:
- name: 'Checkout 🛎️'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'
with:
persist-credentials: false

- name: 'Install Java 🍵'
uses: 'actions/setup-java@v3'
uses: 'actions/setup-java@v4'
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: 'Run tests 📋'
run: './gradlew test'
99 changes: 56 additions & 43 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
buildscript {
apply from: 'https://moddingx.github.io/ModUtils/v5/buildscript.gradle', to: buildscript
plugins {
id 'org.moddingx.modgradle.meta' version '5.0.0'
id 'org.moddingx.modgradle.javadoc' version '5.0.0'
}

apply from: 'https://moddingx.github.io/ModUtils/v5/mod.gradle'

apply plugin: 'org.moddingx.modgradle.javadoc'
apply plugin: 'org.moddingx.modgradle.coremods'

configurations {
apCompileOnly
apCompileOnlyResolvable.extendsFrom apCompileOnly
Expand All @@ -17,62 +13,90 @@ dependencies {
}

sourceSets {
ap {
compileClasspath = configurations.apCompileOnlyResolvable
ap { compileClasspath = configurations.apCompileOnlyResolvable }
sourcegen { compileClasspath = configurations.compileClasspath }
main { java.srcDirs += [ file('./src/generated/java') ] }
}

mod.configure {
modid 'libx'
group 'org.moddingx'
versioning {
base '6.0'
maven 'https://maven.moddingx.org/release'
}
sourcegen {
compileClasspath = configurations.compileClasspath

neoforge '21.1.97'
extraModSource sourceSets.ap

license 'The Apache License, Version 2.0'
github 'ModdingX/LibX'

runs {
data {
modSource sourceSets.sourcegen
}
}

artifacts {
sources {
publishToRepositories()
uploadToModHostingSites()
}
javadoc {}
}

publishing {
maven {
name 'moddingx'
url 'https://maven.moddingx.org/release'
credentials(PasswordCredentials)
}
}
main {
java.srcDirs += [ file('./src/generated/java') ]

upload {
curseforge {
projectId 412525
}
modrinth {
projectId 'qEH6GYul'
}
}
}

mod.run.sourceSet(sourceSets.ap)

dependencies {
annotationProcessor sourceSets.ap.output
implementation sourceSets.ap.output

coremods 'org.moddingx:CoreModTypes:5.0.2-2'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation 'net.minecraftforge:srgutils:0.4.13'
testImplementation 'com.moandjiezana.toml:toml4j:0.7.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.2'
}

compileJava.options.compilerArgs += [
'-Amod.properties.strict_onlyin=true',
'-Amod.properties.strict_super=true',
'-Amod.properties.force_findbugs=true'
'-Amod.properties.javax_nullity=true'
]

test {
dependsOn createSrgToMcp // Needed, so the tests can load mappings
useJUnitPlatform()
}

jar {
from sourceSets.ap.output
}

sourceJarConfigure {
sourceSets.ap.java.srcDirs.forEach { additionalSourceDir it }
}

javadocConfigure {
from sourceSets.ap.java.sourceDirectories
exclude '**.impl.*?'
exclude '**.annotation.processor.*?'
}

javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
options.destinationDirectory(file("build/docs/javadoc"))
title("LibX ${mod.base_version} JavaDoc")
options.windowTitle("LibX ${mod.base_version} JavaDoc")
options.header('<h3><a href="https://moddingx.github.io/WikiX" target="_blank">Wiki</a>' \
title("LibX ${mod.setup.minecraft} JavaDoc")
options.windowTitle("LibX ${mod.setup.minecraft} JavaDoc")
options.header('<h3><a href="https://moddingx.org/wiki/libx" target="_blank">Wiki</a>' \
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' \
+ '<a href="https://github.com/ModdingX/LibX" target="_blank">GitHub</a></h2>')
options.memberLevel = JavadocMemberLevel.PROTECTED
Expand All @@ -81,21 +105,10 @@ javadoc {
// Performs checks for releases
task release {
finalizedBy compileJava

doFirst {
compileJava.options.compilerArgs += [
'-Amod.properties.release=true'
]
}
}

minecraft {
runs { data {
mods {
"${mod.modid}_sourcegen" {
source sourceSets.sourcegen
}
}
args '--flat', '--mod', "${mod.modid}_sourcegen"
}}
}
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-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
26 changes: 13 additions & 13 deletions mod.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
modid=libx
group=org.moddingx
base_version=5.0
#modid=libx
#group=org.moddingx
#base_version=5.0
# Do not change forge version (keep NeoForge compatibility on this version of minecraft)
forge_version=1.20.1-47.1.3
mappings=sugarcane_2023.07.09-1.20.1
#forge_version=1.20.1-47.1.3
#mappings=sugarcane_2023.07.09-1.20.1

sources=true
#sources=true

local_maven=/var/www/moddingx/maven
changelog_repository=https://github.com/ModdingX/LibX/commit/%H
#local_maven=/var/www/moddingx/maven
#changelog_repository=https://github.com/ModdingX/LibX/commit/%H

license=The Apache License, Version 2.0
license_url=https://www.apache.org/licenses/LICENSE-2.0.txt
#license=The Apache License, Version 2.0
#license_url=https://www.apache.org/licenses/LICENSE-2.0.txt

curse_project=412525
modrinth_project=qEH6GYul
upload_versions=1.20.1
#curse_project=412525
#modrinth_project=qEH6GYul
#upload_versions=1.20.1
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' }
maven { url = 'https://maven.moddingx.org/release' }
}
}

rootProject.name= 'LibX'
15 changes: 7 additions & 8 deletions src/ap/java/org/moddingx/libx/annotation/processor/Classes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ public class Classes {

public static final String MODX = "org.moddingx.libx.mod.ModX";
public static final String MODX_REGISTRATION = "org.moddingx.libx.mod.ModXRegistration";
public static final String MOD = "net.minecraftforge.fml.common.Mod";
public static final String MOD = "net.neoforged.fml.common.Mod";
public static final String FOR_MOD = "org.moddingx.libx.annotation.ForMod";
public static final String DIST = "net.minecraftforge.api.distmarker.Dist";
public static final String ONLY_IN = "net.minecraftforge.api.distmarker.OnlyIn";
public static final String ONLY_INS = "net.minecraftforge.api.distmarker.OnlyIns";
public static final String DIST_EXECUTOR = "net.minecraftforge.fml.DistExecutor";
public static final String DIST = "net.neoforged.api.distmarker.Dist";
public static final String ONLY_IN = "net.neoforged.api.distmarker.OnlyIn";
public static final String ONLY_INS = "net.neoforged.api.distmarker.OnlyIns";

public static final String PROCESSOR_INTERFACE = "org.moddingx.libx.annotation.impl.ProcessorInterface";
public static final String LAZY_MAP_BUILDER = "org.moddingx.libx.annotation.impl.LazyMapBuilder";
Expand All @@ -24,11 +23,11 @@ public class Classes {
public static final String REGISTRY = "net.minecraft.core.Registry";
public static final String REGISTRIES = "net.minecraft.core.registries.Registries";
public static final String RESOURCE_KEY = "net.minecraft.resources.ResourceKey";
public static final String FORGE_KEYS = "net.minecraftforge.registries.ForgeRegistries$Keys";
public static final String NEOFORGE_KEYS = "net.neoforged.neoforge.registries.NeoForgeRegistries$Keys";

public static final String BAKED_MODEL = "net.minecraft.client.resources.model.BakedModel";
public static final String MODEL_REGISTRY_EVENT = "net.minecraftforge.client.event.ModelEvent$RegisterAdditional";
public static final String MODEL_BAKE_EVENT = "net.minecraftforge.client.event.ModelEvent$BakingCompleted";
public static final String MODEL_REGISTRY_EVENT = "net.neoforged.neoforge.client.event.ModelEvent$RegisterAdditional";
public static final String MODEL_BAKE_EVENT = "net.neoforged.neoforge.client.event.ModelEvent$BakingCompleted";
public static final String CODEC = "com.mojang.serialization.Codec";
public static final String MAP_CODEC = "com.mojang.serialization.MapCodec";
public static final String RECORD_CODEC_BUILDER = "com.mojang.serialization.codecs.RecordCodecBuilder";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public interface ProcessorEnv {

SourceVersion TARGET = SourceVersion.RELEASE_17;
SourceVersion TARGET = SourceVersion.RELEASE_21;

Types types();
Elements elements();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.HashSet;
import java.util.Set;

public class FindBugsProcessor extends Processor {
public class NullityProcessor extends Processor {

@Override
public Class<?>[] getTypes() {
Expand All @@ -28,13 +28,13 @@ public Set<String> getSupportedAnnotationTypes() {
@Override
public Set<String> getSupportedOptions() {
Set<String> set = new HashSet<>(super.getSupportedAnnotationTypes());
set.add("mod.properties.force_findbugs");
set.add("mod.properties.javax_nullity");
return set;
}

@Override
public void run(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!this.options().containsKey("mod.properties.force_findbugs") || !Boolean.parseBoolean(this.options().get("mod.properties.force_findbugs"))) return;
if (!this.options().containsKey("mod.properties.javax_nullity") || !Boolean.parseBoolean(this.options().get("mod.properties.javax_nullity"))) return;
for (Element element : roundEnv.getElementsAnnotatedWith(this.typeElement(Classes.JETBRAINS_NOTNULL))) {
this.messager().printMessage(Diagnostic.Kind.ERROR, "This should use javax.annotation.Nonnull.", element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,32 @@ public void write(Filer filer, Messager messager) {
writer.write("((" + Classes.sourceName(Classes.MODX_REGISTRATION) + ")mod).addRegistrationHandler(" + this.modClass.getSimpleName() + "$::register);");
}
if (!this.models.isEmpty()) {
writer.write(Classes.sourceName(Classes.DIST_EXECUTOR) + ".unsafeRunWhenOn(" + Classes.sourceName(Classes.DIST) + ".CLIENT,()->()->{");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".addModListener(" + Classes.sourceName(Classes.MODEL_REGISTRY_EVENT) + ".class," + this.modClass.getSimpleName() + "$::registerModels);");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".addLowModListener(" + Classes.sourceName(Classes.MODEL_BAKE_EVENT) + ".class," + this.modClass.getSimpleName() + "$::bakeModels);");
writer.write("});");
writer.write("if(" + Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".isDistClient()){registerClientOnlyEventListeners();}");
}
writer.write("}");
if (!allReg.isEmpty()) {
writer.write("private static void register(){");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".runUnchecked(()->{");
for (RegistrationEntry entry : allReg) {
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".register(mod," + (entry.registryFqn() == null ? "null" : entry.registryFqn()) + "," + quote(entry.name()) + "," + entry.fieldClassFqn() + "." + entry.fieldName() + ",()->{return " + entry.fieldClassFqn() + ".class.getDeclaredField(" + quote(entry.fieldName()) + ");});");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".register(mod," + (entry.registryFqn() == null ? "null" : entry.registryFqn()) + "," + quote(entry.name()) + "," + entry.fieldClassFqn() + "." + entry.fieldName() + ");");
}
writer.write("});");
writer.write("}");
}
if (!this.models.isEmpty()) {
// Not OnlyIn
writer.write("private static void registerClientOnlyEventListeners(){");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".addModListener(mod," + Classes.sourceName(Classes.MODEL_REGISTRY_EVENT) + ".class," + this.modClass.getSimpleName() + "$::registerModels);");
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".addLowModListener(mod," + Classes.sourceName(Classes.MODEL_BAKE_EVENT) + ".class," + this.modClass.getSimpleName() + "$::bakeModels);");
writer.write("}");

writer.write("@" + Classes.sourceName(Classes.ONLY_IN) + "(" + Classes.sourceName(Classes.DIST) + ".CLIENT)");
writer.write("private static void registerModels(" + Classes.sourceName(Classes.MODEL_REGISTRY_EVENT) + " event){");
for (LoadableModel model : this.models) {
writer.write(Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".addSpecialModel(event," + Classes.sourceName(Classes.PROCESSOR_INTERFACE) + ".newRL(" + quote(model.modelNamespace()) + "," + quote(model.modelPath()) + "));");
}
writer.write("}");

writer.write("@" + Classes.sourceName(Classes.ONLY_IN) + "(" + Classes.sourceName(Classes.DIST) + ".CLIENT)");
writer.write("private static void bakeModels(" + Classes.sourceName(Classes.MODEL_BAKE_EVENT) + " event){");
for (LoadableModel model : this.models) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static TargetRegistry resolveRegistry(Element classElem, RegisterClass c
TypeMirror registryClass = env.classType(classAnnotation::registryClass);
if (registryClass.getKind() == TypeKind.VOID) {
classesToCheck = List.of(
env.typeElement(Classes.FORGE_KEYS),
env.typeElement(Classes.NEOFORGE_KEYS),
env.typeElement(Classes.REGISTRIES)
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* The registry is resolved by taking the value from {@link #registryClass()} and looking for a
* {@code public static final} field with the name from {@link #registry()} that holds a
* {@code ResourceKey<Registry<T>>} that links to the registry to use. If {@link #registryClass()} is not given,
* {@code ForgeRegistries.Keys} and {@code Registries} are searched.
* {@code NeoForgeRegistries.Keys} and {@code Registries} are searched.
*
* To ignore a field add {@link Reg.Exclude @Exclude} to it.
*
Expand Down
Loading

0 comments on commit ff0722f

Please sign in to comment.