Cleanup model stuff and build script

This commit is contained in:
modmuss50 2023-08-09 13:09:43 +01:00
parent a31af2bd7c
commit f9017f2475
4 changed files with 26 additions and 58 deletions

View file

@ -28,8 +28,8 @@
} }
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.21", "fabricloader": ">=0.14.22",
"fabric-api": ">=0.82.1", "fabric-api": ">=0.86.1",
"team_reborn_energy": ">=3.0.0", "team_reborn_energy": ">=3.0.0",
"fabric-biome-api-v1": ">=3.0.0", "fabric-biome-api-v1": ">=3.0.0",
"minecraft": ">=1.20.1- <1.20.2-" "minecraft": ">=1.20.1- <1.20.2-"

View file

@ -1,9 +1,3 @@
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.135'
}
}
plugins { plugins {
id 'java' id 'java'
id 'groovy' id 'groovy'
@ -13,7 +7,7 @@ plugins {
id 'maven-publish' id 'maven-publish'
id 'com.diffplug.spotless' version '6.19.0' id 'com.diffplug.spotless' version '6.19.0'
id 'fabric-loom' version '1.3-SNAPSHOT' id 'fabric-loom' version '1.3-SNAPSHOT'
id 'me.modmuss50.mod-publish-plugin' version '0.0.3' id 'me.modmuss50.mod-publish-plugin' version '0.3.3'
} }
repositories { repositories {
@ -83,7 +77,7 @@ allprojects {
publications { publications {
register("maven", MavenPublication) { register("maven", MavenPublication) {
groupId project.name groupId project.name
artifactId project.archivesBaseName + "-" + getBranch() artifactId project.archivesBaseName + "-" + (ENV.GITHUB_REF_NAME ?: "local")
version project.version version project.version
from components.java from components.java
@ -340,11 +334,11 @@ tasks.register('copyTranslationsToGenerated', Copy) {
} }
publishMods { publishMods {
changelog = ENV.CHANGELOG ?: "No changelog provided" changelog = providers.environmentVariable("CHANGELOG").orElse("No changelog provided")
version = project.version version = project.version
type = ENV.RELEASE_CHANNEL == "release" ? STABLE : BETA type = providers.environmentVariable("RELEASE_CHANNEL").orElse("release").map {it == "release" ? STABLE : BETA }
modLoaders.add("fabric") modLoaders.add("fabric")
dryRun = ENV.CURSEFORGE_API_KEY == null dryRun = providers.environmentVariable("CURSEFORGE_API_KEY").getOrNull() == null
def options = curseforgeOptions { def options = curseforgeOptions {
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY") accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
@ -373,39 +367,12 @@ publishMods {
projectId = "237903" projectId = "237903"
file = project(":RebornCore").tasks.remapJar.archiveFile file = project(":RebornCore").tasks.remapJar.archiveFile
} }
}
static def getBranch() { github {
def ENV = System.getenv() file = remapJar.archiveFile
if (ENV.GITHUB_REF) { additionalFiles.from project(":RebornCore").tasks.remapJar.archiveFile
def branch = ENV.GITHUB_REF repository = providers.environmentVariable("GITHUB_REPOSITORY").orElse("dryrun")
return branch.substring(branch.lastIndexOf("/") + 1) accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryrun")
} }
return "unknown"
} }
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
tasks.register('github') {
dependsOn remapJar
onlyIf {
ENV.GITHUB_TOKEN
}
doLast {
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
def repository = github.getRepository(ENV.GITHUB_REPOSITORY)
def releaseBuilder = new GHReleaseBuilder(repository, version as String)
releaseBuilder.name("${archivesBaseName}-${version}")
releaseBuilder.body(ENV.CHANGELOG)
releaseBuilder.commitish(getBranch())
def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive")
ghRelease.uploadAsset(file("RebornCore/build/libs/RebornCore-${version}.jar"), "application/java-archive")
}
}
github.dependsOn(project(":RebornCore").getTasks().named("remapJar"))

View file

@ -26,7 +26,7 @@ package techreborn;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.model.loading.v1.PreparableModelLoadingPlugin; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess; import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.minecraft.client.item.ClampedModelPredicateProvider; import net.minecraft.client.item.ClampedModelPredicateProvider;
@ -80,7 +80,6 @@ import techreborn.items.tool.industrial.NanosaberItem;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -88,7 +87,7 @@ public class TechRebornClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
PreparableModelLoadingPlugin.register((resourceManager, executor) -> CompletableFuture.completedFuture(null), (data, pluginContext) -> { ModelLoadingPlugin.register((pluginContext) -> {
pluginContext.addModels( pluginContext.addModels(
new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "cell_base"), "inventory"), new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "cell_base"), "inventory"),
new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "cell_fluid"), "inventory"), new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "cell_fluid"), "inventory"),
@ -99,14 +98,16 @@ public class TechRebornClient implements ClientModInitializer {
new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "bucket_background"), "inventory") new ModelIdentifier(new Identifier(TechReborn.MOD_ID, "bucket_background"), "inventory")
); );
pluginContext.modifyModelBeforeBake().register((model, context) -> { pluginContext.resolveModel().register((context) -> {
final Identifier id = context.id(); final Identifier id = context.id();
if (!id.getNamespace().equals(TechReborn.MOD_ID)) { if (!id.getNamespace().equals(TechReborn.MOD_ID) || !id.getPath().startsWith("item/")) {
return model; return null;
} }
if (id.getPath().equals("cell")) { String path = id.getPath().replace("item/", "");
if (path.equals("cell")) {
if (!RendererAccess.INSTANCE.hasRenderer()) { if (!RendererAccess.INSTANCE.hasRenderer()) {
return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"techreborn:item/cell_background\"}}"); return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"techreborn:item/cell_background\"}}");
} }
@ -114,8 +115,8 @@ public class TechRebornClient implements ClientModInitializer {
return new UnbakedDynamicModel(DynamicCellBakedModel::new); return new UnbakedDynamicModel(DynamicCellBakedModel::new);
} }
Fluid fluid = Registries.FLUID.get(new Identifier(TechReborn.MOD_ID, id.getPath().split("_bucket")[0])); Fluid fluid = Registries.FLUID.get(new Identifier(TechReborn.MOD_ID, path.split("_bucket")[0]));
if (id.getPath().endsWith("_bucket") && fluid != Fluids.EMPTY) { if (path.endsWith("_bucket") && fluid != Fluids.EMPTY) {
if (!RendererAccess.INSTANCE.hasRenderer()) { if (!RendererAccess.INSTANCE.hasRenderer()) {
return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"minecraft:item/bucket\"}}"); return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"minecraft:item/bucket\"}}");
} }
@ -123,7 +124,7 @@ public class TechRebornClient implements ClientModInitializer {
return new UnbakedDynamicModel(DynamicBucketBakedModel::new); return new UnbakedDynamicModel(DynamicBucketBakedModel::new);
} }
return model; return null;
}); });
}); });

View file

@ -30,8 +30,8 @@
] ]
}, },
"depends": { "depends": {
"fabricloader": ">=0.14.21", "fabricloader": ">=0.14.22",
"fabric-api": ">=0.82.1", "fabric-api": ">=0.86.1",
"reborncore": "*", "reborncore": "*",
"team_reborn_energy": ">=3.0.0", "team_reborn_energy": ">=3.0.0",
"fabric-biome-api-v1": ">=3.0.0", "fabric-biome-api-v1": ">=3.0.0",