Compare commits

...

10 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 4b831cb6a1
chore: update to 1.20.5
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2024-04-25 22:26:50 +02:00
Johannes Frohnmeyer cada2e99cd
chore: update to 1.20.4
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-12-07 20:28:57 +01:00
Johannes Frohnmeyer e6aab9cd19
chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-22 20:37:51 +02:00
Johannes Frohnmeyer 8409042838
chore: add @reason javadoc to @Overwrite 2023-09-22 20:35:43 +02:00
Johannes Frohnmeyer e83d98fdec
chore: use proper default
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-10 06:52:06 +02:00
Johannes Frohnmeyer 3b91be9864
chore: use jfMod DSL 2023-09-10 06:52:03 +02:00
Johannes Frohnmeyer 02ce4ef490
chore: simplify config 2023-09-10 06:51:59 +02:00
Johannes Frohnmeyer 423049ea7a
Bump to 1.20
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-06-09 18:23:12 +02:00
Johannes Frohnmeyer 3e3f0a394d
Bump to 1.19.4
ci/woodpecker/push/jfmod Pipeline failed Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-03-14 21:18:06 +01:00
Johannes Frohnmeyer b70b3c7d2a
Use new config compiler
ci/woodpecker/push/jfmod Pipeline was successful Details
2022-12-29 16:13:26 +01:00
10 changed files with 114 additions and 111 deletions

View File

@ -1,18 +1,39 @@
import io.gitlab.jfronny.scripts.*
plugins {
id("jfmod") version "1.2-SNAPSHOT"
id("io.gitlab.jfronny.libjf.libjf-config-compiler-plugin")
id("jfmod") version "1.6-SNAPSHOT"
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "quickmath"
jfMod {
minecraftVersion = "1.20.5"
yarn("build.1")
loaderVersion = "0.15.10"
libJfVersion = "3.15.5"
fabricApiVersion = "0.97.6+1.20.5"
modrinth {
projectId = "quickmath"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
curseforge {
projectId = "400837"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
}
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${prop("libjf_version")}")
modImplementation("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${prop("libjf_version")}")
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
modImplementation("io.gitlab.jfronny.libjf:libjf-unsafe-v0")
// Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${prop("libjf_version")}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${prop("libjf_version")}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
modLocalRuntime("com.terraformersmc:modmenu:5.0.0-alpha.4")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil")
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
// for modmenu
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
}

View File

@ -1,17 +0,0 @@
# https://fabricmc.net/develop/
minecraft_version=1.19.3
yarn_mappings=build.2
loader_version=0.14.11
maven_group=io.gitlab.jfronny
archives_base_name=quickmath
modrinth_id=quickmath
modrinth_required_dependencies=libjf
modrinth_optional_dependencies=modmenu
curseforge_id=400837
curseforge_required_dependencies=libjf
curseforge_optional_dependencies=modmenu
fabric_version=0.68.1+1.19.3
libjf_version=3.3.0

View File

@ -1,13 +1,9 @@
pluginManagement {
val libjf_version: String by settings
repositories {
maven("https://maven.fabricmc.net/") // FabricMC
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
gradlePluginPortal()
}
plugins {
id("io.gitlab.jfronny.libjf.libjf-config-compiler-plugin") version libjf_version
}
}
rootProject.name = "quickmath"

View File

@ -35,18 +35,18 @@ public class BytecodeTransformer implements AsmConfig {
rnd("method_43059", "()D"), "random"
);
private static final Map<String, Boolean> stat = Map.of( // Maps QuickMäth MathUtil methods to booleans representing whether to overwrite them
"sin", Cfg.corruptTrigonometry2,
"cos", Cfg.corruptTrigonometry2,
"sinM", Cfg.corruptTrigonometry,
"cosM", Cfg.corruptTrigonometry,
//"sqrt", Cfg.corruptGenericMath,
"sqrtM", Cfg.corruptGenericMath,
//"floor", Cfg.corruptGenericMath2,
// "nextInt", Cfg.corruptGenericMath2,
"nextLong", Cfg.corruptGenericMath2,
"nextBoolean", Cfg.corruptGenericMath2,
// "nextFloat", Cfg.corruptGenericMath2,
"random", Cfg.corruptGenericMath2
"sin", Cfg.corruptTrigonometry.contains(Cfg.CorruptionLevel2.FULL),
"cos", Cfg.corruptTrigonometry.contains(Cfg.CorruptionLevel2.FULL),
"sinM", Cfg.corruptTrigonometry.contains(Cfg.CorruptionLevel2.MAJOR),
"cosM", Cfg.corruptTrigonometry.contains(Cfg.CorruptionLevel2.MAJOR),
//"sqrt", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.MAJOR),
"sqrtM", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.MAJOR),
//"floor", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL),
// "nextInt", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL),
"nextLong", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL),
"nextBoolean", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL),
// "nextFloat", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL),
"random", Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL)
);
private static String mth(String method, String descriptor) {

View File

@ -1,15 +1,45 @@
package io.gitlab.jfronny.quickmath;
import io.gitlab.jfronny.libjf.config.api.v1.Entry;
import io.gitlab.jfronny.libjf.config.api.v1.JfConfig;
import io.gitlab.jfronny.libjf.config.api.v2.Entry;
import io.gitlab.jfronny.libjf.config.api.v2.JfConfig;
import io.gitlab.jfronny.libjf.config.api.v2.dsl.ConfigBuilder;
import io.gitlab.jfronny.libjf.config.api.v2.dsl.Migration;
@JfConfig
@JfConfig(tweaker = Cfg.Migrations.class)
public class Cfg {
@Entry public static boolean corruptGenericMath = true;
@Entry public static boolean corruptGenericMath2 = false;
@Entry public static boolean corruptTrigonometry = true;
@Entry public static boolean corruptTrigonometry2 = true;
@Entry public static CorruptionLevel2 corruptGenericMath = CorruptionLevel2.MAJOR;
@Entry public static CorruptionLevel2 corruptTrigonometry = CorruptionLevel2.FULL;
@Entry public static boolean corruptPerlinNoise = true;
@Entry public static boolean corruptSimplexNoise = true;
@Entry public static boolean debugAsm = false;
static {
JFC_Cfg.ensureInitialized();
}
public enum CorruptionLevel {
DISABLED, MINOR, MAJOR, FULL;
public boolean contains(CorruptionLevel level) {
return compareTo(level) >= 0;
}
}
public enum CorruptionLevel2 {
DISABLED, MAJOR, FULL;
public boolean contains(CorruptionLevel2 level) {
return compareTo(level) >= 0;
}
}
public static class Migrations {
public static ConfigBuilder<?> tweak(ConfigBuilder<?> builder) {
return builder.addMigration("corruptGenericMath2", Migration.of(reader -> {
if (reader.nextBoolean()) corruptGenericMath = CorruptionLevel2.FULL;
})).addMigration("corruptTrigonometry2", Migration.of(reader -> {
if (!reader.nextBoolean()) corruptTrigonometry = CorruptionLevel2.MAJOR;
}));
}
}
}

View File

@ -1,15 +1,14 @@
package io.gitlab.jfronny.quickmath;
import io.gitlab.jfronny.quickmath.mixin.*;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class MixinPlugin implements IMixinConfigPlugin {
private static final String PREFIX = "io.gitlab.jfronny.quickmath.mixin.";
@Override
public void onLoad(String mixinPackage) {
@ -20,19 +19,17 @@ public class MixinPlugin implements IMixinConfigPlugin {
return null;
}
@SuppressWarnings("ReferenceToMixin")
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (Objects.equals(mixinClassName, MathHelperMixin.class.getName()))
return Cfg.corruptGenericMath;
else if (Objects.equals(mixinClassName, MathHelperMixin2.class.getName()))
return Cfg.corruptGenericMath2;
else if (Objects.equals(mixinClassName, MixinPerlinNoiseSampler.class.getName()))
return Cfg.corruptPerlinNoise;
else if (Objects.equals(mixinClassName, MixinSimplexNoiseSampler.class.getName()))
return Cfg.corruptSimplexNoise;
else
throw new IllegalStateException("Unrecognized mixin! This should never happen");
if (!mixinClassName.startsWith(PREFIX))
throw new IllegalStateException("Unrecognized mixin! This should never happen: " + mixinClassName);
return switch (mixinClassName.substring(PREFIX.length())) {
case "MathHelperMixin" -> Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.MAJOR);
case "MathHelperMixin2" -> Cfg.corruptGenericMath.contains(Cfg.CorruptionLevel2.FULL);
case "MixinPerlinNoiseSampler" -> Cfg.corruptPerlinNoise;
case "MixinSimplexNoiseSampler" -> Cfg.corruptSimplexNoise;
default -> throw new IllegalStateException("Unrecognized mixin! This should never happen: " + mixinClassName);
};
}
@Override

View File

@ -1,10 +1,10 @@
package io.gitlab.jfronny.quickmath;
import io.gitlab.jfronny.commons.log.*;
import io.gitlab.jfronny.commons.logger.SystemLoggerPlus;
import net.fabricmc.api.*;
public class ModMain implements ModInitializer {
public static final Logger LOGGER = Logger.forName("quickmäth");
public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName("quickmäth");
@Override
public void onInitialize() {
LOGGER.info("QuickMäth initialized, but why are you using this?");

View File

@ -1,15 +1,9 @@
package io.gitlab.jfronny.quickmath.mixin;
import io.gitlab.jfronny.quickmath.MathUtil;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.*;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(MathHelper.class)
@ -18,16 +12,19 @@ public abstract class MathHelperMixin {
@Shadow public static int floor(double value) { return 0; }
@Shadow public static double nextDouble(Random random, double min, double max) { return 0; }
@Overwrite
public static int fastFloor(double d) {
return (int)(d / 32) * 32;
}
/**
* @author JFronny
* @reason Reduce precision
*/
@Overwrite
public static long lfloor(double d) {
return (long) (Math.floor(d / 4) * 4);
}
/**
* @author JFronny
* @reason Introduce variation
*/
@Overwrite
public static double absMax(double d, double e) {
if (d > 0.0D) {
@ -62,29 +59,4 @@ public abstract class MathHelperMixin {
private static void adjustRandomDouble(CallbackInfoReturnable<Double> ci) {
ci.setReturnValue((double) floor(ci.getReturnValue()));
}
@Overwrite
public static double average(long[] array) {
long[] var3 = array;
long min = Long.MAX_VALUE;
long max = Long.MIN_VALUE;
int var4 = array.length;
for(int var5 = 0; var5 < var4; ++var5) {
long m = var3[var5];
if (m > max)
max = m;
if (m < min)
min = m;
}
return nextDouble(RANDOM, min, max);
}
@Overwrite
public static long clamp(long value, long min, long max) {
return MathUtil.boxedInvert(Math.max(Math.min(value, max), min), max, min);
}
}

View File

@ -1,17 +1,21 @@
{
"quickmath.jfconfig.title": "QuickMäth - Restart to apply changes",
"quickmath.jfconfig.title": "QuickMäth",
"quickmath.jfconfig.tooltip": "Restart to apply changes",
"quickmath.jfconfig.corruptGenericMath": "Corrupt generic math",
"quickmath.jfconfig.corruptGenericMath.tooltip": "Corrupts methods in MathHelper. This will impact many things but most notably movement",
"quickmath.jfconfig.corruptGenericMath2": "Corrupt more generic math",
"quickmath.jfconfig.corruptGenericMath2.tooltip": "Corrupts more methods in MathHelper. These WILL break a lot of things so they are separate",
"quickmath.jfconfig.corruptTrigonometry": "Corrupt Trigonometry",
"quickmath.jfconfig.corruptTrigonometry.tooltip": "Corrupts trigonometry methods. Effects vary",
"quickmath.jfconfig.corruptTrigonometry2": "Corrupt more Trigonometry",
"quickmath.jfconfig.corruptTrigonometry2.tooltip": "Corrupts all trigonometry methods. This WILL break a lot of things",
"quickmath.jfconfig.corruptPerlinNoise": "Corrupt perlin noise",
"quickmath.jfconfig.corruptPerlinNoise.tooltip": "Corrupts methods in OctavePerlinNoiseSampler and PerlinNoiseSampler. This will mostly impact world generation",
"quickmath.jfconfig.corruptSimplexNoise": "Corrupt simplex noise",
"quickmath.jfconfig.corruptSimplexNoise.tooltip": "Corrupts methods in SimplexNoiseSampler. I am actually not sure what this breaks",
"quickmath.jfconfig.debugAsm": "Debug ASM",
"quickmath.jfconfig.debugAsm.tooltip": "Prints debug messages for the purpose of debugging"
"quickmath.jfconfig.debugAsm.tooltip": "Prints debug messages for the purpose of debugging",
"quickmath.jfconfig.enum.CorruptionLevel2.DISABLED": "Disabled",
"quickmath.jfconfig.enum.CorruptionLevel2.MAJOR": "Major",
"quickmath.jfconfig.enum.CorruptionLevel2.FULL": "Full",
"quickmath.jfconfig.enum.CorruptionLevel.DISABLED": "Disabled",
"quickmath.jfconfig.enum.CorruptionLevel.MINOR": "Minor",
"quickmath.jfconfig.enum.CorruptionLevel.MAJOR": "Major",
"quickmath.jfconfig.enum.CorruptionLevel.FULL": "Full"
}

View File

@ -18,7 +18,7 @@
"icon": "assets/quickmath/icon.png",
"environment": "*",
"entrypoints": {
"libjf:config": ["io.gitlab.jfronny.quickmath.Cfg"],
"libjf:config": ["io.gitlab.jfronny.quickmath.JFC_Cfg"],
"libjf:asm": ["io.gitlab.jfronny.quickmath.BytecodeTransformer"],
"main": ["io.gitlab.jfronny.quickmath.ModMain"]
},