Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2d1856
Initial Split source sets stuff
AlphaMode Sep 11, 2025
c1cbc8f
Actually add client config to FMJ
AlphaMode Sep 11, 2025
15358a5
Fix game test module
AlphaMode Sep 11, 2025
270134a
Remove LogicalSidedProvider
AlphaMode Sep 11, 2025
d78009d
Fix blocks module
AlphaMode Sep 11, 2025
13df65d
Fix client_extensions module
AlphaMode Sep 11, 2025
93fa211
Fix client_events module
AlphaMode Sep 12, 2025
28092f8
Fix common module
AlphaMode Sep 12, 2025
8bf8d3b
Fix config module
AlphaMode Sep 12, 2025
67bae74
Nuke FluidUtil
AlphaMode Sep 12, 2025
5cbaa82
fix gui_utils module
AlphaMode Sep 12, 2025
f090ffb
fix level_events module
AlphaMode Sep 12, 2025
59a85ca
fix item_abilities module
AlphaMode Sep 12, 2025
febc241
fix items module
AlphaMode Sep 12, 2025
a083b07
fix resources module
AlphaMode Sep 12, 2025
4dff74e
fix entity module
AlphaMode Sep 12, 2025
a08d1b6
fix data module
AlphaMode Sep 12, 2025
7567984
fix milk module
AlphaMode Sep 12, 2025
88e7cb3
fix render_types module
AlphaMode Sep 12, 2025
aa4cb3c
fix model_loader module
AlphaMode Sep 12, 2025
3283e69
fix model_data module
AlphaMode Sep 12, 2025
0c755fb
fix transfer module
AlphaMode Sep 12, 2025
969c271
fix models module
AlphaMode Sep 12, 2025
52ab7db
fix recipe_book_categories module
AlphaMode Sep 12, 2025
c546a2c
fix obj_loader module
AlphaMode Sep 12, 2025
b210428
Update tags module
AlphaMode Sep 12, 2025
0835d69
Fix base module
AlphaMode Sep 12, 2025
5e387b7
Fix launch
AlphaMode Sep 12, 2025
d0151c5
Redo tags data gen
AlphaMode Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
46 changes: 32 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ allprojects {
resolutionStrategy.force("net.fabricmc:fabric-loader:$loader_version")
}

processResources {
tasks.withType(ProcessResources).configureEach {
Map<String, ?> properties = [
version: version,
loader_version: loader_version,
Expand All @@ -148,7 +148,7 @@ allprojects {
// property replacement is a bit too eager
class_5124: "\$class_5124",
class_56: "\$class_56",
class_9665: "\$class_9665",
class_9665: "\$class_9665",
class_7226: "\$class_7226",
class_1793: "\$class_1793"
]
Expand All @@ -172,36 +172,56 @@ subprojects {

archivesBaseName = "porting_lib_" + name

// Must be added before the split source sets are setup.
java.withSourcesJar()

loom {
runs.configureEach {
File output = file("src/main/resources/data/porting_lib_$name/structures/gametest")
property("porting_lib.gametest.quickexport.output", output.absolutePath)
}
splitEnvironmentSourceSets()
mods.register("porting_lib_" + name) {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
File aw = file("src/main/resources/porting_lib_${name}.accesswidener")
if (aw.exists())
accessWidenerPath.set(aw)
File commonAW = file("src/main/resources/porting_lib_${name}.accesswidener")
File clientAW = file("src/client/resources/porting_lib_${name}.accesswidener")
if (commonAW.exists() && !clientAW.exists())
accessWidenerPath.set(commonAW)
else if (clientAW.exists() && !commonAW.exists())
accessWidenerPath.set(clientAW)
}

// these two modules are used by all others automatically.
if (name != "core" && name != "gametest") {
portingLib {
addModuleDependency("core") // core depends on gametest
afterEvaluate {
if (name != "core" && name != "gametest") {
portingLib {
addModuleDependency("core") // core depends on gametest
}
}
}

validateModule {
projectName = project.name
readMe.set(rootProject.file("README.md"))
resources.set(project.file("src/main/resources"))
var resourcesDir = project.file("src/main/resources")
if (resourcesDir.exists()) {
resources.set(resourcesDir)
}
var clientResourcesDir = project.file("src/client/resources")
if (clientResourcesDir.exists()) {
clientResources.set(clientResourcesDir)
}
}

sortAccessWidener {
File awFile = project.file("src/main/resources/${project.name}.accesswidener")
if (awFile.exists())
aw.set(awFile)
File commonAWFile = project.file("src/main/resources/${project.name}.accesswidener")
if (commonAWFile.exists())
aw.set(commonAWFile)
File clientAWFile = project.file("src/client/resources/${project.name}.accesswidener")
if (clientAWFile.exists())
aw.set(clientAWFile)
}

processResources {
Expand All @@ -211,8 +231,6 @@ subprojects {
}
}

java.withSourcesJar()

publishing {
repositories {
maven {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Delete;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.jvm.tasks.Jar;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
Expand Down Expand Up @@ -46,6 +48,7 @@ public void addModuleDependencies(List<String> names) {
public void addModuleDependency(String name) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();
SourceSetOutput clientOutput = project.findProject(":" + name).getExtensions().findByType(JavaPluginExtension.class).getSourceSets().getByName("client").getOutput();

Dependency dependency = dependencies.project(Map.of(
"path", ":" + name,
Expand All @@ -60,6 +63,7 @@ public void addModuleDependency(String name) {
}
modules.add("porting_lib_" + name);
dependencies.add("api", dependency);
dependencies.add("clientImplementation", clientOutput);

if (name.equals("mixin_extensions")) {
// special case, also an AP
Expand All @@ -71,6 +75,7 @@ public void addModuleDependency(String name) {
Project depProject = project.project(":" + name);
SourceSetContainer sourceSets = depProject.getExtensions().getByType(SourceSetContainer.class);
settings.sourceSet(sourceSets.getByName("main"), depProject);
settings.sourceSet(sourceSets.getByName("client"), depProject);
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class FmjExpander extends FilterReader {
public static final String RESOURCES = "src/main/resources";
public static final String CLIENT_RESOURCES = "src/client/resources";
public static final String FMJ = "fabric.mod.json";
public static final String TEMPLATE_FMJ = RESOURCES + "/template." + FMJ;

Expand Down Expand Up @@ -93,28 +93,48 @@ public JsonObject expandFmj(JsonObject moduleFmj) {
tryMerge(template, key, value);
}

if (template.get("id").getAsString().endsWith("-datagen")) {
return template;
}

String name = "porting_lib_" + this.projectName;
Path resources = this.projectDirPath.resolve(RESOURCES);
Path clientResources = this.projectDirPath.resolve(CLIENT_RESOURCES);

// fill in mixins
String mixinsFileName = name + ".mixins.json";
Path mixins = resources.resolve(mixinsFileName);
if (Files.exists(mixins)) {
String commonMixinsFileName = name + ".mixins.json";
Path commonMixins = resources.resolve(commonMixinsFileName);
String clientMixinsFileName = name + ".client.mixins.json";
Path clientMixins = clientResources.resolve(clientMixinsFileName);
boolean hasCommon = Files.exists(commonMixins);
boolean hasClient = Files.exists(clientMixins);
if (hasCommon || hasClient) {
JsonArray array = new JsonArray();
array.add(mixinsFileName);
if (hasCommon) {
array.add(commonMixinsFileName);
}
if (hasClient) {
JsonObject clientConfig = new JsonObject();
clientConfig.addProperty("config", clientMixinsFileName);
clientConfig.addProperty("environment", "client");
array.add(clientConfig);
}
template.add("mixins", array);
}

// and AW
String awFileName = name + ".accesswidener";
Path aw = resources.resolve(awFileName);
if (Files.exists(aw)) {
if (Files.exists(resources.resolve(awFileName)) || Files.exists(clientResources.resolve(awFileName))) {
template.addProperty("accessWidener", awFileName);
}

// and modules
String[] modules = this.projectModules.split(",");
JsonObject depends = template.get("depends").getAsJsonObject();
for (String module : modules) {
depends.addProperty(module, "*");
if (!this.projectModules.isEmpty()) {
String[] modules = this.projectModules.split(",");
JsonObject depends = template.get("depends").getAsJsonObject();
for (String module : modules) {
depends.addProperty(module, "*");
}
}

return template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,61 @@ public abstract class ValidateModuleTask extends DefaultTask {
@InputFile
public abstract RegularFileProperty getReadMe();

@Optional
@InputDirectory
public abstract DirectoryProperty getResources();

@Optional
@InputDirectory
public abstract DirectoryProperty getClientResources();

public Path getFMJ(String name, boolean hasCommonResources, boolean hasClientResources) {
if (hasCommonResources && hasClientResources) {
Path resources = this.getResources().get().getAsFile().toPath();
Path clientResources = this.getClientResources().get().getAsFile().toPath();
Path commonFmjPath = resources.resolve("fabric.mod.json");
Path clientFmjPath = clientResources.resolve("fabric.mod.json");
if (Files.exists(commonFmjPath) && !Files.exists(clientFmjPath)) {
return commonFmjPath;
} else if (Files.exists(clientFmjPath) && !Files.exists(commonFmjPath)) {
return clientFmjPath;
} else {
throw new IllegalStateException(name + " does not have a fabric.mod.json or has a duplicate fabric.mod.json");
}
} else {
if (hasCommonResources) {
Path resources = this.getResources().get().getAsFile().toPath();
Path fmjPath = resources.resolve("fabric.mod.json");
if (Files.exists(fmjPath)) {
return fmjPath;
} else {
throw new IllegalStateException(name + " does not have a fabric.mod.json");
}
}
if (hasClientResources) {
Path resources = this.getClientResources().get().getAsFile().toPath();
Path fmjPath = resources.resolve("fabric.mod.json");
if (Files.exists(fmjPath)) {
return fmjPath;
} else {
throw new IllegalStateException(name + " does not have a fabric.mod.json");
}
}
}
throw new IllegalStateException(name + " does not have a fabric.mod.json");
}

@TaskAction
public void validateModule() throws IOException {
String name = this.getProjectName().get();
boolean ignoreName = this.getIgnoreName().getOrElse(Boolean.FALSE);
Path resources = this.getResources().get().getAsFile().toPath();
boolean hasCommonResources = this.getResources().isPresent();
boolean hasClientResources = this.getClientResources().isPresent();

Path readme = this.getReadMe().get().getAsFile().toPath();

Path fmj = resources.resolve("fabric.mod.json");
if (!Files.exists(fmj))
throw new IllegalStateException(name + " does not have a fabric.mod.json");
Path fmj = getFMJ(name, hasCommonResources, hasClientResources);

JsonObject json = Utils.jsonFromPath(fmj);

if (!ignoreName) {
Expand All @@ -55,8 +97,11 @@ public void validateModule() throws IOException {
}

checkDescription(json);
checkAw(name, resources, json);
checkMixins(name, resources, json);
if (hasCommonResources)
checkAw(name, this.getResources().get().getAsFile().toPath(), json);
if (hasClientResources)
checkAw(name, this.getClientResources().get().getAsFile().toPath(), json);
// checkMixins(name, resources, json); TODO: re enable later
checkReadMe(readme, name);
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true
org.gradle.caching=true

loom_version = 1.7.+
loom_version = 1.11.+

mod_version = 3.1.0

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.attributes.mixin.client;
package io.github.fabricators_of_create.porting_lib.attributes.client.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"priority": 951,
"package": "io.github.fabricators_of_create.porting_lib.attributes.client.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"LocalPlayerMixin"
],
"injectors": {
"defaultRequire": 1,
"maxShiftBy": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"common.ServerGamePacketListenerImplMixin",
"common.ServerPlayerMixin"
],
"client": [
"client.LocalPlayerMixin"
],
"injectors": {
"defaultRequire": 1,
"maxShiftBy": 5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib;
package io.github.fabricators_of_create.porting_lib.client;

import io.github.fabricators_of_create.porting_lib.event.common.ModsLoadedCallback;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import com.google.common.collect.ImmutableMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import com.mojang.blaze3d.vertex.PoseStack;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import com.mojang.blaze3d.shaders.FogShape;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.fabricators_of_create.porting_lib.event.client;
package io.github.fabricators_of_create.porting_lib.client.event;

import com.mojang.blaze3d.vertex.PoseStack;

Expand Down
Loading
Loading