diff --git a/src/main/java/net/frozenblock/lib/gravity/api/functions/InterpolatedGravityFunction.java b/src/main/java/net/frozenblock/lib/gravity/api/functions/InterpolatedGravityFunction.java index 4dc8fa033..7151b1378 100644 --- a/src/main/java/net/frozenblock/lib/gravity/api/functions/InterpolatedGravityFunction.java +++ b/src/main/java/net/frozenblock/lib/gravity/api/functions/InterpolatedGravityFunction.java @@ -28,17 +28,21 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -@ApiStatus.Experimental -@ApiStatus.Internal -public record InterpolatedGravityFunction(double gravity, double minLerpGravity, double maxLerpGravity, double minLerpY, double maxLerpY) implements SerializableGravityFunction { +public record InterpolatedGravityFunction( + double gravity, + //double minLerpGravity, + //double maxLerpGravity, + //double minLerpY, + //double maxLerpY +) implements SerializableGravityFunction { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.DOUBLE.fieldOf("gravity").forGetter(InterpolatedGravityFunction::gravity), - Codec.DOUBLE.fieldOf("minLerpGravity").forGetter(InterpolatedGravityFunction::minLerpGravity), - Codec.DOUBLE.fieldOf("maxLerpGravity").forGetter(InterpolatedGravityFunction::maxLerpY), - Codec.DOUBLE.fieldOf("minLerpY").forGetter(InterpolatedGravityFunction::minLerpY), - Codec.DOUBLE.fieldOf("maxLerpY").forGetter(InterpolatedGravityFunction::maxLerpY) + //Codec.DOUBLE.fieldOf("minLerpGravity").forGetter(InterpolatedGravityFunction::minLerpGravity), + //Codec.DOUBLE.fieldOf("maxLerpGravity").forGetter(InterpolatedGravityFunction::maxLerpY), + //Codec.DOUBLE.fieldOf("minLerpY").forGetter(InterpolatedGravityFunction::minLerpY), + //Codec.DOUBLE.fieldOf("maxLerpY").forGetter(InterpolatedGravityFunction::maxLerpY) ).apply(instance, InterpolatedGravityFunction::new) ); @@ -46,13 +50,15 @@ public record InterpolatedGravityFunction(double gravity, double minLerpGravity, @Override public double get(@Nullable Entity entity, double y, double minY, double maxY) { - if (!(entity instanceof Player)) return 1.0; - double normalizedY = (y - minLerpY) / (maxLerpY - minLerpY); + double normalizedY = (y - minY) / (maxY - minY); + //double normalizedY = (y - minLerpY) / (maxLerpY - minLerpY); - if (normalizedY < 0) return minLerpGravity; - if (normalizedY < 0.5) return Mth.lerp(normalizedY, minLerpGravity, gravity); + return gravity * normalizedY; + /*if (normalizedY < 0.5) { + return Mth.clamp(Mth.lerp(normalizedY, minLerpGravity, gravity), minLerpGravity, gravity); + } if (normalizedY < 1.0) return Mth.lerp(normalizedY, gravity, maxLerpGravity); - return maxLerpGravity; + return maxLerpGravity;*/ } @Override