From ffa3798dae4b6714a21eb1296b8fea347492ede6 Mon Sep 17 00:00:00 2001 From: fretuks Date: Thu, 11 Dec 2025 22:02:59 +0100 Subject: [PATCH] fixed a critical bug that made it impossible to become insane --- build.gradle | 6 ++---- gradle.properties | 2 +- .../mindmotion/event/PlayerTickHandler.java | 20 +++++++++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 7da5537..3454cd6 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ minecraft { sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { - mavenLocal() // REQUIRED for local Ascend mod + mavenLocal() mavenCentral() maven { @@ -86,9 +86,7 @@ repositories { dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - - // Local Ascend mod (works because of mavenLocal()) - implementation fg.deobf("net.fretux.ascend:Ascend:2.0.2") + implementation fg.deobf("net.fretux.ascend:Ascend:2.0.3") // Iron's Spellbooks compileOnly fg.deobf("io.redspace.ironsspellbooks:irons_spellbooks:${irons_spells_version}:api") diff --git a/gradle.properties b/gradle.properties index 79cece1..445da49 100644 --- a/gradle.properties +++ b/gradle.properties @@ -52,7 +52,7 @@ mod_name=Mind & Motion # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=1.2.0 +mod_version=1.2.1 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/net/fretux/mindmotion/event/PlayerTickHandler.java b/src/main/java/net/fretux/mindmotion/event/PlayerTickHandler.java index 0cbb8ad..90cbb42 100644 --- a/src/main/java/net/fretux/mindmotion/event/PlayerTickHandler.java +++ b/src/main/java/net/fretux/mindmotion/event/PlayerTickHandler.java @@ -150,12 +150,13 @@ public class PlayerTickHandler { } return; } - sanity.setSanity(value + delta); - value = sanity.getSanity(); - if (value <= 0 && delta < 0) { - float overflow = Math.abs(value); + float newValue = value + delta; + if (newValue <= 0 && delta < 0) { + float overflow = -newValue; sanity.setSanity(0); sanity.setInsanity(Math.min(sanity.getMaxSanity(), insanity + overflow)); + } else { + sanity.setSanity(newValue); } insanity = sanity.getInsanity(); if (sanity.getSanity() <= 0 && insanity >= sanity.getMaxSanity()) { @@ -168,10 +169,17 @@ public class PlayerTickHandler { return; } } else { - sanity.setSanity(value + delta); - if (sanity.getSanity() > 0) { + float newValueElse = value + delta; + if (newValueElse <= 0 && delta < 0) { + float overflow = -newValueElse; + sanity.setSanity(0); + sanity.setInsanity(Math.min(sanity.getMaxSanity(), insanity + overflow)); + insanity = sanity.getInsanity(); + } else if (newValueElse > 0) { + sanity.setSanity(newValueElse); sanity.setInsanity(Math.max(0, insanity - 0.15f)); insanityDamageTicks.remove(player.getUUID()); + insanity = sanity.getInsanity(); } } float percent = (value / sanity.getMaxSanity()) * 100f;