Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Johannes Frohnmeyer | 4b831cb6a1 | |
Johannes Frohnmeyer | cada2e99cd | |
Johannes Frohnmeyer | e6aab9cd19 | |
Johannes Frohnmeyer | 8409042838 | |
Johannes Frohnmeyer | e83d98fdec | |
Johannes Frohnmeyer | 3b91be9864 | |
Johannes Frohnmeyer | 02ce4ef490 | |
Johannes Frohnmeyer | 423049ea7a |
|
@ -1,16 +1,39 @@
|
|||
import io.gitlab.jfronny.scripts.*
|
||||
|
||||
plugins {
|
||||
id("jfmod") version "1.3-SNAPSHOT"
|
||||
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-ui-tiny-v1:${prop("libjf_version")}")
|
||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${prop("libjf_version")}")
|
||||
modLocalRuntime("com.terraformersmc:modmenu:6.1.0-rc.1")
|
||||
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")
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.19.4
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.14.17
|
||||
|
||||
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.75.3+1.19.4
|
||||
libjf_version=3.6.0
|
|
@ -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) {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
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;
|
||||
|
@ -16,4 +16,30 @@ public class Cfg {
|
|||
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;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?");
|
||||
|
|
|
@ -12,11 +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; }
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
|
|
|
@ -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"
|
||||
}
|
Loading…
Reference in New Issue