This commit is contained in:
kawaiizenbo 2023-03-05 09:34:05 -07:00
parent fa3d84db0e
commit 5981e5ce50
3 changed files with 35 additions and 26 deletions

View file

@ -5,8 +5,8 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.1
loader_version=0.14.11
yarn_mappings=1.19.3+build.5
loader_version=0.14.14
# Mod Properties
mod_version = dev
@ -14,4 +14,4 @@ org.gradle.parallel=true
archives_base_name = moonlight
# Dependencies
fabric_version=0.68.1+1.19.3
fabric_version=0.75.1+1.19.3

View file

@ -1,14 +1,12 @@
package me.kawaiizenbo.moonlight.ui;
import java.math.BigDecimal;
import java.math.RoundingMode;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import me.kawaiizenbo.moonlight.util.MathUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class HUD
@ -27,31 +25,17 @@ public class HUD
textRenderer.drawWithShadow(matrix, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 12, 0x55FFFF);
textRenderer.drawWithShadow(matrix, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 22, 0x55FFFF);
textRenderer.drawWithShadow(matrix, "Meters/s: " + ColorUtils.gray + round(moveSpeed(), 2), 2, scaledHeight - 20, 0x55FFFF);
textRenderer.drawWithShadow(matrix, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, 0x55FFFF);
// Coords
textRenderer.drawWithShadow(matrix, "X: " + ColorUtils.gray + round(mc.player.getX(), 1) +
ColorUtils.reset + " Y: " + ColorUtils.gray + round(mc.player.getY(), 1) +
ColorUtils.reset + " Z: " + ColorUtils.gray + round(mc.player.getZ(), 1), 2, scaledHeight - 10, 0x55FFFF);
}
private static double round(double value, int places)
{
if (places < 0) throw new IllegalArgumentException();
BigDecimal bd = new BigDecimal(Double.toString(value));
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
textRenderer.drawWithShadow(matrix, "X: " + ColorUtils.gray + MathUtils.round(mc.player.getX(), 1) +
ColorUtils.reset + " Y: " + ColorUtils.gray + MathUtils.round(mc.player.getY(), 1) +
ColorUtils.reset + " Z: " + ColorUtils.gray + MathUtils.round(mc.player.getZ(), 1), 2, scaledHeight - 10, 0x55FFFF);
}
private double moveSpeed()
{
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
return Math.abs(length2D(move)) ;
}
public double length2D(Vec3d vec3d)
{
return MathHelper.sqrt((float)(vec3d.x * vec3d.x + vec3d.z * vec3d.z));
return Math.abs(MathUtils.length2D(move)) ;
}
}

View file

@ -0,0 +1,25 @@
package me.kawaiizenbo.moonlight.util;
import java.math.BigDecimal;
import java.math.RoundingMode;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class MathUtils
{
public static double round(double value, int places)
{
if (places < 0) throw new IllegalArgumentException();
BigDecimal bd = new BigDecimal(Double.toString(value));
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
}
public static double length2D(Vec3d vec3d)
{
return MathHelper.sqrt((float)(vec3d.x * vec3d.x + vec3d.z * vec3d.z));
}
}