From 328e01ae26baa3c7a60bbcaff403e8f7a31a365f Mon Sep 17 00:00:00 2001 From: Emma Triphora Date: Mon, 2 Sep 2024 22:10:18 -0400 Subject: [PATCH] honse sacrifice for the honse gods --- .../java/coffee/waffle/emcutils/Config.java | 25 ++++++++++++ .../waffle/emcutils/feature/HorseStats.java | 24 +++++++++--- .../resources/assets/emcutils/lang/en_us.json | 7 +++- .../waffle/emcutils/fabric/ConfigImpl.java | 25 ++++++++++++ .../waffle/emcutils/forge/ConfigImpl.java | 38 +++++++++++++++++++ gradle.properties | 2 +- 6 files changed, 113 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/coffee/waffle/emcutils/Config.java b/common/src/main/java/coffee/waffle/emcutils/Config.java index fdd214a..60cfa0f 100644 --- a/common/src/main/java/coffee/waffle/emcutils/Config.java +++ b/common/src/main/java/coffee/waffle/emcutils/Config.java @@ -47,6 +47,31 @@ public static int totalVaultPages() { throw new AssertionError("ExpectPlatform didn't apply!"); } + @ExpectPlatform + public static int precisionPoints() { + throw new AssertionError("ExpectPlatform didn't apply!"); + } + + @ExpectPlatform + public static double aquaLowerRange() { + throw new AssertionError("ExpectPlatform didn't apply!"); + } + + @ExpectPlatform + public static double greenLowerRange() { + throw new AssertionError("ExpectPlatform didn't apply!"); + } + + @ExpectPlatform + public static double yellowLowerRange() { + throw new AssertionError("ExpectPlatform didn't apply!"); + } + + @ExpectPlatform + public static double redLowerRange() { + throw new AssertionError("ExpectPlatform didn't apply!"); + } + public enum TabListSortType { NAME_ASCENDING { @Override diff --git a/common/src/main/java/coffee/waffle/emcutils/feature/HorseStats.java b/common/src/main/java/coffee/waffle/emcutils/feature/HorseStats.java index dcd3186..692e242 100644 --- a/common/src/main/java/coffee/waffle/emcutils/feature/HorseStats.java +++ b/common/src/main/java/coffee/waffle/emcutils/feature/HorseStats.java @@ -1,5 +1,6 @@ package coffee.waffle.emcutils.feature; +import coffee.waffle.emcutils.Config; import coffee.waffle.emcutils.Util; import coffee.waffle.emcutils.event.TooltipCallback; import com.google.gson.JsonArray; @@ -12,23 +13,32 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.math.RoundingMode; -import java.text.DecimalFormat; - public class HorseStats { public static void init() { TooltipCallback.ITEM.register((itemStack, list, tooltipContext, type) -> { if (!Util.isOnEMC() || !isHorseSpawnEgg(itemStack)) return; for (Text text : list) { - if (text.getString().startsWith("This horse is a")) return; + if (text.getString().startsWith("Overall rating")) return; } list.add(Text.empty()); double horseRating = getRating(itemStack); - list.add(Text.of("This horse is a " + horseRating + " out of 10").copy().formatted(Formatting.GREEN)); + Formatting formatting = Formatting.WHITE; + if (horseRating >= Config.aquaLowerRange()) { + formatting = Formatting.AQUA; + } else if (horseRating >= Config.greenLowerRange()) { + formatting = Formatting.GREEN; + } else if (horseRating >= Config.yellowLowerRange()) { + formatting = Formatting.YELLOW; + } else if (horseRating >= Config.redLowerRange()) { + formatting = Formatting.RED; + } + + list.add(Text.of("Overall rating: ").copy().formatted(Formatting.GRAY) + .append(Text.of(String.valueOf(horseRating)).copy().formatted(formatting, Formatting.BOLD))); itemStack.getItem().appendTooltip(itemStack, tooltipContext, list, type); }); @@ -138,6 +148,8 @@ private static double getRating(ItemStack item) { double overallRating = (speedRating + jumpRating + healthRating) / 3; - return (double) Math.round(overallRating * 100d) / 100d; + double precision = Math.pow(10, Config.precisionPoints()); + + return (double) Math.round(overallRating * precision) / precision; } } diff --git a/common/src/main/resources/assets/emcutils/lang/en_us.json b/common/src/main/resources/assets/emcutils/lang/en_us.json index 806fd7e..ca809f1 100644 --- a/common/src/main/resources/assets/emcutils/lang/en_us.json +++ b/common/src/main/resources/assets/emcutils/lang/en_us.json @@ -21,5 +21,10 @@ "emcutils.midnightconfig.dontRunResidenceCollector": "Don't run residence collector", "emcutils.midnightconfig.dontRunResidenceCollector.tooltip": "The following config option can be enabled if you're running \n on a very slow connection to prevent spam in the console.\n Note, though, that this will disable cross-server visit \n command integration and minimap integration.", "emcutils.midnightconfig.totalVaultPages": "Limit for vault page buttons", - "emcutils.midnightconfig.totalVaultPages.tooltip": "You should set this to the number of vault pages that you have. \n For example, if you have five vault pages, set this to 5." + "emcutils.midnightconfig.totalVaultPages.tooltip": "You should set this to the number of vault pages that you have. \n For example, if you have five vault pages, set this to 5.", + "emcutils.midnightconfig.precisionPoints": "Honse precision points (hi marvel)", + "emcutils.midnightconfig.aquaLowerRange": "Aqua colored horse rating, lower range", + "emcutils.midnightconfig.greenLowerRange": "Green colored horse rating, lower range", + "emcutils.midnightconfig.yellowLowerRange": "Yellow colored horse rating, lower range", + "emcutils.midnightconfig.redLowerRange": "Red colored horse rating, lower range" } diff --git a/fabric/src/main/java/coffee/waffle/emcutils/fabric/ConfigImpl.java b/fabric/src/main/java/coffee/waffle/emcutils/fabric/ConfigImpl.java index 4726d4a..80fd8b2 100644 --- a/fabric/src/main/java/coffee/waffle/emcutils/fabric/ConfigImpl.java +++ b/fabric/src/main/java/coffee/waffle/emcutils/fabric/ConfigImpl.java @@ -14,6 +14,11 @@ public class ConfigImpl extends MidnightConfig { @Entry public static ChatAlertSound chatAlertSound = ChatAlertSound.LEVEL_UP; @Entry public static boolean dontRunResidenceCollector = false; @Entry(min = 1, max = 255) public static int totalVaultPages = 255; + @Entry(min = 0, max = 10) public static int precisionPoints = 2; + @Entry(min = 0, max = 10) public static double aquaLowerRange = 9.9; + @Entry(min = 0, max = 10) public static double greenLowerRange = 9.5; + @Entry(min = 0, max = 10) public static double yellowLowerRange = 9.0; + @Entry(min = 0, max = 10) public static double redLowerRange = 8.0; public static boolean chatButtonsEnabled() { return chatButtonsEnabled; @@ -46,4 +51,24 @@ public static boolean dontRunResidenceCollector() { public static int totalVaultPages() { return totalVaultPages; } + + public static int precisionPoints() { + return precisionPoints; + } + + public static double aquaLowerRange() { + return aquaLowerRange; + } + + public static double greenLowerRange() { + return greenLowerRange; + } + + public static double yellowLowerRange() { + return yellowLowerRange; + } + + public static double redLowerRange() { + return redLowerRange; + } } diff --git a/forge/src/main/java/coffee/waffle/emcutils/forge/ConfigImpl.java b/forge/src/main/java/coffee/waffle/emcutils/forge/ConfigImpl.java index c65b64a..777a1e7 100644 --- a/forge/src/main/java/coffee/waffle/emcutils/forge/ConfigImpl.java +++ b/forge/src/main/java/coffee/waffle/emcutils/forge/ConfigImpl.java @@ -5,6 +5,7 @@ import coffee.waffle.emcutils.Config.TabListSortType; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; +import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; import net.minecraftforge.common.ForgeConfigSpec.EnumValue; import net.minecraftforge.common.ForgeConfigSpec.IntValue; @@ -18,6 +19,11 @@ public class ConfigImpl { public static EnumValue chatAlertSound; public static BooleanValue dontRunResidenceCollector; public static IntValue totalVaultPages; + public static IntValue precisionPoints; + public static DoubleValue aquaLowerRange; + public static DoubleValue greenLowerRange; + public static DoubleValue yellowLowerRange; + public static DoubleValue redLowerRange; static { ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder() @@ -44,6 +50,18 @@ public class ConfigImpl { totalVaultPages = builder.comment("Limit for vault page buttons") .defineInRange("totalVaultPages", 255, 1, 255); builder.pop(); + builder.push("honse").comment("Honse Settings"); + precisionPoints = builder.comment("Honse precision points (hi marvel)") + .defineInRange("precisionPoints", 2, 0, 10); + aquaLowerRange = builder.comment("Aqua colored horse rating, lower range") + .defineInRange("precisionPoints", 9.9, 0, 10); + greenLowerRange = builder.comment("Green colored horse rating, lower range") + .defineInRange("precisionPoints", 9.5, 0, 10); + yellowLowerRange = builder.comment("Yellow colored horse rating, lower range") + .defineInRange("precisionPoints", 9.0, 0, 10); + redLowerRange = builder.comment("Red colored horse rating, lower range") + .defineInRange("precisionPoints", 8.0, 0, 10); + builder.pop(); SPEC = builder.build(); } @@ -78,4 +96,24 @@ public static boolean dontRunResidenceCollector() { public static int totalVaultPages() { return totalVaultPages.get(); } + + public static int precisionPoints() { + return precisionPoints.get(); + } + + public static double aquaLowerRange() { + return aquaLowerRange.get(); + } + + public static double greenLowerRange() { + return greenLowerRange.get(); + } + + public static double yellowLowerRange() { + return yellowLowerRange.get(); + } + + public static double redLowerRange() { + return redLowerRange.get(); + } } diff --git a/gradle.properties b/gradle.properties index b342a08..562aee1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx4G org.gradle.parallel=true -mod_version=9.0.2-horse.1 +mod_version=9.0.3-horse.2