Use libjf

This commit is contained in:
JFronny 2021-05-19 15:12:49 +02:00
parent 64cdc96032
commit 2c882709c0
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
16 changed files with 64 additions and 200 deletions

View File

@ -1,19 +1,10 @@
plugins { apply from: "https://gitlab.com/-/snippets/2121059/raw/master/jfbase.gradle"
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"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories { repositories {
maven { url = 'https://maven.terraformersmc.com/'; name = "ModMenu" } maven {
name = 'TerraformersMC'
url = 'https://maven.terraformersmc.com/'
}
} }
dependencies { dependencies {
@ -22,86 +13,9 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. download("https://gitlab.com/jfmods/LibJF/-/jobs/artifacts/master/raw/latest-dev.jar?job=build_test", "libjf")
// You may need to force-disable transitiveness on them.
modCompile "me.sargunvohra.mcmods:autoconfig1u:3.3.1"
include "me.sargunvohra.mcmods:autoconfig1u:3.3.1"
modApi ("me.shedaniel.cloth:config-2:4.8.3") {
exclude(group: "net.fabricmc.fabric-api")
}
include ("me.shedaniel.cloth:config-2:4.8.3") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation "com.terraformersmc:modmenu:1.14.15" modImplementation "com.terraformersmc:modmenu:1.16.9"
} }
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 = 'hRVfXPJj'
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 = "400837"
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

@ -3,12 +3,18 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5 minecraft_version=1.16.5
yarn_mappings=1.16.5+build.3 yarn_mappings=1.16.5+build.9
loader_version=0.11.1 loader_version=0.11.3
# Mod Properties # Mod Properties
mod_version=1.1.1 mod_version=1.2.0
maven_group=io.jfronny.gitlab maven_group=io.jfronny.gitlab
archives_base_name=quickmeth archives_base_name=quickmeth
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html fabric_version=0.34.2+1.16
fabric_version=0.29.4+1.16
modrinth_id=hRVfXPJj
modrinth_required_dependencies=TUqoYNVF
modrinth_optional_dependencies=Gz5wa6j2
curseforge_id=400837
curseforge_required_dependencies=libjf
curseforge_optional_dependencies=modmenu

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # 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 set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 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_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @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 :end
@rem End local scope for the variables with windows NT shell @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,20 +1,14 @@
package io.gitlab.jfronny.quickmeth; package io.gitlab.jfronny.quickmeth;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData; import io.gitlab.jfronny.libjf.config.Entry;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; import io.gitlab.jfronny.libjf.config.JfConfig;
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry.Gui.RequiresRestart;
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
@Config(name = "quickmeth") public class Cfg implements JfConfig {
public class Cfg implements ConfigData { @Entry
@Comment("Corrupts methods in MathHelper. This will impact many things but most notably movement") public static boolean corruptGenericMath = true;
@RequiresRestart @Entry
public boolean corruptGenericMath = true; public static boolean corruptPerlinNoise = true;
@Comment("Corrupts methods in OctavePerlinNoiseSampler and PerlinNoiseSampler. This will mostly impact world generation") @Entry
@RequiresRestart public static boolean corruptSimplexNoise = true;
public boolean corruptPerlinNoise = true;
@Comment("Corrupts methods in SimplexNoiseSampler. I am actually not sure what this breaks")
@RequiresRestart
public boolean corruptSimplexNoise = true;
} }

View File

@ -1,22 +1,8 @@
package io.gitlab.jfronny.quickmeth; package io.gitlab.jfronny.quickmeth;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class quickmeth implements ModInitializer { public class MathUtil {
public static Cfg cfg;
static {
AutoConfig.register(Cfg.class, JanksonConfigSerializer::new);
cfg = AutoConfig.getConfigHolder(Cfg.class).getConfig();
}
@Override
public void onInitialize() {
}
public static double BoxedInvert(double min, double max, double value) { public static double BoxedInvert(double min, double max, double value) {
return max - value + min; return max - value + min;
} }

View File

@ -1,5 +1,6 @@
package io.gitlab.jfronny.quickmeth; package io.gitlab.jfronny.quickmeth;
import io.gitlab.jfronny.libjf.Libjf;
import io.gitlab.jfronny.quickmeth.mixin.MathHelperMixin; import io.gitlab.jfronny.quickmeth.mixin.MathHelperMixin;
import io.gitlab.jfronny.quickmeth.mixin.MixinOctavePerlinNoiseSampler; import io.gitlab.jfronny.quickmeth.mixin.MixinOctavePerlinNoiseSampler;
import io.gitlab.jfronny.quickmeth.mixin.MixinPerlinNoiseSampler; import io.gitlab.jfronny.quickmeth.mixin.MixinPerlinNoiseSampler;
@ -26,14 +27,15 @@ public class MixinPlugin implements IMixinConfigPlugin {
@SuppressWarnings("ReferenceToMixin") @SuppressWarnings("ReferenceToMixin")
@Override @Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
Libjf.registerConfig("quickmeth", Cfg.class);
if (Objects.equals(mixinClassName, MathHelperMixin.class.getName())) if (Objects.equals(mixinClassName, MathHelperMixin.class.getName()))
return quickmeth.cfg.corruptGenericMath; return Cfg.corruptGenericMath;
else if (Objects.equals(mixinClassName, MixinOctavePerlinNoiseSampler.class.getName())) else if (Objects.equals(mixinClassName, MixinOctavePerlinNoiseSampler.class.getName()))
return quickmeth.cfg.corruptPerlinNoise; return Cfg.corruptPerlinNoise;
else if (Objects.equals(mixinClassName, MixinPerlinNoiseSampler.class.getName())) else if (Objects.equals(mixinClassName, MixinPerlinNoiseSampler.class.getName()))
return quickmeth.cfg.corruptPerlinNoise; return Cfg.corruptPerlinNoise;
else if (Objects.equals(mixinClassName, MixinSimplexNoiseSampler.class.getName())) else if (Objects.equals(mixinClassName, MixinSimplexNoiseSampler.class.getName()))
return quickmeth.cfg.corruptSimplexNoise; return Cfg.corruptSimplexNoise;
else else
throw new IllegalStateException("Unrecognized mixin! This should never happen"); throw new IllegalStateException("Unrecognized mixin! This should never happen");
} }

View File

@ -1,12 +0,0 @@
package io.gitlab.jfronny.quickmeth;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
public class ModMenu implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return screen -> AutoConfig.getConfigScreen(Cfg.class, screen).get();
}
}

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.quickmeth.mixin; package io.gitlab.jfronny.quickmeth.mixin;
import io.gitlab.jfronny.quickmeth.quickmeth; import io.gitlab.jfronny.quickmeth.MathUtil;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.util.Util; import net.minecraft.util.Util;
@ -29,7 +29,7 @@ public class MathHelperMixin {
@Overwrite @Overwrite
public static float sin(float f) { public static float sin(float f) {
return quickmeth.BoxedInvert(SINE_TABLE[(int)(f * 10430.378F) & '\uffff']); return MathUtil.BoxedInvert(SINE_TABLE[(int)(f * 10430.378F) & '\uffff']);
} }
//@Overwrite //@Overwrite

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.quickmeth.mixin; package io.gitlab.jfronny.quickmeth.mixin;
import io.gitlab.jfronny.quickmeth.quickmeth; import io.gitlab.jfronny.quickmeth.MathUtil;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.noise.PerlinNoiseSampler; import net.minecraft.util.math.noise.PerlinNoiseSampler;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@ -19,9 +19,9 @@ public class MixinPerlinNoiseSampler {
@Overwrite @Overwrite
public double sample(double x, double y, double z, double d, double e) { public double sample(double x, double y, double z, double d, double e) {
x = quickmeth.BoxedInvert(x); x = MathUtil.BoxedInvert(x);
y = quickmeth.BoxedInvert(y); y = MathUtil.BoxedInvert(y);
z = quickmeth.BoxedInvert(z); z = MathUtil.BoxedInvert(z);
double f = x + this.originX; double f = x + this.originX;
double g = y + this.originY; double g = y + this.originY;
@ -43,6 +43,6 @@ public class MixinPerlinNoiseSampler {
t = 0.0D; t = 0.0D;
} }
return quickmeth.BoxedInvert(((PerlinNoiseSampler)(Object)this).sample(i, j, k, l, m - t, n, o, p, q)); return MathUtil.BoxedInvert(((PerlinNoiseSampler)(Object)this).sample(i, j, k, l, m - t, n, o, p, q));
} }
} }

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.quickmeth.mixin; package io.gitlab.jfronny.quickmeth.mixin;
import io.gitlab.jfronny.quickmeth.quickmeth; import io.gitlab.jfronny.quickmeth.MathUtil;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.noise.SimplexNoiseSampler; import net.minecraft.util.math.noise.SimplexNoiseSampler;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@ -20,8 +20,8 @@ public class MixinSimplexNoiseSampler {
private int[] permutations; private int[] permutations;
@Overwrite @Overwrite
public double sample(double x, double y) { public double sample(double x, double y) {
x = quickmeth.BoxedInvert(x); x = MathUtil.BoxedInvert(x);
y = quickmeth.BoxedInvert(y); y = MathUtil.BoxedInvert(y);
double d = (x + y) * SKEW_FACTOR_2D; double d = (x + y) * SKEW_FACTOR_2D;
int i = MathHelper.floor(x + d); int i = MathHelper.floor(x + d);
int j = MathHelper.floor(y + d); int j = MathHelper.floor(y + d);
@ -52,7 +52,7 @@ public class MixinSimplexNoiseSampler {
double aa = mgrad(v, h, k, 0.0D, 0.5D); double aa = mgrad(v, h, k, 0.0D, 0.5D);
double ab = mgrad(w, p, q, 0.0D, 0.5D); double ab = mgrad(w, p, q, 0.0D, 0.5D);
double ac = mgrad(z, r, s, 0.0D, 0.5D); double ac = mgrad(z, r, s, 0.0D, 0.5D);
return quickmeth.BoxedInvert(70.0D * (aa + ab + ac)); return MathUtil.BoxedInvert(70.0D * (aa + ab + ac));
} }
@Overwrite @Overwrite
@ -61,10 +61,10 @@ public class MixinSimplexNoiseSampler {
} }
private static double mgrad(int hash, double x, double y, double z, double d) { private static double mgrad(int hash, double x, double y, double z, double d) {
x = quickmeth.BoxedInvert(x); x = MathUtil.BoxedInvert(x);
y = quickmeth.BoxedInvert(y); y = MathUtil.BoxedInvert(y);
z = quickmeth.BoxedInvert(z); z = MathUtil.BoxedInvert(z);
d = quickmeth.BoxedInvert(d); d = MathUtil.BoxedInvert(d);
double e = d - x * x - y * y - z * z; double e = d - x * x - y * y - z * z;
double g; double g;
@ -79,6 +79,6 @@ public class MixinSimplexNoiseSampler {
} }
private static double mdot(int[] gArr, double x, double y, double z) { private static double mdot(int[] gArr, double x, double y, double z) {
return quickmeth.BoxedInvert((double)gArr[0] * x + (double)gArr[1] * y + (double)gArr[2] * z); return MathUtil.BoxedInvert((double)gArr[0] * x + (double)gArr[1] * y + (double)gArr[2] * z);
} }
} }

View File

@ -1,6 +1,9 @@
{ {
"text.autoconfig.quickmeth.title": "QuickMäth", "quickmeth.jfconfig.title": "QuickMäth",
"text.autoconfig.quickmeth.option.corruptGenericMath": "Corrupt generic math", "quickmeth.jfconfig.corruptGenericMath": "Corrupt generic math",
"text.autoconfig.quickmeth.option.corruptPerlinNoise": "Corrupt perlin noise", "quickmeth.jfconfig.corruptGenericMath.tooltip": "Corrupts methods in MathHelper. This will impact many things but most notably movement",
"text.autoconfig.quickmeth.option.corruptSimplexNoise": "Corrupt simplex noise" "quickmeth.jfconfig.corruptPerlinNoise": "Corrupt perlin noise",
"quickmeth.jfconfig.corruptPerlinNoise.tooltip": "Corrupts methods in OctavePerlinNoiseSampler and PerlinNoiseSampler. This will mostly impact world generation",
"quickmeth.jfconfig.corruptSimplexNoise": "Corrupt simplex noise",
"quickmeth.jfconfig.corruptSimplexNoise.tooltip": "Corrupts methods in SimplexNoiseSampler. I am actually not sure what this breaks"
} }

View File

@ -15,13 +15,9 @@
"icon": "assets/quickmeth/icon.png", "icon": "assets/quickmeth/icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "libjf:config": [
"io.gitlab.jfronny.quickmeth.quickmeth" "io.gitlab.jfronny.quickmeth.Cfg"
],
"modmenu": [
"io.gitlab.jfronny.quickmeth.ModMenu"
] ]
}, },
"mixins": [ "mixins": [
"quickmeth.mixins.json" "quickmeth.mixins.json"