From 450eee5fe667d776a2d2c8b89a7f1dde9b918c25 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 24 Feb 2024 14:22:28 +0000 Subject: [PATCH 1/3] Downgrade for quilt compatibility --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index b83bd439..f56cd269 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ org.gradle.daemon=false # check these on https://fabricmc.net/develop minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 - loader_version=0.15.7 - fabric_version=0.92.0+1.20.1 + loader_version=0.15.3 + fabric_version=0.91.0+1.20.1 # Mod Properties group=com.minelittlepony From f9711b9043c5177aeaba93d5629092654ade66d3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 24 Feb 2024 16:09:02 +0000 Subject: [PATCH 2/3] Add error messages when lerping nan values --- .../java/com/minelittlepony/unicopia/util/Lerp.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/util/Lerp.java b/src/main/java/com/minelittlepony/unicopia/util/Lerp.java index c0169aab..4ce60ff4 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/Lerp.java +++ b/src/main/java/com/minelittlepony/unicopia/util/Lerp.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.util; +import com.minelittlepony.unicopia.Unicopia; + import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; @@ -23,6 +25,9 @@ public class Lerp { } public boolean update(float newTarget, long changeDuration) { + if (Float.isNaN(newTarget) || Float.isInfinite(newTarget)) { + Unicopia.LOGGER.error("Invalid lerp target. Target cannot be NaN or Infinity"); + } if (MathHelper.approximatelyEquals(end, newTarget)) { return false; } @@ -31,6 +36,12 @@ public class Lerp { end = newTarget; duration = changeDuration; finished = false; + if (Float.isNaN(start) || Float.isInfinite(start)) { + Unicopia.LOGGER.error("Invalid lerp start. Value cannot be NaN or Infinity"); + } + if (Float.isNaN(end) || Float.isInfinite(end)) { + Unicopia.LOGGER.error("Invalid lerp end. Value cannot be NaN or Infinity"); + } return true; } From 0ba987159fece58133f5015dcd4b6de6afc56fa6 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 24 Feb 2024 16:22:41 +0000 Subject: [PATCH 3/3] Prevent delta from becoming infinity or nan when duration is 0 --- .../java/com/minelittlepony/unicopia/util/Lerp.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/util/Lerp.java b/src/main/java/com/minelittlepony/unicopia/util/Lerp.java index 4ce60ff4..2032209c 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/Lerp.java +++ b/src/main/java/com/minelittlepony/unicopia/util/Lerp.java @@ -31,6 +31,13 @@ public class Lerp { if (MathHelper.approximatelyEquals(end, newTarget)) { return false; } + if (changeDuration == 0) { + start = newTarget; + end = newTarget; + finished = true; + return false; + } + start = getValue(); startTime = Util.getMeasuringTimeMs(); end = newTarget; @@ -66,6 +73,9 @@ public class Lerp { } private float getDelta() { + if (duration == 0) { + return 1; + } return MathHelper.clamp((float)(Util.getMeasuringTimeMs() - startTime) / (float)duration, 0, 1); } }