Prechádzať zdrojové kódy

Fix conversion of speed and jump values

d4rkm0nkey 4 rokov pred
rodič
commit
0630e385d6

+ 1 - 1
gradle.properties

@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
 	loader_version=0.9.2+build.206
 
 # Mod Properties
-	mod_version = 4.1.0
+	mod_version = 4.1.1
 	maven_group = monkey.lumpy
 	archives_base_name = horse-stats-vanilla
 

+ 2 - 1
src/main/java/monkey/lumpy/horse/stats/vanilla/mixin/AbstractDonkeyEntityMixin.java

@@ -11,6 +11,7 @@ import me.sargunvohra.mcmods.autoconfig1u.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 org.spongepowered.asm.mixin.injection.At;
 
@@ -43,7 +44,7 @@ public class AbstractDonkeyEntityMixin extends HorseBaseEntity {
         if (this.world.isClient && !this.isTame() && player.shouldCancelInteraction() && (config == null || config.isTooltipEnabled())) {
             // Show tooltip
             DecimalFormat df = new DecimalFormat("#.#");
-            String jumpstrength = df.format( 0.695 * (this.getJumpStrength() * 10) - 1.736);
+            String jumpstrength = df.format( Converter.jumpStrengthToJumpHeight(this.getJumpStrength()) );
             String maxHealth = df.format(this.getMaxHealth());
             String speed = df.format( 0.42466 * (this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED) * 100) + 0.112665);            
             

+ 2 - 1
src/main/java/monkey/lumpy/horse/stats/vanilla/mixin/HorseEntityMixin.java

@@ -12,6 +12,7 @@ import me.sargunvohra.mcmods.autoconfig1u.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;
@@ -43,7 +44,7 @@ public abstract class HorseEntityMixin extends HorseBaseEntity {
             DecimalFormat df = new DecimalFormat("#.#");
             String jumpstrength = df.format( 0.695 * (this.getJumpStrength() * 10) - 1.736);
             String maxHealth = df.format(this.getMaxHealth());
-            String speed = df.format( 0.42466 * (this.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED) * 100) + 0.112665);            
+            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();

+ 3 - 2
src/main/java/monkey/lumpy/horse/stats/vanilla/mixin/HorseScreenMixin.java

@@ -16,6 +16,7 @@ import org.spongepowered.asm.mixin.Shadow;
 
 import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
 import monkey.lumpy.horse.stats.vanilla.config.ModConfig;
+import monkey.lumpy.horse.stats.vanilla.util.Converter;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -45,9 +46,9 @@ public abstract class HorseScreenMixin extends HandledScreen<HorseScreenHandler>
             hasChest = true;
         }
         DecimalFormat df = new DecimalFormat("#.#");
-        String jumpstrength = df.format( 0.695 * (this.entity.getJumpStrength() * 10) - 1.736);
+        String jumpstrength = df.format(Converter.jumpStrengthToJumpHeight(this.entity.getJumpStrength()));
         String maxHealth = df.format(this.entity.getMaxHealth());
-        String speed = df.format( 0.42466 * (this.entity.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED) * 100) + 0.112665);
+        String speed = df.format(Converter.genericSpeedToBlocPerSec(this.entity.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)));
 
         // Coloring
         int jumpColor = normalColor;

+ 11 - 0
src/main/java/monkey/lumpy/horse/stats/vanilla/util/Converter.java

@@ -0,0 +1,11 @@
+package monkey.lumpy.horse.stats.vanilla.util;
+
+public class Converter {
+    public static double jumpStrengthToJumpHeight(double strength) {
+        return -0.1817584952 * strength * strength * strength + 3.689713992 * strength * strength + 2.128599134 * strength - 0.343930367;
+    }
+
+    public static double genericSpeedToBlocPerSec(double speed) {
+        return 0.132 * speed * speed + 42.119 * speed;
+    }
+}