Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
64 changes: 45 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@ import groovy.json.JsonParserType
import groovy.json.JsonOutput

plugins {
id "dev.architectury.loom"

id "me.modmuss50.mod-publish-plugin" version "0.7.4"
id 'maven-publish'
}

def unobfuscated = project.name.startsWith("26")
System.out.println("unobfuscated minecraft? " + unobfuscated)
apply plugin: unobfuscated
? 'net.fabricmc.fabric-loom'
: 'net.fabricmc.fabric-loom-remap'
System.out.println(net.fabricmc.loom.LoomGradlePlugin.LOOM_VERSION)

if (unobfuscated) {
configurations {
implementation.extendsFrom(modImplementation)
api.extendsFrom(modApi)
compileOnly.extendsFrom(modCompileOnly)
runtimeOnly.extendsFrom(modRuntimeOnly)
}
}

base.archivesName = project.archives_base_name
version = stonecutter.current.version + "-" + mod_version
group = rootProject.maven_group
Expand All @@ -23,18 +39,22 @@ repositories {
}

}



configurations.configureEach {
resolutionStrategy {
force("net.fabricmc:fabric-loader:${fabric_loader_version}")
}
}

dependencies {
minecraft "com.mojang:minecraft:${stonecutter.current.version}"
mappings loom.officialMojangMappings()
if (!unobfuscated) mappings loom.officialMojangMappings()
if (loader == "fabric") {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
modImplementation("com.terraformersmc:modmenu:${modmenu_version}")
modCompileOnly("com.terraformersmc:modmenu:${modmenu_version}")
modCompileOnly("me.lucko:fabric-permissions-api:${fpapi_version}")

include modApi("teamreborn:energy:${team_reborn_energy_version}") {
Expand Down Expand Up @@ -84,7 +104,7 @@ stonecutter {
}
}

def aw = "${mod_id}-${stonecutter.eval(stonecutter.current.version, ">=1.21.2") ? 1212 : 120}.accesswidener"
def aw = "${mod_id}-${stonecutter.eval(stonecutter.current.version, ">=26.0") ? 261 : stonecutter.eval(stonecutter.current.version, ">=1.21.2") ? 1212 : 120}.accesswidener"

loom {
accessWidenerPath.set(getRootProject().file("src/main/resources/${aw}"))
Expand All @@ -94,22 +114,32 @@ loom {
mixinConfigs("${mod_id}.mixins.json")
}
mixin {
useLegacyMixinAp = true
useLegacyMixinAp = !unobfuscated
defaultRefmapName = "${mod_id}.refmap.json"
}
}

def isJava21 = stonecutter.eval(stonecutter.current.version, ">=1.20.5")
def isJava25 = stonecutter.eval(stonecutter.current.version, ">=26.0") // todo figure out >=26.1 snap 1

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = isJava21 ? 21 : 17
options.release = isJava25 ? 25 : isJava21 ? 21 : 17
}

def buildJar = tasks.create("buildJar", Copy.class) {
into("${rootProject.layout.getBuildDirectory().get()}/libs/$mod_version")
}

tasks.register('renameJarForPublication', Zip) {
dependsOn unobfuscated? jar : remapJar
from (unobfuscated? jar : remapJar).archiveFile.map { zipTree(it) }
archiveExtension = "jar"
metadataCharset "UTF-8"
destinationDirectory = base.libsDirectory
archiveClassifier = loader
}

afterEvaluate {
buildJar.dependsOn(renameJarForPublication)
buildJar.from(renameJarForPublication.archiveFile)
Expand All @@ -118,11 +148,13 @@ afterEvaluate {

java {
withSourcesJar()
sourceCompatibility = isJava21 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
targetCompatibility = isJava21 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
sourceCompatibility = isJava25 ? JavaVersion.VERSION_25 : isJava21 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
targetCompatibility = isJava25 ? JavaVersion.VERSION_25 : isJava21 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
}
remapJar {
if (loader == "neoforge") atAccessWideners.add aw
if (!unobfuscated) {
remapJar {
if (loader == "neoforge") atAccessWideners.add aw
}
}
ext {
releaseChangelog = {
Expand Down Expand Up @@ -208,14 +240,7 @@ processResources {
}
}

tasks.register('renameJarForPublication', Zip) {
dependsOn remapJar
from remapJar.archiveFile.map { zipTree(it) }
archiveExtension = "jar"
metadataCharset "UTF-8"
destinationDirectory = base.libsDirectory
archiveClassifier = loader
}


assemble.dependsOn renameJarForPublication

Expand Down Expand Up @@ -292,7 +317,8 @@ publishMods {

curseforge {
minecraftVersions.addAll versions
if (isJava21) javaVersions.add(JavaVersion.VERSION_21)
if (isJava25) javaVersions.add(JavaVersion.VERSION_25)
else if (isJava21) javaVersions.add(JavaVersion.VERSION_21)
else javaVersions.addAll(JavaVersion.VERSION_17,JavaVersion.VERSION_18)
clientRequired = true
serverRequired = true
Expand Down
Empty file added buildSrc/build.gradle.kts
Empty file.
Empty file.
45 changes: 23 additions & 22 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,31 @@ plugins {

stonecutter {
create(rootProject) {
version("1.20.1-fabric", "1.20.1")
version("1.20.1-forge", "1.20.1")
// version("1.20.1-fabric", "1.20.1")
// version("1.20.1-forge", "1.20.1")
version("1.20.4-fabric", "1.20.4")
version("1.20.4-forge", "1.20.4")
version("1.20.4-neoforge", "1.20.4")
version("1.21.1-fabric", "1.21.1")
version("1.21.1-forge", "1.21.1")
version("1.21.1-neoforge", "1.21.1")
version("1.21.3-fabric", "1.21.3")
version("1.21.3-forge", "1.21.3")
version("1.21.3-neoforge", "1.21.3")
version("1.21.4-fabric", "1.21.4")
version("1.21.4-forge", "1.21.4")
version("1.21.4-neoforge", "1.21.4")
version("1.21.5-fabric", "1.21.5")
version("1.21.5-forge", "1.21.5")
version("1.21.5-neoforge", "1.21.5")
version("1.21.8-fabric", "1.21.8")
version("1.21.8-forge", "1.21.8")
version("1.21.8-neoforge", "1.21.8")
version("1.21.10-fabric", "1.21.10")
version("1.21.10-forge", "1.21.10")
version("1.21.10-neoforge", "1.21.10")
// version("1.20.4-forge", "1.20.4")
// version("1.20.4-neoforge", "1.20.4")
// version("1.21.1-fabric", "1.21.1")
// version("1.21.1-forge", "1.21.1")
// version("1.21.1-neoforge", "1.21.1")
// version("1.21.3-fabric", "1.21.3")
// version("1.21.3-forge", "1.21.3")
// version("1.21.3-neoforge", "1.21.3")
// version("1.21.4-fabric", "1.21.4")
// version("1.21.4-forge", "1.21.4")
// version("1.21.4-neoforge", "1.21.4")
// version("1.21.5-fabric", "1.21.5")
// version("1.21.5-forge", "1.21.5")
// version("1.21.5-neoforge", "1.21.5")
// version("1.21.8-fabric", "1.21.8")
// version("1.21.8-forge", "1.21.8")
// version("1.21.8-neoforge", "1.21.8")
// version("1.21.10-fabric", "1.21.10")
// version("1.21.10-forge", "1.21.10")
// version("1.21.10-neoforge", "1.21.10")
version("1.21.11-fabric", "1.21.11")
version("26.1-fabric", "26.1-snapshot-1")
vcsVersion = "1.20.4-fabric"
}
}
Expand Down
36 changes: 19 additions & 17 deletions src/main/java/wily/factoryapi/FactoryAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.spongepowered.asm.mixin.MixinEnvironment;
import wily.factoryapi.base.config.FactoryCommonOptions;
import wily.factoryapi.base.config.FactoryConfig;
//? if fabric {
Expand Down Expand Up @@ -137,7 +138,8 @@ public FactoryAPI(){
}

public static void init() {
LOGGER.info("Initializing FactoryAPI!");
LOGGER.info("Initializing FactoryAPI and running mixin audit!");
MixinEnvironment.getCurrentEnvironment().audit();
FactoryConfig.registerCommonStorage(createModLocation("common"), FactoryCommonOptions.COMMON_STORAGE);
FactoryEvent.registerPayload(r->{
r.register( false, FactoryAPICommand.UIDefinitionPayload.ID);
Expand All @@ -147,8 +149,8 @@ public static void init() {
r.register( true, CommonConfigSyncPayload.ID_C2S);
r.register(false, OpenExtraMenuPayload.ID);
//? if >=1.21.2 {
/*r.register(false, CommonRecipeManager.ClientPayload.ID);
*///?}
r.register(false, CommonRecipeManager.ClientPayload.ID);
//?}
});
FactoryEvent.preServerTick(s-> SECURE_EXECUTOR.executeAll());
FactoryEvent.registerCommands(((commandSourceStackCommandDispatcher, commandBuildContext, commandSelection) -> FactoryAPICommand.register(commandSourceStackCommandDispatcher,commandBuildContext)));
Expand All @@ -160,44 +162,44 @@ public static void init() {
});
FactoryEvent.PlayerEvent.JOIN_EVENT.register(HelloPayload::sendInitialPayloads);
//? if >=1.21.2 {
/*Consumer<MinecraftServer> updateRecipes = server -> CommonRecipeManager.updateRecipes(server.getRecipeManager());
Consumer<MinecraftServer> updateRecipes = server -> CommonRecipeManager.updateRecipes(server.getRecipeManager());
FactoryEvent.PlayerEvent.RELOAD_RESOURCES_EVENT.register(playerList-> {
updateRecipes.accept(playerList.getServer());
CommonNetwork.sendToPlayers(playerList.getPlayers(), CommonRecipeManager.ClientPayload.getInstance());
});
FactoryEvent.serverStarted(updateRecipes);
*///?}
//?}
FactoryEvent.PlayerEvent.REMOVED_EVENT.register(sp->CommonNetwork.ENABLED_PLAYERS.removeAll(sp.getUUID()));
FactoryEvent.serverStopped(s-> {
SECURE_EXECUTOR.clear();
CommonNetwork.ENABLED_PLAYERS.clear();
//? if >=1.21.2 {
/*CommonRecipeManager.clearRecipes();
*///?}
CommonRecipeManager.clearRecipes();
//?}
currentServer = null;
});
//? if fabric {
FabricStorages.registerDefaultStorages();
//?}
}

public static ResourceLocation createLocation(String namespace, String path){
return ResourceLocation.tryBuild(namespace,path);
public static Identifier createLocation(String namespace, String path){
return Identifier.tryBuild(namespace,path);
}

public static ResourceLocation createLocation(String location){
return ResourceLocation.tryParse(location);
public static Identifier createLocation(String location){
return Identifier.tryParse(location);
}

public static ResourceLocation createModLocation(String path){
public static Identifier createModLocation(String path){
return createLocation(MOD_ID,path);
}

public static ResourceLocation createVanillaLocation(String path){
public static Identifier createVanillaLocation(String path){
//? if <1.20.5 {
return new ResourceLocation(path);
//?} else
//return ResourceLocation.withDefaultNamespace(path);
/*return new Identifier(path);
*///?} else
return Identifier.withDefaultNamespace(path);
}

public static Loader getLoader() {
Expand Down
Loading
Loading