1.17
This commit is contained in:
parent
e4d9c6a12e
commit
6039388b61
@ -17,5 +17,5 @@ dependencies {
|
|||||||
|
|
||||||
download("https://gitlab.com/jfmods/LibJF/-/jobs/artifacts/master/raw/latest-dev.jar?job=build_test", "libjf")
|
download("https://gitlab.com/jfmods/LibJF/-/jobs/artifacts/master/raw/latest-dev.jar?job=build_test", "libjf")
|
||||||
|
|
||||||
modImplementation "com.terraformersmc:modmenu:1.16.9"
|
modImplementation "com.terraformersmc:modmenu:2.0.0-beta.5"
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
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.17-pre1
|
||||||
yarn_mappings=1.16.5+build.9
|
yarn_mappings=1.17-pre1+build.6
|
||||||
loader_version=0.11.3
|
loader_version=0.11.3
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.2.0
|
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
|
||||||
fabric_version=0.34.2+1.16
|
fabric_version=0.34.8+1.17
|
||||||
|
|
||||||
modrinth_id=hRVfXPJj
|
modrinth_id=hRVfXPJj
|
||||||
modrinth_required_dependencies=7a9qcRLy
|
modrinth_required_dependencies=7a9qcRLy
|
||||||
modrinth_optional_dependencies=Gz5wa6j2
|
modrinth_optional_dependencies=EDbIonje
|
||||||
curseforge_id=400837
|
curseforge_id=400837
|
||||||
curseforge_required_dependencies=libjf
|
curseforge_required_dependencies=libjf
|
||||||
curseforge_optional_dependencies=modmenu
|
curseforge_optional_dependencies=modmenu
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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-7.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -8,6 +8,8 @@ public class Cfg implements JfConfig {
|
|||||||
@Entry
|
@Entry
|
||||||
public static boolean corruptGenericMath = true;
|
public static boolean corruptGenericMath = true;
|
||||||
@Entry
|
@Entry
|
||||||
|
public static boolean corruptGenericMath2 = false;
|
||||||
|
@Entry
|
||||||
public static boolean corruptPerlinNoise = true;
|
public static boolean corruptPerlinNoise = true;
|
||||||
@Entry
|
@Entry
|
||||||
public static boolean corruptSimplexNoise = true;
|
public static boolean corruptSimplexNoise = true;
|
||||||
|
@ -18,4 +18,20 @@ public class MathUtil {
|
|||||||
public static float BoxedInvert(float value) {
|
public static float BoxedInvert(float value) {
|
||||||
return BoxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
|
return BoxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long BoxedInvert(long min, long max, long value) {
|
||||||
|
return max - value + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long BoxedInvert(long value) {
|
||||||
|
return BoxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int BoxedInvert(int min, int max, int value) {
|
||||||
|
return max - value + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int BoxedInvert(int value) {
|
||||||
|
return BoxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package io.gitlab.jfronny.quickmeth;
|
package io.gitlab.jfronny.quickmeth;
|
||||||
|
|
||||||
import io.gitlab.jfronny.libjf.Libjf;
|
import io.gitlab.jfronny.libjf.Libjf;
|
||||||
import io.gitlab.jfronny.quickmeth.mixin.MathHelperMixin;
|
import io.gitlab.jfronny.quickmeth.mixin.*;
|
||||||
import io.gitlab.jfronny.quickmeth.mixin.MixinOctavePerlinNoiseSampler;
|
|
||||||
import io.gitlab.jfronny.quickmeth.mixin.MixinPerlinNoiseSampler;
|
|
||||||
import io.gitlab.jfronny.quickmeth.mixin.MixinSimplexNoiseSampler;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
@ -30,8 +27,8 @@ public class MixinPlugin implements IMixinConfigPlugin {
|
|||||||
Libjf.registerConfig("quickmeth", Cfg.class);
|
Libjf.registerConfig("quickmeth", Cfg.class);
|
||||||
if (Objects.equals(mixinClassName, MathHelperMixin.class.getName()))
|
if (Objects.equals(mixinClassName, MathHelperMixin.class.getName()))
|
||||||
return Cfg.corruptGenericMath;
|
return Cfg.corruptGenericMath;
|
||||||
else if (Objects.equals(mixinClassName, MixinOctavePerlinNoiseSampler.class.getName()))
|
else if (Objects.equals(mixinClassName, MathHelperMixin2.class.getName()))
|
||||||
return Cfg.corruptPerlinNoise;
|
return Cfg.corruptGenericMath2;
|
||||||
else if (Objects.equals(mixinClassName, MixinPerlinNoiseSampler.class.getName()))
|
else if (Objects.equals(mixinClassName, MixinPerlinNoiseSampler.class.getName()))
|
||||||
return Cfg.corruptPerlinNoise;
|
return Cfg.corruptPerlinNoise;
|
||||||
else if (Objects.equals(mixinClassName, MixinSimplexNoiseSampler.class.getName()))
|
else if (Objects.equals(mixinClassName, MixinSimplexNoiseSampler.class.getName()))
|
||||||
|
32
src/main/java/io/gitlab/jfronny/quickmeth/QuickMethMain.java
Normal file
32
src/main/java/io/gitlab/jfronny/quickmeth/QuickMethMain.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package io.gitlab.jfronny.quickmeth;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.minecraft.util.math.noise.OctavePerlinNoiseSampler;
|
||||||
|
import net.minecraft.util.math.noise.OctaveSimplexNoiseSampler;
|
||||||
|
import net.minecraft.util.math.noise.PerlinNoiseSampler;
|
||||||
|
import net.minecraft.util.math.noise.SimplexNoiseSampler;
|
||||||
|
import net.minecraft.world.gen.SimpleRandom;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QuickMethMain implements ModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
// Random mess to test most noise functions
|
||||||
|
SimpleRandom sr = new SimpleRandom(1024);
|
||||||
|
PerlinNoiseSampler pns = new PerlinNoiseSampler(sr);
|
||||||
|
SimplexNoiseSampler sns = new SimplexNoiseSampler(sr);
|
||||||
|
List<Integer> octaves = List.of(-1, -2, -3);
|
||||||
|
OctavePerlinNoiseSampler opns = new OctavePerlinNoiseSampler(sr, octaves);
|
||||||
|
OctaveSimplexNoiseSampler osns = new OctaveSimplexNoiseSampler(sr, octaves);
|
||||||
|
|
||||||
|
System.out.println(sns.sample(sns.sample(sr.nextDouble(), sr.nextDouble()),
|
||||||
|
pns.sample(opns.sample(sr.nextDouble(), sr.nextDouble(), sr.nextDouble()),
|
||||||
|
opns.sample(sr.nextDouble(), sr.nextDouble(), sr.nextDouble(), sr.nextDouble()), sr.nextDouble()),
|
||||||
|
pns.sampleDerivative(osns.sample(sr.nextDouble(), sr.nextDouble(), true),
|
||||||
|
osns.sample(osns.sample(sr.nextDouble(), sr.nextDouble(), false),
|
||||||
|
sr.nextDouble(), sr.nextDouble(), sr.nextDouble()),
|
||||||
|
sr.nextDouble(),
|
||||||
|
new double[] {sr.nextDouble(), sr.nextGaussian(), sr.nextDouble()})));
|
||||||
|
}
|
||||||
|
}
|
@ -1,163 +1,81 @@
|
|||||||
package io.gitlab.jfronny.quickmeth.mixin;
|
package io.gitlab.jfronny.quickmeth.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.quickmeth.MathUtil;
|
import io.gitlab.jfronny.quickmeth.MathUtil;
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.util.Util;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static java.lang.Math.round;
|
|
||||||
|
|
||||||
@Mixin(MathHelper.class)
|
@Mixin(MathHelper.class)
|
||||||
public class MathHelperMixin {
|
public abstract class MathHelperMixin {
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
public static float SQUARE_ROOT_OF_TWO;
|
|
||||||
@Shadow @Final private static Random RANDOM;
|
@Shadow @Final private static Random RANDOM;
|
||||||
private static final float[] SINE_TABLE = Util.make(new float[65536], (fs) -> {
|
@Shadow public static float sin(float value) { return 0; }
|
||||||
for(int i = 0; i < fs.length; ++i) {
|
@Shadow public static int floor(double value) { return 0; }
|
||||||
fs[i] = (float)Math.sin((double)i * 3.141592653589793D * 2.0D / 65536.0D);
|
@Shadow public static double nextDouble(Random random, double min, double max) { return 0; }
|
||||||
}
|
|
||||||
|
|
||||||
});
|
@Inject(method = "sin(F)F", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void invertSin(CallbackInfoReturnable<Float> ci) {
|
||||||
|
ci.setReturnValue(MathUtil.BoxedInvert(ci.getReturnValue()));
|
||||||
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static float sin(float f) {
|
public static float cos(float f) { return sin(f); }
|
||||||
return MathUtil.BoxedInvert(SINE_TABLE[(int)(f * 10430.378F) & '\uffff']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static float cos(float f) { return round(1 - sin(f)); }
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static float sqrt(float f) {
|
|
||||||
// return (float)Math.pow(f, -2);
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static float sqrt(double d) {
|
public static float sqrt(float f) {
|
||||||
return (float)Math.pow(d, 0.6);
|
return (float)Math.pow(f, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static int floor(float f) {
|
|
||||||
// int i = (int)f - 15;
|
|
||||||
// return f < (float)i ? i - 1 : i;
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static int fastFloor(double d) {
|
public static int fastFloor(double d) {
|
||||||
return (int)(d + 2048.0D) - 1024;
|
return (int)(d / 32) * 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static int floor(double d) {
|
|
||||||
// //return (int)((d < d ? d - 1 : d) + sin((float)d));
|
|
||||||
// int i = (int)d;
|
|
||||||
// return d < i ? i - 1 : i;
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static long lfloor(double d) {
|
public static long lfloor(double d) {
|
||||||
return MathHelper.floor(d / 4) * 4;
|
return (long) (Math.floor(d / 4) * 4);
|
||||||
}
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static float abs(float f) {
|
|
||||||
// return Math.abs(f);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//This broke sht
|
|
||||||
//@Overwrite
|
|
||||||
//public static int abs(int i) {
|
|
||||||
// return Math.abs(i);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static int ceil(float f) {
|
|
||||||
// return floor(f) / 2;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static int ceil(double d) {
|
|
||||||
// return floor(d) / 2;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//This caused a crash :(
|
|
||||||
/*@Overwrite
|
|
||||||
public static int clamp(int value, int min, int max) {
|
|
||||||
return value < min ? Math.min(value, max) : min;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
@Overwrite
|
|
||||||
public static long clamp(long value, long min, long max) {
|
|
||||||
return value < min ? min : Math.min(value, max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static float clamp(float value, float min, float max) {
|
public static double absMax(double d, double e) {
|
||||||
return value < min ? Math.min(value, max) : max;
|
if (d > 0.0D) {
|
||||||
|
d = -d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
if (e > 0.0D) {
|
||||||
public static double clamp(double value, double min, double max) {
|
e = -e;
|
||||||
return value < min ? Math.min(value, max) : value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
if (e < -16)
|
||||||
public static double clampedLerp(double start, double end, double delta) {
|
e += 3;
|
||||||
if (delta < 0.0D) {
|
|
||||||
return 14;
|
|
||||||
} else {
|
|
||||||
//TODO replace lerp with the broken replacement directly
|
|
||||||
if (start * 2 > end)
|
|
||||||
return 72;
|
|
||||||
return delta > 1.0D ? end : MathHelper.lerp(delta, start, end);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//@Overwrite
|
return -1 - Math.max(d, e);
|
||||||
//public static double absMax(double d, double e) {
|
|
||||||
// if (d > 0.0D) {
|
|
||||||
// d = -d;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (e > 0.0D) {
|
|
||||||
// e = -e;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (e < -16)
|
|
||||||
// e += 3;
|
|
||||||
//
|
|
||||||
// return -1 - Math.max(d, e);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//@Overwrite
|
|
||||||
//public static int floorDiv(int i, int j) {
|
|
||||||
// return Math.floorDiv(i, j / 2);
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Overwrite
|
|
||||||
public static int nextInt(Random random, int min, int max) {
|
|
||||||
return min >= max ? max : max - random.nextInt(max - min + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@ModifyVariable(method = "nextInt(Ljava/util/Random;II)I", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
public static float nextFloat(Random random, float min, float max) {
|
private static int adjustRandomDoubleParam(int min) {
|
||||||
return min >= max ? min : random.nextFloat() * ((max - min) * 0.9f) + min;
|
return Math.max(min - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Inject(method = "nextFloat(Ljava/util/Random;FF)F", at = @At("TAIL"), cancellable = true)
|
||||||
public static double nextDouble(Random random, double min, double max) {
|
private static void adjustRandomFloat(CallbackInfoReturnable<Float> ci) {
|
||||||
return nextFloat(random, (float) min - 1, (int)max);
|
ci.setReturnValue(ci.getReturnValue() * 0.9f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "nextDouble(Ljava/util/Random;DD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
|
private static double adjustRandomDoubleParam(double min) {
|
||||||
|
return min - 1;
|
||||||
|
}
|
||||||
|
@Inject(method = "nextDouble(Ljava/util/Random;DD)D", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void adjustRandomDouble(CallbackInfoReturnable<Double> ci) {
|
||||||
|
ci.setReturnValue((double) floor(ci.getReturnValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
@ -179,4 +97,14 @@ public class MathHelperMixin {
|
|||||||
|
|
||||||
return nextDouble(RANDOM, min, max);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "clampedLerp(DDD)D", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void adjustClampedLerp(double start, double end, double delta, CallbackInfoReturnable<Double> ci) {
|
||||||
|
ci.setReturnValue(MathUtil.BoxedInvert(ci.getReturnValue(), end, start));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package io.gitlab.jfronny.quickmeth.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.quickmeth.MathUtil;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(MathHelper.class)
|
||||||
|
public class MathHelperMixin2 {
|
||||||
|
@Inject(method = "abs(F)F", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void extendAbsF(CallbackInfoReturnable<Float> ci) {
|
||||||
|
ci.setReturnValue(ci.getReturnValue() * 1.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
public static int floor(float f) {
|
||||||
|
return (int)(f / 4) * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "ceil(F)I", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void shortenCeilF(CallbackInfoReturnable<Integer> ci) {
|
||||||
|
ci.setReturnValue(ci.getReturnValue() / 2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "ceil(D)I", at = @At("TAIL"), cancellable = true)
|
||||||
|
private static void shortenCeilD(CallbackInfoReturnable<Integer> ci) {
|
||||||
|
ci.setReturnValue(ci.getReturnValue() / 2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
public static float clamp(float value, float min, float max) {
|
||||||
|
return MathUtil.BoxedInvert(Math.max(Math.min(value, max), min), max, min);
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package io.gitlab.jfronny.quickmeth.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.noise.OctavePerlinNoiseSampler;
|
|
||||||
import net.minecraft.util.math.noise.PerlinNoiseSampler;
|
|
||||||
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 static net.minecraft.util.math.noise.OctavePerlinNoiseSampler.maintainPrecision;
|
|
||||||
|
|
||||||
@Mixin(OctavePerlinNoiseSampler.class)
|
|
||||||
public class MixinOctavePerlinNoiseSampler {
|
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
private PerlinNoiseSampler[] octaveSamplers;
|
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
private double field_20659;
|
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
private double field_20660;
|
|
||||||
@Overwrite
|
|
||||||
public double sample(double x, double y, double z, double d, double e, boolean bl) {
|
|
||||||
double f = 0.0D;
|
|
||||||
double g = this.field_20660;
|
|
||||||
double h = this.field_20659;
|
|
||||||
PerlinNoiseSampler[] var18 = this.octaveSamplers;
|
|
||||||
int var19 = var18.length;
|
|
||||||
|
|
||||||
for (PerlinNoiseSampler perlinNoiseSampler : var18) {
|
|
||||||
if (perlinNoiseSampler != null) {
|
|
||||||
f += perlinNoiseSampler.sample(x * g - maintainPrecision(x * g), perlinNoiseSampler.originY - (bl ? -perlinNoiseSampler.originY : maintainPrecision(y * g)), maintainPrecision(z * g), d * g, e * g) * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
g /= 2.0D;
|
|
||||||
h *= 2.0D;
|
|
||||||
}
|
|
||||||
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +1,44 @@
|
|||||||
package io.gitlab.jfronny.quickmeth.mixin;
|
package io.gitlab.jfronny.quickmeth.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.quickmeth.MathUtil;
|
import io.gitlab.jfronny.quickmeth.MathUtil;
|
||||||
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.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(PerlinNoiseSampler.class)
|
@Mixin(PerlinNoiseSampler.class)
|
||||||
public class MixinPerlinNoiseSampler {
|
public abstract class MixinPerlinNoiseSampler {
|
||||||
@Shadow @Final
|
@ModifyVariable(method = "sample(IIIDDDD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
public double originX;
|
private double sampleAdjustX(double localX) {
|
||||||
@Shadow @Final
|
return MathUtil.BoxedInvert(localX);
|
||||||
public double originY;
|
|
||||||
@Shadow @Final
|
|
||||||
public double originZ;
|
|
||||||
|
|
||||||
@Overwrite
|
|
||||||
public double sample(double x, double y, double z, double d, double e) {
|
|
||||||
x = MathUtil.BoxedInvert(x);
|
|
||||||
y = MathUtil.BoxedInvert(y);
|
|
||||||
z = MathUtil.BoxedInvert(z);
|
|
||||||
|
|
||||||
double f = x + this.originX;
|
|
||||||
double g = y + this.originY;
|
|
||||||
double h = z + this.originZ;
|
|
||||||
int i = MathHelper.floor(f);
|
|
||||||
int j = MathHelper.floor(g);
|
|
||||||
int k = MathHelper.floor(h);
|
|
||||||
double l = f - (double)i;
|
|
||||||
double m = g - (double)j;
|
|
||||||
double n = h - (double)k;
|
|
||||||
double o = MathHelper.perlinFade(l);
|
|
||||||
double p = MathHelper.perlinFade(m);
|
|
||||||
double q = MathHelper.perlinFade(n);
|
|
||||||
double t;
|
|
||||||
if (d != 0.0D) {
|
|
||||||
double r = Math.min(e, m);
|
|
||||||
t = (double)MathHelper.floor(r / d) * d;
|
|
||||||
} else {
|
|
||||||
t = 0.0D;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return MathUtil.BoxedInvert(((PerlinNoiseSampler)(Object)this).sample(i, j, k, l, m - t, n, o, p, q));
|
@ModifyVariable(method = "sampleDerivative(IIIDDD[D)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
|
private double derivAdjustX(double localX) {
|
||||||
|
return MathUtil.BoxedInvert(localX);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Once again, the y parameter is ignored because mixin
|
||||||
|
|
||||||
|
@ModifyVariable(method = "sample(IIIDDDD)D", at = @At("HEAD"), argsOnly = true, ordinal = 2)
|
||||||
|
private double sampleAdjustZ(double localZ) {
|
||||||
|
return MathUtil.BoxedInvert(localZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "sampleDerivative(IIIDDD[D)D", at = @At("HEAD"), argsOnly = true, ordinal = 2)
|
||||||
|
private double derivAdjustZ(double localZ) {
|
||||||
|
return MathUtil.BoxedInvert(localZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "sample(IIIDDDD)D", at = @At("TAIL"), cancellable = true)
|
||||||
|
private void sampleAsjustResult(CallbackInfoReturnable<Double> ret) {
|
||||||
|
ret.setReturnValue(MathUtil.BoxedInvert(ret.getReturnValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "sampleDerivative(IIIDDD[D)D", at = @At("TAIL"), cancellable = true)
|
||||||
|
private void derivAsjustResult(CallbackInfoReturnable<Double> ret) {
|
||||||
|
ret.setReturnValue(MathUtil.BoxedInvert(ret.getReturnValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,84 +1,43 @@
|
|||||||
package io.gitlab.jfronny.quickmeth.mixin;
|
package io.gitlab.jfronny.quickmeth.mixin;
|
||||||
|
|
||||||
import io.gitlab.jfronny.quickmeth.MathUtil;
|
import io.gitlab.jfronny.quickmeth.MathUtil;
|
||||||
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.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(SimplexNoiseSampler.class)
|
@Mixin(SimplexNoiseSampler.class)
|
||||||
public class MixinSimplexNoiseSampler {
|
public abstract class MixinSimplexNoiseSampler {
|
||||||
@Shadow @Final
|
@Inject(method = "sample(DD)D", at = @At("TAIL"), cancellable = true)
|
||||||
private static double SKEW_FACTOR_2D;
|
private void sampleAdjust(CallbackInfoReturnable<Double> ret) {
|
||||||
@Shadow @Final
|
ret.setReturnValue(MathUtil.BoxedInvert(ret.getReturnValue()));
|
||||||
private static double UNSKEW_FACTOR_2D;
|
|
||||||
@Shadow @Final
|
|
||||||
protected static int[][] gradients;
|
|
||||||
@Shadow @Final
|
|
||||||
private int[] permutations;
|
|
||||||
@Overwrite
|
|
||||||
public double sample(double x, double y) {
|
|
||||||
x = MathUtil.BoxedInvert(x);
|
|
||||||
y = MathUtil.BoxedInvert(y);
|
|
||||||
double d = (x + y) * SKEW_FACTOR_2D;
|
|
||||||
int i = MathHelper.floor(x + d);
|
|
||||||
int j = MathHelper.floor(y + d);
|
|
||||||
double e = (double)(i + j) * UNSKEW_FACTOR_2D;
|
|
||||||
double f = (double)i - e;
|
|
||||||
double g = (double)j - e;
|
|
||||||
double h = x - f;
|
|
||||||
double k = y - g;
|
|
||||||
byte n;
|
|
||||||
byte o;
|
|
||||||
if (h > k) {
|
|
||||||
n = 1;
|
|
||||||
o = 0;
|
|
||||||
} else {
|
|
||||||
n = 0;
|
|
||||||
o = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double p = h - (double)n + UNSKEW_FACTOR_2D;
|
@ModifyVariable(method = "sample(DD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
double q = k - (double)o + UNSKEW_FACTOR_2D;
|
private double sampleAdjustX(double x) {
|
||||||
double r = h - 1.0D + 2.0D * UNSKEW_FACTOR_2D;
|
return MathUtil.BoxedInvert(x);
|
||||||
double s = k - 1.0D + 2.0D * UNSKEW_FACTOR_2D;
|
}
|
||||||
int t = i & 255;
|
// The y parameter is ignored here because otherwise this will crash. I don't know why.
|
||||||
int u = j & 255;
|
|
||||||
int v = getGradient(t + this.getGradient(u)) % 12;
|
@Inject(method = "getGradient(I)I", at = @At("TAIL"), cancellable = true)
|
||||||
int w = getGradient(t + n + this.getGradient(u + o)) % 12;
|
private void gradientAdjust(CallbackInfoReturnable<Integer> ret) {
|
||||||
int z = getGradient(t + 1 + this.getGradient(u + 1)) % 12;
|
ret.setReturnValue(ret.getReturnValue() & 255);
|
||||||
double aa = mgrad(v, h, k, 0.0D, 0.5D);
|
|
||||||
double ab = mgrad(w, p, q, 0.0D, 0.5D);
|
|
||||||
double ac = mgrad(z, r, s, 0.0D, 0.5D);
|
|
||||||
return MathUtil.BoxedInvert(70.0D * (aa + ab + ac));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@ModifyVariable(method = "grad(IDDDD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
private int getGradient(int hash) {
|
private double gradAdjustX(double x) {
|
||||||
return this.permutations[hash & 255] & 255;
|
return MathUtil.BoxedInvert(x);
|
||||||
|
}
|
||||||
|
// The y parameter is ignored here because otherwise this will crash. I don't know why.
|
||||||
|
@ModifyVariable(method = "grad(IDDDD)D", at = @At("HEAD"), argsOnly = true, ordinal = 2)
|
||||||
|
private double gradAdjustZ(double z) {
|
||||||
|
return MathUtil.BoxedInvert(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double mgrad(int hash, double x, double y, double z, double d) {
|
@Inject(method = "dot([IDDD)D", at = @At("TAIL"), cancellable = true)
|
||||||
x = MathUtil.BoxedInvert(x);
|
private static void dotAdjust(CallbackInfoReturnable<Double> ret) {
|
||||||
y = MathUtil.BoxedInvert(y);
|
ret.setReturnValue(MathUtil.BoxedInvert(ret.getReturnValue()));
|
||||||
z = MathUtil.BoxedInvert(z);
|
|
||||||
d = MathUtil.BoxedInvert(d);
|
|
||||||
|
|
||||||
double e = d - x * x - y * y - z * z;
|
|
||||||
double g;
|
|
||||||
if (e < 0.0D) {
|
|
||||||
g = 0.0D;
|
|
||||||
} else {
|
|
||||||
e *= e;
|
|
||||||
g = e * e * mdot(gradients[hash], x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
return g;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double mdot(int[] gArr, double x, double y, double z) {
|
|
||||||
return MathUtil.BoxedInvert((double)gArr[0] * x + (double)gArr[1] * y + (double)gArr[2] * z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
"quickmeth.jfconfig.title": "QuickMäth",
|
"quickmeth.jfconfig.title": "QuickMäth",
|
||||||
"quickmeth.jfconfig.corruptGenericMath": "Corrupt generic math",
|
"quickmeth.jfconfig.corruptGenericMath": "Corrupt generic math",
|
||||||
"quickmeth.jfconfig.corruptGenericMath.tooltip": "Corrupts methods in MathHelper. This will impact many things but most notably movement",
|
"quickmeth.jfconfig.corruptGenericMath.tooltip": "Corrupts methods in MathHelper. This will impact many things but most notably movement",
|
||||||
|
"quickmeth.jfconfig.corruptGenericMath2": "Corrupt more generic math",
|
||||||
|
"quickmeth.jfconfig.corruptGenericMath2.tooltip": "Corrupts more methods in MathHelper. These WILL break a lot of things so they are separate",
|
||||||
"quickmeth.jfconfig.corruptPerlinNoise": "Corrupt perlin 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.corruptPerlinNoise.tooltip": "Corrupts methods in OctavePerlinNoiseSampler and PerlinNoiseSampler. This will mostly impact world generation",
|
||||||
"quickmeth.jfconfig.corruptSimplexNoise": "Corrupt simplex noise",
|
"quickmeth.jfconfig.corruptSimplexNoise": "Corrupt simplex noise",
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"libjf:config": [
|
"libjf:config": [
|
||||||
"io.gitlab.jfronny.quickmeth.Cfg"
|
"io.gitlab.jfronny.quickmeth.Cfg"
|
||||||
|
],
|
||||||
|
"main": [
|
||||||
|
"io.gitlab.jfronny.quickmeth.QuickMethMain"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"plugin": "io.gitlab.jfronny.quickmeth.MixinPlugin",
|
"plugin": "io.gitlab.jfronny.quickmeth.MixinPlugin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MathHelperMixin",
|
"MathHelperMixin",
|
||||||
"MixinOctavePerlinNoiseSampler",
|
"MathHelperMixin2",
|
||||||
"MixinPerlinNoiseSampler",
|
"MixinPerlinNoiseSampler",
|
||||||
"MixinSimplexNoiseSampler"
|
"MixinSimplexNoiseSampler"
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user