This commit is contained in:
JFronny 2021-06-02 13:31:04 +02:00
parent 3127075ab6
commit 26ca20346c
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
13 changed files with 58 additions and 150 deletions

View File

@ -1,102 +1,27 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'maven-publish'
id "com.modrinth.minotaur" version "1.1.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
}
apply from: "https://gitlab.com/-/snippets/2121059/raw/master/jfbase.gradle"
repositories {
maven {
name = 'TerraformersMC'
url = 'https://maven.terraformersmc.com/'
}
maven { url 'https://jitpack.io' }
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
//Fabric API
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
include modApi("me.sargunvohra.mcmods:autoconfig1u:3.2.2") {
exclude(group: "net.fabricmc.fabric-api")
}
download("https://gitlab.com/jfmods/LibJF/-/jobs/artifacts/master/raw/latest-dev.jar?job=build_test", "libjf")
modImplementation "com.terraformersmc:modmenu:2.+"
include modImplementation ('com.gitlab.jfmods:LibWeb:-SNAPSHOT') {
exclude(group: "net.fabricmc.fabric-api")
}
}
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
jar {
from "LICENSE"
}
import com.modrinth.minotaur.TaskModrinthUpload
task publishModrinth (type: TaskModrinthUpload){
token = System.getenv("MODRINTH_API_TOKEN") // Use an environment property!
projectId = 'v3lfX2LD'
versionNumber = "${project.mod_version}"
uploadFile = remapJar // This is the java jar task
addGameVersion("${project.minecraft_version}")
addLoader('fabric')
versionName = "[${project.minecraft_version}] ${project.mod_version}"
afterEvaluate {
tasks.publishModrinth.dependsOn(remapJar)
tasks.publishModrinth.dependsOn(sourcesJar)
}
}
curseforge {
apiKey = System.getenv("CURSEFORGE_API_TOKEN") == null ? "###" : System.getenv("CURSEFORGE_API_TOKEN")
project {
id = "407012"
releaseType = 'release'
addGameVersion "Fabric"
addGameVersion "${project.minecraft_version}"
changelog = ""
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
mainArtifact.displayName = "[${project.minecraft_version}] ${project.mod_version}"
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
options {
forgeGradleIntegration = false
}
}

View File

@ -2,12 +2,19 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.3
loader_version=0.11.1
minecraft_version=1.17-pre3
yarn_mappings=build.1
loader_version=0.11.3
# Mod Properties
mod_version=1.1.1
mod_version=1.1.2
maven_group=io.gitlab.jfronny
archives_base_name=dynres
#Dependencies
fabric_version=0.29.4+1.16
fabric_version=0.34.8+1.17
modrinth_id=v3lfX2LD
modrinth_required_dependencies=TUqoYNVF
modrinth_optional_dependencies=EDbIonje
curseforge_id=407012
curseforge_required_dependencies=libjf
curseforge_optional_dependencies=modmenu

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

21
gradlew.bat vendored
View File

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View File

@ -1,10 +0,0 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@ -1,14 +1,11 @@
package io.gitlab.jfronny.dynres;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
import io.gitlab.jfronny.libjf.config.Entry;
import io.gitlab.jfronny.libjf.config.JfConfig;
@Config(name = "dynres")
public class Cfg implements ConfigData {
@Comment("The relative path to the resources zip. Expect strange behaviour if changed")
public String resourcesFile = "resources.zip";
@Comment("Set to true to provide a hash to clients. Changes to the pack will require a server restart with this")
public boolean hashResources = false;
public class Cfg implements JfConfig {
@Entry
public static String resourcesFile = "resources.zip";
@Entry
public static boolean hashResources = false;
}

View File

@ -1,9 +1,8 @@
package io.gitlab.jfronny.dynres;
import io.gitlab.jfronny.libjf.Libjf;
import io.gitlab.jfronny.libweb.api.LibWebAPI;
import io.gitlab.jfronny.libweb.api.LibWebInit;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.gui.FabricGuiEntry;
@ -14,13 +13,11 @@ import java.io.IOException;
public class DynRes implements LibWebInit {
public static File resFile;
public static Cfg cfg;
public static String resourceLink = "";
static {
AutoConfig.register(Cfg.class, JanksonConfigSerializer::new);
cfg = AutoConfig.getConfigHolder(Cfg.class).getConfig();
resFile = new File(FabricLoader.getInstance().getGameDir().toFile(), cfg.resourcesFile);
Libjf.registerConfig("dynres", Cfg.class);
resFile = new File(FabricLoader.getInstance().getGameDir().toFile(), Cfg.resourcesFile);
if (!resFile.isFile()) {
FabricGuiEntry.displayCriticalError(new FileNotFoundException("The file " + resFile + " does not exist in the game directory but is required"), true);
}
@ -30,7 +27,7 @@ public class DynRes implements LibWebInit {
public void register(LibWebAPI api) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
try {
resourceLink = api.registerFile("/resources.zip", resFile.toPath(), !cfg.hashResources);
resourceLink = api.registerFile("/resources.zip", resFile.toPath(), !Cfg.hashResources);
Logger.l.info("Initialized DynRes at " + resourceLink);
} catch (IOException e) {
e.printStackTrace();

View File

@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerInfo.class)
public class ServerInfoMixin {
@Inject(at = @At("RETURN"), method = "getResourcePack()Lnet/minecraft/client/network/ServerInfo$ResourcePackState;")
public void getResPackState(CallbackInfoReturnable<ServerInfo.ResourcePackState> info) {
public void getResPackState(CallbackInfoReturnable<ServerInfo.ResourcePackPolicy> info) {
Logger.l.info("[RECEIVE] ResourcePackStatus=" + info.getReturnValue());
}
}

View File

@ -1,14 +1,18 @@
package io.gitlab.jfronny.dynres.mixin;
import io.gitlab.jfronny.dynres.Cfg;
import io.gitlab.jfronny.dynres.DynRes;
import io.gitlab.jfronny.dynres.Logger;
import io.gitlab.jfronny.dynres.ServerPropertiesHandlerExt;
import io.gitlab.jfronny.libjf.Libjf;
import io.gitlab.jfronny.libweb.extra.LibWeb;
import io.gitlab.jfronny.libweb.extra.WebPaths;
import net.minecraft.server.dedicated.ServerPropertiesHandler;
import net.minecraft.util.registry.DynamicRegistryManager;
import org.apache.commons.codec.digest.DigestUtils;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -20,11 +24,9 @@ import java.util.Properties;
@Mixin(ServerPropertiesHandler.class)
public class ServerPropertiesHandlerMixin implements ServerPropertiesHandlerExt {
@Shadow public String resourcePack;
@Shadow public String resourcePackHash;
@Shadow public String resourcePackSha1;
@Mutable @Final @Shadow public String resourcePackHash;
@Mutable @Final @Shadow public String resourcePackSha1;
@Mutable @Final @Shadow public String resourcePack;
@Inject(at = @At("RETURN"), method = "<init>(Ljava/util/Properties;Lnet/minecraft/util/registry/DynamicRegistryManager;)V")
public void init(Properties properties, DynamicRegistryManager dynamicRegistryManager, CallbackInfo info) {
@ -37,7 +39,8 @@ public class ServerPropertiesHandlerMixin implements ServerPropertiesHandlerExt
if (print)
Logger.l.info("Pack link: " + resourcePack);
resourcePackSha1 = "";
if (DynRes.cfg.hashResources) {
Libjf.registerConfig("dynres", Cfg.class);
if (Cfg.hashResources) {
try {
FileInputStream fs = new FileInputStream(DynRes.resFile);
resourcePackSha1 = DigestUtils.sha1Hex(fs);

View File

@ -0,0 +1,7 @@
{
"dynres.jfconfig.title": "DynRes",
"dynres.jfconfig.resourcesFile": "Corrupt generic math",
"dynres.jfconfig.resourcesFile.tooltip": "The relative path to the resources zip. Expect strange behaviour if changed",
"dynres.jfconfig.hashResources": "Corrupt more generic math",
"dynres.jfconfig.hashResources.tooltip": "Set to true to provide a hash to clients. Changes to the pack will require a server restart with this"
}

View File

@ -15,12 +15,9 @@
"icon": "assets/dynres/icon.png",
"environment": "*",
"entrypoints": {
"libweb": [
"io.gitlab.jfronny.dynres.DynRes"
],
"client": [
"io.gitlab.jfronny.dynres.DebugClient"
]
"libweb": ["io.gitlab.jfronny.dynres.DynRes"],
"client": ["io.gitlab.jfronny.dynres.DebugClient"],
"libjf:config": ["io.gitlab.jfronny.dynres.Cfg"]
},
"mixins": [
"dynres.mixins.json"