44 lines
1.9 KiB
Java
44 lines
1.9 KiB
Java
package io.gitlab.jfronny.quickmeth.mixin;
|
|
|
|
import io.gitlab.jfronny.quickmeth.MathUtil;
|
|
import net.minecraft.util.math.noise.SimplexNoiseSampler;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
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;
|
|
|
|
@Mixin(SimplexNoiseSampler.class)
|
|
public abstract class MixinSimplexNoiseSampler {
|
|
@Inject(method = "sample(DD)D", at = @At("TAIL"), cancellable = true)
|
|
private void sampleAdjust(CallbackInfoReturnable<Double> ret) {
|
|
ret.setReturnValue(MathUtil.boxedInvert(ret.getReturnValue()));
|
|
}
|
|
|
|
@ModifyVariable(method = "sample(DD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
|
private double sampleAdjustX(double x) {
|
|
return MathUtil.boxedInvert(x);
|
|
}
|
|
// The y parameter is ignored here because otherwise this will crash. I don't know why.
|
|
|
|
@Inject(method = "getGradient(I)I", at = @At("TAIL"), cancellable = true)
|
|
private void gradientAdjust(CallbackInfoReturnable<Integer> ret) {
|
|
ret.setReturnValue(ret.getReturnValue() & 255);
|
|
}
|
|
|
|
@ModifyVariable(method = "grad(IDDDD)D", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
|
private double gradAdjustX(double x) {
|
|
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);
|
|
}
|
|
|
|
@Inject(method = "dot([IDDD)D", at = @At("TAIL"), cancellable = true)
|
|
private static void dotAdjust(CallbackInfoReturnable<Double> ret) {
|
|
ret.setReturnValue(MathUtil.boxedInvert(ret.getReturnValue()));
|
|
}
|
|
}
|