diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ca3795..0900f62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: matrix: # Use these Java versions java: [ - 17, # Current Java LTS & minimum supported by Minecraft + 21, # Current Java LTS & minimum supported by Minecraft ] # and run on both Linux and Windows os: [ubuntu-22.04, windows-2022] @@ -33,7 +33,7 @@ jobs: - name: build run: ./gradlew build - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS uses: actions/upload-artifact@v3 with: name: Artifacts diff --git a/build.gradle b/build.gradle index fc40a0a..a7b49cb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.4-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } @@ -38,9 +38,9 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modApi "com.terraformersmc:modmenu:8.0.0" - modImplementation include("io.github.cottonmc:LibGui:9.0.0+1.20.2") - modApi include ("me.shedaniel.cloth:cloth-config-fabric:12.0.109") + modApi "com.terraformersmc:modmenu:10.0.0-beta.1" + modImplementation include("io.github.cottonmc:LibGui:10.0.0+1.20.6") + modApi include ("me.shedaniel.cloth:cloth-config-fabric:14.0.126") } processResources { @@ -52,7 +52,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } java { @@ -61,8 +61,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index 847fe18..d70c32f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 -loader_version=0.14.24 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.3 +loader_version=0.15.11 -#Fabric api -fabric_version=0.90.4+1.20.2 +# Fabric API +fabric_version=0.99.4+1.20.6 # Mod Properties -mod_version=4.5.0 +mod_version=4.7.0 maven_group=monkey.lumpy archives_base_name=horse-stats-vanilla diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..e644113 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cf58316..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/HorseStatsVanilla.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/HorseStatsVanilla.java deleted file mode 100644 index adb70e7..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/HorseStatsVanilla.java +++ /dev/null @@ -1,13 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla; - -import net.fabricmc.api.ModInitializer; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; - -public class HorseStatsVanilla implements ModInitializer { - @Override - public void onInitialize() { - AutoConfig.register(ModConfig.class, JanksonConfigSerializer::new); - } -} \ No newline at end of file diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/ModMenuApiImpl.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/ModMenuApiImpl.java deleted file mode 100644 index cd02484..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/ModMenuApiImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; - -import me.shedaniel.autoconfig.AutoConfig; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import net.fabricmc.api.Environment; -import net.fabricmc.api.EnvType; - -@Environment(EnvType.CLIENT) -public class ModMenuApiImpl implements ModMenuApi { - - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent).get(); - } -} \ No newline at end of file diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/config/ModConfig.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/config/ModConfig.java deleted file mode 100644 index 7f41de8..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/config/ModConfig.java +++ /dev/null @@ -1,108 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.config; - -import me.shedaniel.autoconfig.ConfigData; -import me.shedaniel.autoconfig.annotation.Config; -import me.shedaniel.autoconfig.annotation.ConfigEntry; -import me.shedaniel.autoconfig.annotation.ConfigEntry.Category; -import me.shedaniel.math.Color; - -@Config(name = "horsestatsvanilla") -public class ModConfig implements ConfigData { - - private boolean showValue = true; - @ConfigEntry.Gui.Tooltip - private boolean showMaxMin = false; - @ConfigEntry.Gui.Tooltip - private boolean enableTooltip = true; - private boolean valueUp = false; - @ConfigEntry.Gui.Tooltip - private boolean useColors = true; - - @ConfigEntry.ColorPicker(allowAlpha = true) - private int goodColor = 0xff00b400; - @ConfigEntry.ColorPicker(allowAlpha = true) - private int neutralColor = 0xff464646; - @ConfigEntry.ColorPicker(allowAlpha = true) - private int badColor = 0xffff0000; - - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float goodHorseJumpValue = 4; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float badHorseJumpValue = 2.5f; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float goodHorseSpeedValue = 11; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float badHorseSpeedValue = 7; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float goodHorseHeartsValue = 25; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float badHorseHeartsValue = 20; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float goodStrengthValue = 9; - @Category("coloring") - @ConfigEntry.Gui.Tooltip - private float badStrengthValue = 6; - - public boolean showValue() { return showValue; } - - public boolean useColors() { return useColors; } - - public boolean showMaxMin() { return showMaxMin; } - - public boolean valueUp() { return valueUp; } - - public boolean isTooltipEnabled() { - return enableTooltip; - } - - public float getGoodHorseJumpValue() { - return goodHorseJumpValue; - } - - public float getBadHorseJumpValue() { - return badHorseJumpValue; - } - - public float getGoodHorseSpeedValue() { - return goodHorseSpeedValue; - } - - public float getBadHorseSpeedValue() { - return badHorseSpeedValue; - } - - public float getGoodHorseHeartsValue() { - return goodHorseHeartsValue; - } - - public float getBadHorseHeartsValue() { - return badHorseHeartsValue; - } - - public float getGoodStrengthValue() { - return goodStrengthValue; - } - - public float getBadStrengthValue() { - return badStrengthValue; - } - - public Color getGoodColor() { - return Color.ofOpaque(goodColor); - } - - public Color getNeutralColor() { - return Color.ofOpaque(neutralColor); - } - - public Color getBadColor() { - return Color.ofOpaque(badColor); - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/ToolTipGui.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/ToolTipGui.java deleted file mode 100644 index 8ab1bcc..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/ToolTipGui.java +++ /dev/null @@ -1,28 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.gui; - -import io.github.cottonmc.cotton.gui.GuiDescription; -import io.github.cottonmc.cotton.gui.client.CottonClientScreen; - -public class ToolTipGui extends CottonClientScreen { - - public ToolTipGui(GuiDescription description) { - super(description); - } - - @Override - public boolean keyPressed(int ch, int keyCode, int modifiers) { - if(keyCode == 26) { - close(); - } - return super.keyPressed(ch, keyCode, modifiers); - } - - @Override - public boolean keyReleased(int ch, int keyCode, int modifiers) { - if(keyCode == 50) { - close(); - } - return super.keyReleased(ch, keyCode, modifiers); - } - -} \ No newline at end of file diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/Tooltip.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/Tooltip.java deleted file mode 100644 index 16169ff..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/Tooltip.java +++ /dev/null @@ -1,68 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.gui; - -import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; -import io.github.cottonmc.cotton.gui.widget.WBox; -import io.github.cottonmc.cotton.gui.widget.WLabel; -import io.github.cottonmc.cotton.gui.widget.data.Axis; -import io.github.cottonmc.cotton.gui.widget.data.Insets; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.math.Color; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import net.minecraft.text.Text; - -public class Tooltip extends LightweightGuiDescription { - private ModConfig config; - - public Tooltip(double speed, double jump, int health) { - super(); - config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - WBox root = new WBox(Axis.VERTICAL); - setRootPanel(root); - root.setSpacing(-8); - root.setInsets(new Insets(5,5,0,5)); - - // Coloring - Color jumpColor = config.getNeutralColor(); - Color speedColor = config.getNeutralColor(); - Color hearthColor = config.getNeutralColor(); - if(config == null || config.useColors()) { - if(jump > config.getGoodHorseJumpValue()) {jumpColor = config.getGoodColor();} - else if (jump < config.getBadHorseJumpValue()) {jumpColor = config.getBadColor();} - - if(speed > config.getGoodHorseSpeedValue()) {speedColor = config.getGoodColor();} - else if (speed < config.getBadHorseSpeedValue()) {speedColor = config.getBadColor();} - - if(health> config.getGoodHorseHeartsValue()) {hearthColor = config.getGoodColor();} - else if (health < config.getBadHorseHeartsValue()) {hearthColor = config.getBadColor();} - } - - WBox speedBox = new WBox(Axis.HORIZONTAL); - - WLabel speedSymbol = new WLabel(Text.literal("➟"), speedColor.hashCode()); - WLabel speedLabel = new WLabel(Text.literal(String.valueOf(speed)), speedColor.hashCode()); - - speedBox.add(speedSymbol); - speedBox.add(speedLabel); - - WBox jumpBox = new WBox(Axis.HORIZONTAL); - - WLabel jumpSymbol = new WLabel(Text.literal("⇮"), jumpColor.hashCode()); - WLabel jumpLabel = new WLabel(Text.literal(String.valueOf(jump)), jumpColor.hashCode()); - - jumpBox.add(jumpSymbol); - jumpBox.add(jumpLabel); - - WBox healthBox = new WBox(Axis.HORIZONTAL); - - WLabel healthSymbol = new WLabel(Text.literal("♥"), hearthColor.hashCode()); - WLabel healthLabel = new WLabel(Text.literal(String.valueOf(health)), hearthColor.hashCode()); - - healthBox.add(healthSymbol); - healthBox.add(healthLabel); - - root.add(speedBox); - root.add(jumpBox); - root.add(healthBox); - root.validate(this); - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/TooltipDonkey.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/TooltipDonkey.java deleted file mode 100644 index 231a077..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/gui/TooltipDonkey.java +++ /dev/null @@ -1,82 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.gui; - -import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; -import io.github.cottonmc.cotton.gui.widget.WBox; -import io.github.cottonmc.cotton.gui.widget.WLabel; -import io.github.cottonmc.cotton.gui.widget.data.Axis; -import io.github.cottonmc.cotton.gui.widget.data.Insets; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.math.Color; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import net.minecraft.text.Text; - -public class TooltipDonkey extends LightweightGuiDescription { - private ModConfig config; - - public TooltipDonkey(double speed, double jump, int health, int strength) { - super(); - config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - WBox root = new WBox(Axis.VERTICAL); - setRootPanel(root); - root.setSpacing(-8); - root.setInsets(new Insets(5,5,0,5)); - - // Coloring - Color jumpColor = config.getNeutralColor(); - Color speedColor = config.getNeutralColor(); - Color hearthColor = config.getNeutralColor(); - Color strengthColor = config.getNeutralColor(); - if(config == null || config.useColors()) { - assert config != null; - if(jump > config.getGoodHorseJumpValue()) {jumpColor = config.getGoodColor();} - else if (jump < config.getBadHorseJumpValue()) {jumpColor = config.getBadColor();} - - if(speed > config.getGoodHorseSpeedValue()) {speedColor = config.getGoodColor();} - else if (speed < config.getBadHorseSpeedValue()) {speedColor = config.getBadColor();} - - if(health> config.getGoodHorseHeartsValue()) {hearthColor = config.getGoodColor();} - else if (health < config.getBadHorseHeartsValue()) {hearthColor = config.getBadColor();} - - if(strength> config.getGoodStrengthValue()) {strengthColor = config.getGoodColor();} - else if (strength < config.getBadStrengthValue()) {strengthColor = config.getBadColor();} - } - - WBox speedBox = new WBox(Axis.HORIZONTAL); - - WLabel speedSymbol = new WLabel(Text.literal("➟"), speedColor.hashCode()); - WLabel speedLabel = new WLabel(Text.literal(String.valueOf(speed)), speedColor.hashCode()); - - speedBox.add(speedSymbol); - speedBox.add(speedLabel); - - WBox jumpBox = new WBox(Axis.HORIZONTAL); - - WLabel jumpSymbol = new WLabel(Text.literal("⇮"), jumpColor.hashCode()); - WLabel jumpLabel = new WLabel(Text.literal(String.valueOf(jump)), jumpColor.hashCode()); - - jumpBox.add(jumpSymbol); - jumpBox.add(jumpLabel); - - WBox healthBox = new WBox(Axis.HORIZONTAL); - - WLabel healthSymbol = new WLabel(Text.literal("♥"), hearthColor.hashCode()); - WLabel healthLabel = new WLabel(Text.literal(String.valueOf(health)), hearthColor.hashCode()); - - healthBox.add(healthSymbol); - healthBox.add(healthLabel); - - WBox strengthBox = new WBox(Axis.HORIZONTAL); - - WLabel strengthSymbol = new WLabel(Text.literal("▦"), strengthColor.hashCode()); - WLabel strengthLabel = new WLabel(Text.literal(String.valueOf(strength)), strengthColor.hashCode()); - - strengthBox.add(strengthSymbol); - strengthBox.add(strengthLabel); - - root.add(speedBox); - root.add(jumpBox); - root.add(healthBox); - root.add(strengthBox); - root.validate(this); - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/AbstractDonkeyEntityMixin.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/AbstractDonkeyEntityMixin.java deleted file mode 100644 index 6bcc2de..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/AbstractDonkeyEntityMixin.java +++ /dev/null @@ -1,65 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.mixin; - -import com.ibm.icu.math.BigDecimal; -import com.ibm.icu.text.DecimalFormat; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import me.shedaniel.autoconfig.AutoConfig; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import monkey.lumpy.horse.stats.vanilla.gui.ToolTipGui; -import monkey.lumpy.horse.stats.vanilla.gui.TooltipDonkey; -import monkey.lumpy.horse.stats.vanilla.util.Converter; - -import org.spongepowered.asm.mixin.injection.At; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.passive.AbstractDonkeyEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.world.World; - -@Mixin(AbstractDonkeyEntity.class) -public abstract class AbstractDonkeyEntityMixin extends AbstractHorseEntity { - @Shadow public abstract int getInventoryColumns(); - - private ModConfig config; - - protected AbstractDonkeyEntityMixin(EntityType entityType, World world) { - super(entityType, world); - } - - - @Inject(at = @At("HEAD"), method = "interactMob") - public ActionResult interactMob(PlayerEntity player, Hand hand, CallbackInfoReturnable ret) { - if(config == null) { - config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - } - - if (config.showValue() && this.world.isClient && !this.isTame() && player.shouldCancelInteraction() && (config == null || config.isTooltipEnabled())) { - // Show tooltip - DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getJumpStrength()) ); - String maxHealth = df.format(this.getMaxHealth()); - String strength = df.format(3L * this.getInventoryColumns()); - String speed = df.format(Converter.genericSpeedToBlocPerSec(this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); - - double jumpValue = new BigDecimal(jumpStrength.replace(',', '.')).doubleValue(); - double speedValue = new BigDecimal(speed.replace(',', '.')).doubleValue(); - int healthValue = new BigDecimal(maxHealth.replace(',', '.')).intValue(); - int strengthValue = new BigDecimal(strength.replace(',', '.')).intValue(); - - MinecraftClient.getInstance().setScreen( - new ToolTipGui(new TooltipDonkey(speedValue, jumpValue, healthValue, strengthValue)) - ); - } - return ret.getReturnValue(); - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseEntityMixin.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseEntityMixin.java deleted file mode 100644 index 1022f13..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseEntityMixin.java +++ /dev/null @@ -1,59 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.mixin; - -import java.math.BigDecimal; -import java.text.DecimalFormat; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import me.shedaniel.autoconfig.AutoConfig; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import monkey.lumpy.horse.stats.vanilla.gui.ToolTipGui; -import monkey.lumpy.horse.stats.vanilla.gui.Tooltip; -import monkey.lumpy.horse.stats.vanilla.util.Converter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.passive.HorseEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.world.World; - -@Mixin(HorseEntity.class) -public abstract class HorseEntityMixin extends AbstractHorseEntity { - - private ModConfig config; - - protected HorseEntityMixin(EntityType entityType, World world) { - super(entityType, world); - } - - - @Inject(at = @At("HEAD"), method = "interactMob") - public ActionResult interactMob(PlayerEntity player, Hand hand, CallbackInfoReturnable ret) { - if(config == null) { - config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - } - - if (config.showValue() && this.world.isClient && !this.isTame() && player.shouldCancelInteraction() && (config == null || config.isTooltipEnabled())) { - // Show tooltip - DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getJumpStrength()) ); - String maxHealth = df.format(this.getMaxHealth()); - String speed = df.format(Converter.genericSpeedToBlocPerSec(this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); - - double jumpValue = new BigDecimal(jumpStrength.replace(',', '.')).doubleValue(); - double speedValue = new BigDecimal(speed.replace(',', '.')).doubleValue(); - int healthValue = new BigDecimal(maxHealth.replace(',', '.')).intValue(); - - MinecraftClient.getInstance().setScreen( - new ToolTipGui(new Tooltip(speedValue, jumpValue, healthValue)) - ); - } - return ret.getReturnValue(); - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseScreenMixin.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseScreenMixin.java deleted file mode 100644 index 4b30496..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/mixin/HorseScreenMixin.java +++ /dev/null @@ -1,118 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.mixin; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.HorseScreen; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.passive.AbstractDonkeyEntity; -import net.minecraft.entity.passive.AbstractHorseEntity; -import net.minecraft.entity.passive.LlamaEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.HorseScreenHandler; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.math.Color; -import monkey.lumpy.horse.stats.vanilla.config.ModConfig; -import monkey.lumpy.horse.stats.vanilla.util.Converter; - -import java.math.BigDecimal; -import java.text.DecimalFormat; - -@Mixin(HorseScreen.class) -public abstract class HorseScreenMixin extends HandledScreen { - @Shadow - @Final - private AbstractHorseEntity entity; - private ModConfig config; - - public HorseScreenMixin(HorseScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); - } - - protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { - super.drawForeground(matrices, mouseX, mouseY); - if(config == null) { - config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - } - if (config.showValue()) { - boolean hasChest = AbstractDonkeyEntity.class.isAssignableFrom(this.entity.getClass()) && ((AbstractDonkeyEntity) this.entity).hasChest(); - DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format(Converter.jumpStrengthToJumpHeight(this.entity.getJumpStrength())); - String maxHealth = df.format(this.entity.getMaxHealth()); - String speed = df.format(Converter.genericSpeedToBlocPerSec(this.entity.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); - - // Coloring - Color jumpColor = config.getNeutralColor(); - Color speedColor = config.getNeutralColor(); - Color hearthColor = config.getNeutralColor(); - if(config.useColors()) { - double jumpValue = new BigDecimal(jumpStrength.replace(',', '.')).doubleValue(); - double speedValue = new BigDecimal(speed.replace(',', '.')).doubleValue(); - double healthValue = new BigDecimal(maxHealth.replace(',', '.')).doubleValue(); - - if(jumpValue > config.getGoodHorseJumpValue()) {jumpColor = config.getGoodColor();} - else if (jumpValue < config.getBadHorseJumpValue()) {jumpColor = config.getBadColor();} - - if(speedValue > config.getGoodHorseSpeedValue()) {speedColor = config.getGoodColor();} - else if (speedValue < config.getBadHorseSpeedValue()) {speedColor = config.getBadColor();} - - if(healthValue > config.getGoodHorseHeartsValue()) {hearthColor = config.getGoodColor();} - else if (healthValue < config.getBadHorseHeartsValue()) {hearthColor = config.getBadColor();} - } - - if (config.valueUp()) { - if (config.showMaxMin()) { - this.textRenderer.draw(matrices, "➟ " + speed, 87.0F, 6.0F, speedColor.hashCode()); - this.textRenderer.draw(matrices, "⇮ " + jumpStrength, 122.0F, 6.0F, jumpColor.hashCode()); - this.textRenderer.draw(matrices, "♥ " + maxHealth, 147.0F, 6.0F, hearthColor.hashCode()); - this.textRenderer.draw(matrices, "➟ (4.7-14.2)", 180.0F, 30.0F, config.getNeutralColor().hashCode()); - this.textRenderer.draw(matrices, "⇮ (1-5.3)", 180.0F, 40.0F, config.getNeutralColor().hashCode()); - this.textRenderer.draw(matrices, "♥ (15-30)", 180F, 50.0F, config.getNeutralColor().hashCode()); - } else { - this.textRenderer.draw(matrices, "➟ " + speed, 87.0F, 6.0F, speedColor.hashCode()); - this.textRenderer.draw(matrices, "⇮ " + jumpStrength, 122.0F, 6.0F, jumpColor.hashCode()); - this.textRenderer.draw(matrices, "♥ " + maxHealth, 147.0F, 6.0F, hearthColor.hashCode()); - } - } else if (!hasChest) { - if (config.showMaxMin()) { - this.textRenderer.draw(matrices, "(4.7-14.2)", 119.0F, 26.0F, config.getNeutralColor().hashCode()); - this.textRenderer.draw(matrices, "(1-5.3)", 119.0F, 36.0F, config.getNeutralColor().hashCode()); - this.textRenderer.draw(matrices, "(15-30)", 119.0F, 46.0F, config.getNeutralColor().hashCode()); - } - this.textRenderer.draw(matrices, "➟", 82.0F, 26.0F, speedColor.hashCode()); - this.textRenderer.draw(matrices, speed, 93.0F, 26.0F, speedColor.hashCode()); - this.textRenderer.draw(matrices, "⇮", 84.0F, 36.0F, jumpColor.hashCode()); - this.textRenderer.draw(matrices, jumpStrength, 93.0F, 36.0F, jumpColor.hashCode()); - this.textRenderer.draw(matrices, "♥", 83.0F, 46.0F, hearthColor.hashCode()); - this.textRenderer.draw(matrices, maxHealth, 93.0F, 46.0F, hearthColor.hashCode()); - } else { - this.textRenderer.draw(matrices, "➟ " + speed, 80.0F, 6.0F, speedColor.hashCode()); - this.textRenderer.draw(matrices, "⇮ " + jumpStrength, 115.0F, 6.0F, jumpColor.hashCode()); - this.textRenderer.draw(matrices, "♥ " + maxHealth, 140.0F, 6.0F, hearthColor.hashCode()); - } - - Color strengthColor = config.getNeutralColor(); - - if (LlamaEntity.class.isAssignableFrom(this.entity.getClass())) { - int strength = 3 * ((LlamaEntity) this.entity).getStrength(); - - if(config.useColors()) { - if(strength > config.getGoodHorseJumpValue()) {strengthColor = config.getGoodColor();} - else if (strength < config.getBadHorseJumpValue()) {strengthColor = config.getBadColor();} - } - if (!hasChest) { - if (config.valueUp()) { - this.textRenderer.draw(matrices, "▦ " + strength, 62.0F, 6.0F, strengthColor.hashCode()); - } else { - this.textRenderer.draw(matrices, "▦", 83.0F, 56.0F, strengthColor.hashCode()); - this.textRenderer.draw(matrices, "" + strength, 93.0F, 56.0F, strengthColor.hashCode()); - } - } - } - } - } -} diff --git a/remappedSrc/monkey/lumpy/horse/stats/vanilla/util/Converter.java b/remappedSrc/monkey/lumpy/horse/stats/vanilla/util/Converter.java deleted file mode 100644 index dc9c470..0000000 --- a/remappedSrc/monkey/lumpy/horse/stats/vanilla/util/Converter.java +++ /dev/null @@ -1,17 +0,0 @@ -package monkey.lumpy.horse.stats.vanilla.util; - -public class Converter { - public static double jumpStrengthToJumpHeight(double strength) { - double height = 0; - double velocity = strength; - while(velocity > 0) { - height += velocity; - velocity = (velocity - .08) * .98 * .98; - } - return height; - } - - public static double genericSpeedToBlocPerSec(double speed) { - return 42.157796 * speed; - } -} diff --git a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/AbstractDonkeyEntityMixin.java b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/AbstractDonkeyEntityMixin.java index 74496f8..98ef9e9 100644 --- a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/AbstractDonkeyEntityMixin.java +++ b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/AbstractDonkeyEntityMixin.java @@ -46,7 +46,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand, CallbackInfoRetu if (config.showValue() && !this.isTame() && player.shouldCancelInteraction() && (config == null || config.isTooltipEnabled())) { // Show tooltip DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getJumpStrength()) ); + String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getAttributeValue(EntityAttributes.GENERIC_JUMP_STRENGTH)) ); String maxHealth = df.format(this.getMaxHealth()); String strength = df.format(3L * this.getInventoryColumns()); String speed = df.format(Converter.genericSpeedToBlocPerSec(this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); diff --git a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseEntityMixin.java b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseEntityMixin.java index 80e7c24..0f3ff27 100644 --- a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseEntityMixin.java +++ b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseEntityMixin.java @@ -42,7 +42,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand, CallbackInfoRetu if (config.showValue() && !this.isTame() && player.shouldCancelInteraction() && (config == null || config.isTooltipEnabled())) { // Show tooltip DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getJumpStrength()) ); + String jumpStrength = df.format( Converter.jumpStrengthToJumpHeight(this.getAttributeValue(EntityAttributes.GENERIC_JUMP_STRENGTH)) ); String maxHealth = df.format(this.getMaxHealth()); String speed = df.format(Converter.genericSpeedToBlocPerSec(this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); diff --git a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseScreenMixin.java b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseScreenMixin.java index f8ea61d..70c236b 100644 --- a/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseScreenMixin.java +++ b/src/client/java/monkey/lumpy/horse/stats/vanilla/mixin/client/HorseScreenMixin.java @@ -41,7 +41,7 @@ protected void drawForeground(DrawContext drawContext, int mouseX, int mouseY) { if (config.showValue()) { boolean hasChest = AbstractDonkeyEntity.class.isAssignableFrom(this.entity.getClass()) && ((AbstractDonkeyEntity) this.entity).hasChest(); DecimalFormat df = new DecimalFormat("#.#"); - String jumpStrength = df.format(Converter.jumpStrengthToJumpHeight(this.entity.getJumpStrength())); + String jumpStrength = df.format(Converter.jumpStrengthToJumpHeight(this.entity.getAttributeValue(EntityAttributes.GENERIC_JUMP_STRENGTH))); String maxHealth = df.format(this.entity.getMaxHealth()); String speed = df.format(Converter.genericSpeedToBlocPerSec(this.entity.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); diff --git a/src/client/resources/horsestatsvanilla.client.mixins.json b/src/client/resources/horsestatsvanilla.client.mixins.json index 70e6721..593ecf9 100644 --- a/src/client/resources/horsestatsvanilla.client.mixins.json +++ b/src/client/resources/horsestatsvanilla.client.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "monkey.lumpy.horse.stats.vanilla.mixin.client", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "client": [ "HorseScreenMixin", "HorseEntityMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 48ae981..c2e2d75 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,9 +28,9 @@ } ], "depends": { - "fabricloader": ">=0.14.21", - "java": ">=17", - "minecraft": ">=1.20.2", + "fabricloader": ">=0.15.11", + "java": ">=21", + "minecraft": ">=1.20.6", "fabric-api": "*" }, "suggests": {