Skip to content

Commit

Permalink
honse sacrifice for the honse gods
Browse files Browse the repository at this point in the history
  • Loading branch information
triphora committed Sep 3, 2024
1 parent 4e0ea73 commit 328e01a
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 8 deletions.
25 changes: 25 additions & 0 deletions common/src/main/java/coffee/waffle/emcutils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
});
Expand Down Expand Up @@ -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;
}
}
7 changes: 6 additions & 1 deletion common/src/main/resources/assets/emcutils/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
25 changes: 25 additions & 0 deletions fabric/src/main/java/coffee/waffle/emcutils/fabric/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
38 changes: 38 additions & 0 deletions forge/src/main/java/coffee/waffle/emcutils/forge/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,6 +19,11 @@ public class ConfigImpl {
public static EnumValue<ChatAlertSound> 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()
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 328e01a

Please sign in to comment.