diff --git a/src/main/java/net/foxes4life/foxclient/MainClient.java b/src/main/java/net/foxes4life/foxclient/MainClient.java index 46a65e2..14b1227 100644 --- a/src/main/java/net/foxes4life/foxclient/MainClient.java +++ b/src/main/java/net/foxes4life/foxclient/MainClient.java @@ -5,7 +5,6 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.foxes4life.foxclient.configuration.FoxClientSetting; -import net.foxes4life.foxclient.networking.Networking; import net.foxes4life.foxclient.rpc.DiscordInstance; import net.foxes4life.foxclient.rpc.DiscordMinecraftClient; import net.foxes4life.foxclient.rpc.PresenceUpdater; @@ -17,15 +16,18 @@ import org.lwjgl.glfw.GLFW; + + public class MainClient implements ClientModInitializer { - private static final KeyBinding toggleHud = new KeyBinding("key.foxclient.toggle_hud", GLFW.GLFW_KEY_F6, "category.foxclient.main"); + private static final KeyBinding toggleInfoHud = new KeyBinding("key.foxclient.toggle-info-hud", GLFW.GLFW_KEY_F6, "category.foxclient.main"); private static final KeyBinding clientConfig = new KeyBinding("key.foxclient.configKey", GLFW.GLFW_KEY_RIGHT_CONTROL, "category.foxclient.main"); + public static long deltaTime = 0; @Override public void onInitializeClient() { ZoomUtils.initZoom(); FreelookUtils.init(); - KeyBindingHelper.registerKeyBinding(toggleHud); + KeyBindingHelper.registerKeyBinding(toggleInfoHud); KeyBindingHelper.registerKeyBinding(clientConfig); ClientLifecycleEvents.CLIENT_STARTED.register(client -> { @@ -36,7 +38,7 @@ public void onInitializeClient() { }); ClientTickEvents.END_CLIENT_TICK.register(client -> { - while (toggleHud.wasPressed()) { + while (toggleInfoHud.wasPressed()) { Main.config.set(FoxClientSetting.HudEnabled, !Main.config.get(FoxClientSetting.HudEnabled, Boolean.class)); Main.config.save(); } @@ -44,7 +46,7 @@ public void onInitializeClient() { ClientTickEvents.START_CLIENT_TICK.register(client -> { while (clientConfig.wasPressed()) { - MinecraftClient.getInstance().setScreen(new FoxClientSettingsScreen()); + MinecraftClient.getInstance().setScreen(new FoxClientSettingsScreen(false)); } }); diff --git a/src/main/java/net/foxes4life/foxclient/configuration/FoxClientConfigManager.java b/src/main/java/net/foxes4life/foxclient/configuration/FoxClientConfigManager.java index 43b7831..dbaf33e 100644 --- a/src/main/java/net/foxes4life/foxclient/configuration/FoxClientConfigManager.java +++ b/src/main/java/net/foxes4life/foxclient/configuration/FoxClientConfigManager.java @@ -34,5 +34,7 @@ public void initializeDefaults() { setDefault(FoxClientSetting.ArmorHudEnabled, false); setDefault(FoxClientSetting.ArmorHudDisplayPercentage, false); + setDefault(FoxClientSetting.BlockHudEnabled, true); + setDefault(FoxClientSetting.BlockHudAnimations, true); } } diff --git a/src/main/java/net/foxes4life/foxclient/configuration/FoxClientSetting.java b/src/main/java/net/foxes4life/foxclient/configuration/FoxClientSetting.java index a978035..673cf28 100644 --- a/src/main/java/net/foxes4life/foxclient/configuration/FoxClientSetting.java +++ b/src/main/java/net/foxes4life/foxclient/configuration/FoxClientSetting.java @@ -25,5 +25,8 @@ public enum FoxClientSetting { HudBiome, ArmorHudEnabled, - ArmorHudDisplayPercentage + ArmorHudDisplayPercentage, + + BlockHudEnabled, + BlockHudAnimations } diff --git a/src/main/java/net/foxes4life/foxclient/gui/ArmorHud.java b/src/main/java/net/foxes4life/foxclient/gui/ArmorHud.java index d32a149..875a40a 100644 --- a/src/main/java/net/foxes4life/foxclient/gui/ArmorHud.java +++ b/src/main/java/net/foxes4life/foxclient/gui/ArmorHud.java @@ -5,16 +5,18 @@ import net.foxes4life.foxclient.util.draw.Anchor; import net.foxes4life.foxclient.util.draw.AnchoredBounds; import net.foxes4life.foxclient.util.draw.Bounds; +import net.foxes4life.foxclient.util.rendering.ItemRender; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.util.Identifier; -public class ArmorHud extends DrawableHelper { +public class ArmorHud { private final MinecraftClient client; private final TextRenderer fontRenderer; @@ -27,7 +29,7 @@ public ArmorHud(MinecraftClient client) { Main.LOGGER.info(client.getWindow().getScaledWidth() + " " + client.getWindow().getScaledHeight()); } - public void render(MatrixStack matrices) { + public void render(DrawContext context, ItemRender itemRender,) { int width = client.getWindow().getScaledWidth(); int height = client.getWindow().getScaledHeight(); @@ -36,46 +38,38 @@ public void render(MatrixStack matrices) { ClientPlayerEntity player = client.player; if (player == null) return; - ItemRenderer itemRenderer = client.getItemRenderer(); - - renderItem(matrices, player, itemRenderer, EquipmentSlot.MAINHAND, bounds); - renderItem(matrices, player, itemRenderer, EquipmentSlot.OFFHAND, bounds); - renderItem(matrices, player, itemRenderer, EquipmentSlot.HEAD, bounds); - renderItem(matrices, player, itemRenderer, EquipmentSlot.CHEST, bounds); - renderItem(matrices, player, itemRenderer, EquipmentSlot.LEGS, bounds); - renderItem(matrices, player, itemRenderer, EquipmentSlot.FEET, bounds); + renderItem(context, itemRender, player, EquipmentSlot.MAINHAND, bounds); + renderItem(context, itemRender, player, EquipmentSlot.OFFHAND, bounds); + renderItem(context, itemRender, player, EquipmentSlot.HEAD, bounds); + renderItem(context, itemRender, player, EquipmentSlot.CHEST, bounds); + renderItem(context, itemRender, player, EquipmentSlot.LEGS, bounds); + renderItem(context, itemRender, player, EquipmentSlot.FEET, bounds); } - private void renderItem(MatrixStack matrices, ClientPlayerEntity player, ItemRenderer itemRenderer, EquipmentSlot slot, Bounds bounds) { + private void renderItem(DrawContext context, ItemRender itemRender, ClientPlayerEntity player, EquipmentSlot slot, Bounds bounds) { int x = bounds.x; int y = bounds.y; boolean right = slot == EquipmentSlot.OFFHAND || slot == EquipmentSlot.LEGS || slot == EquipmentSlot.FEET; switch (slot) { - case MAINHAND: - break; - case OFFHAND: - x += bounds.width - 16; - break; - case HEAD: - y += 20; - break; - case CHEST: - y += 40; - break; - case LEGS: + case MAINHAND -> { + } + case OFFHAND -> x += bounds.width - 16; + case HEAD -> y += 20; + case CHEST -> y += 40; + case LEGS -> { x += bounds.width - 16; y += 20; - break; - case FEET: + } + case FEET -> { x += bounds.width - 16; y += 40; - break; + } } ItemStack stack = player.getEquippedStack(slot); if (!stack.isEmpty()) { - itemRenderer.renderGuiItemIcon(matrices, stack, x, y); + itemRender.render(x, y, stack); String text = ""; int color = 0xFFFFFF; @@ -116,7 +110,7 @@ private void renderItem(MatrixStack matrices, ClientPlayerEntity player, ItemRen int countWidth = fontRenderer.getWidth(text); int x2 = x + (right ? 20 : -4 - countWidth); - fontRenderer.draw(matrices, text, x2, y + 3, color); + context.drawText(fontRenderer, text, x2, y + 3, color, true); } } } diff --git a/src/main/java/net/foxes4life/foxclient/gui/BlockHUD.java b/src/main/java/net/foxes4life/foxclient/gui/BlockHUD.java new file mode 100644 index 0000000..fe25048 --- /dev/null +++ b/src/main/java/net/foxes4life/foxclient/gui/BlockHUD.java @@ -0,0 +1,116 @@ +package net.foxes4life.foxclient.gui; + +import net.foxes4life.foxclient.Main; +import net.foxes4life.foxclient.MainClient; +import net.foxes4life.foxclient.configuration.FoxClientSetting; +import net.foxes4life.foxclient.util.TextUtils; +import net.foxes4life.foxclient.util.draw.Anchor; +import net.foxes4life.foxclient.util.draw.AnchoredBounds; +import net.foxes4life.foxclient.util.draw.DrawUtils; +import net.foxes4life.foxclient.util.rendering.ItemRender; +import net.minecraft.block.AirBlock; +import net.minecraft.block.Block; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.text.MutableText; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.RaycastContext; + +import java.awt.*; + +public class BlockHud { + private final MinecraftClient client; + private Block lastBlock; + + private float y = 0; + private float width = 0; + + public BlockHud(MinecraftClient client) { + this.client = client; + } + + public void render(DrawContext context, ItemRender itemRender) { + Block block = getBlock(); + boolean show = false; + + if (block != null && !(block instanceof AirBlock)) { + lastBlock = block; + show = true; + } else { + block = lastBlock; + } + + // if the block is still null, we don't want to render anything + if (block == null) return; + + boolean showAnimations = Main.config.get(FoxClientSetting.BlockHudAnimations, Boolean.class); + + float delta = MainClient.deltaTime; +// context.drawText(client.textRenderer, "Draw delta: " + (int)delta + "ms", 10, 10, 0xFFFFFF, false); + + final int padding = 2; + final int border = 3; + final int height = 16; + + final int minY = -height - padding * 2 - border - 2; + int goalY = show ? 0 : minY; + + // transition y position + if (showAnimations) { + y = (float) MathHelper.lerp(Math.exp(-0.01 * delta), goalY, y); + } else { + y = goalY; + } + + // don't even bother if its off screen + if (y == minY) return; + + MutableText text = TextUtils.translatable(block.getTranslationKey()); + int w = client.textRenderer.getWidth(text); + + // transition the width + if (showAnimations) { + width = (float) MathHelper.lerp(Math.exp(-0.01 * delta), w, width); + } else { + width = w; + } + + AnchoredBounds bounds = new AnchoredBounds(0, (int)y, (int)width + 20 + padding * 2, height + padding * 2, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight(), Anchor.TopCenter, Anchor.TopCenter); + Color backgroundColor = new Color(0, 0, 0, .5f); + int backgroundColorInt = backgroundColor.getRGB(); + + DrawUtils.drawRect(context, bounds, backgroundColorInt); + DrawUtils.drawRect(context, bounds.x - border, bounds.y, border, bounds.height, backgroundColorInt); + DrawUtils.drawRect(context, bounds.x + bounds.width, bounds.y, border, bounds.height, backgroundColorInt); + DrawUtils.drawRect(context, bounds.x, bounds.y + bounds.height, bounds.width, border, backgroundColorInt); + + context.drawText(client.textRenderer, text, bounds.x + 20 + padding, bounds.y + 5 + padding, 0xFFFFFF, false); + itemRender.render(bounds.x + padding, bounds.y + padding, new ItemStack(block)); + } + + private Block getBlock() { + ClientWorld world = client.world; + Entity camera = client.getCameraEntity(); + ClientPlayerInteractionManager interactionManager = client.interactionManager; + + if (world == null || camera == null || interactionManager == null) return null; + + float maxRange = interactionManager.getReachDistance(); + float tickDelta = client.getTickDelta(); + + Vec3d viewVector = camera.getRotationVec(tickDelta); + Vec3d startVector = camera.getCameraPosVec(tickDelta); + Vec3d endVector = startVector.add(viewVector.x * maxRange, viewVector.y * maxRange, viewVector.z * maxRange); + + RaycastContext raycastContext = new RaycastContext(startVector, endVector, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.SOURCE_ONLY, camera); + BlockPos blockPos = world.raycast(raycastContext).getBlockPos(); + + return world.getBlockState(blockPos).getBlock(); + } +} diff --git a/src/main/java/net/foxes4life/foxclient/gui/FoxClientHUD.java b/src/main/java/net/foxes4life/foxclient/gui/InfoHUD.java similarity index 55% rename from src/main/java/net/foxes4life/foxclient/gui/FoxClientHUD.java rename to src/main/java/net/foxes4life/foxclient/gui/InfoHUD.java index 753f355..d6b98d0 100644 --- a/src/main/java/net/foxes4life/foxclient/gui/FoxClientHUD.java +++ b/src/main/java/net/foxes4life/foxclient/gui/InfoHUD.java @@ -18,19 +18,21 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; -public class FoxClientHUD extends DrawableHelper { +public class InfoHUD extends DrawableHelper { private final MinecraftClient client; private final TextRenderer fontRenderer; private int boxHeight = 2; private int boxWidth = 98; - private final List textList = Lists.newArrayList(); + private final LinkedHashMap textList = new LinkedHashMap<>(); private static final Identifier FOXCLIENT_TEXT = new Identifier("foxclient", "textures/ui/branding/text.png"); - public FoxClientHUD(MinecraftClient client) { + public InfoHUD(MinecraftClient client) { this.client = client; this.fontRenderer = client.textRenderer; } @@ -39,15 +41,19 @@ public void render(MatrixStack matrices) { boolean drawLogo = Main.config.get(FoxClientSetting.HudLogo, Boolean.class); loadList(drawLogo); + int padding = 2; + int border = 4; + if (Main.config.get(FoxClientSetting.HudBackground, Boolean.class)) { - fill(matrices, 0, 0, boxWidth - 5, boxHeight - 5, 0x45454545); - fill(matrices, boxWidth - 5, 0, boxWidth, boxHeight - 5, 0x45454545); - fill(matrices, 0, boxHeight - 5, boxWidth - 5, boxHeight, 0x45454545); + context.fill(0, 0, boxWidth + padding * 2, boxHeight + padding * 2, 0x80000000); + context.fill(0, boxHeight + padding * 2, boxWidth + padding * 2, boxHeight + padding * 2 + border, 0x80000000); + context.fill(boxWidth + padding * 2, 0, boxWidth + padding * 2 + border, boxHeight + padding * 2, 0x80000000); } // draw logo if (drawLogo) { - boxHeight += 42; + context.drawTexture(FOXCLIENT_TEXT, padding, padding, 0, 48, 96, 48, 96, 48); // todo: figure this out + renderList(context, 40 + padding); RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderTexture(0, FOXCLIENT_TEXT); RenderSystem.enableBlend(); @@ -57,14 +63,14 @@ public void render(MatrixStack matrices) { renderList(matrices, 42); } else { - renderList(matrices, 2); + renderList(matrices, padding); } } void loadList(boolean drawLogo) { textList.clear(); - boxHeight = drawLogo ? 42 : 2; - boxWidth = 98; + boxHeight = drawLogo ? 40 : 0; + boxWidth = 100; boolean version = Main.config.get(FoxClientSetting.HudVersion, Boolean.class); boolean coords = Main.config.get(FoxClientSetting.HudCoordinates, Boolean.class); @@ -77,52 +83,54 @@ void loadList(boolean drawLogo) { if (version) - textList.add(TextUtils.string(Main.SIMPLE_VERSION)); + textList.put("version", TextUtils.string(Main.SIMPLE_VERSION)); if (coords) { assert this.client.player != null; - textList.add(TextUtils.string(String.format("[XYZ] " + (colorcoords ? "§c%s §a%s §9%s" : "%s %s %s"), this.client.player.getBlockPos().getX(), this.client.player.getBlockPos().getY(), this.client.player.getBlockPos().getZ()))); + textList.put("xyz", TextUtils.string(String.format((colorcoords ? "§c%s §a%s §9%s" : "%s %s %s"), this.client.player.getBlockPos().getX(), this.client.player.getBlockPos().getY(), this.client.player.getBlockPos().getZ()))); } if (fps) - textList.add(TextUtils.string("[FPS] " + ClientUtils.getFPS())); + textList.put("fps", TextUtils.string(ClientUtils.getFPS() + "fps")); if (ping) - textList.add(TextUtils.string(String.format("[Ping] " + ClientUtils.getPing() + "ms"))); + textList.put("ping", TextUtils.string(String.format(ClientUtils.getPing() + "ms"))); if (tps) - textList.add(TextUtils.string(String.format("[TPS] " + ServerTickUtils.calculateServerTPS()))); + textList.put("tps", TextUtils.string(String.format(ServerTickUtils.calculateServerTPS() + "tps"))); if (biome) if (client.world != null) { assert client.getCameraEntity() != null; final BlockPos blockPos = client.getCameraEntity().getBlockPos(); - textList.add(TextUtils.string(String.format("[BIOME] " + client.world.getBiome(blockPos).getKey().get().getValue().toString()))); + textList.put("biome", TextUtils.string(String.format(client.world.getBiome(blockPos).getKey().get().getValue().toString()))); } if (server) { if (client.getCurrentServerEntry() != null) { - textList.add(TextUtils.string(String.format("[IP] " + client.getCurrentServerEntry().address))); + textList.put("ip", TextUtils.string(String.format(client.getCurrentServerEntry().address))); } else { - textList.add(TextUtils.string("[IP] " + I18n.translate("menu.singleplayer"))); + textList.put("ip", TextUtils.string(I18n.translate("menu.singleplayer"))); } } - for (Text text : textList) { - boxHeight += 10; - - if (this.client.textRenderer.getWidth(text.getString()) > boxWidth - 8) { - boxWidth = this.client.textRenderer.getWidth(text.getString()) + 8; + for (Map.Entry entry : textList.entrySet()) { + boxHeight += 14; + Text text = entry.getValue(); + boxWidth = Math.max(boxWidth, this.client.textRenderer.getWidth(text.getString()) + 20); + + void renderList (MatrixStack matrices,int offset){ + int i = 0; + for (Map.Entry entry : textList.entrySet()) { + Identifier identifier = new Identifier("foxclient", "textures/ui/info-hud/icons/" + entry.getKey() + ".png"); + Text text = entry.getValue(); + + int y = offset + (14 * i); + context.drawTexture(identifier, 2, y - 1, 0, 0, 16, 16, 16, 16); + context.drawText(this.fontRenderer, text, 22, y + 3, 0xFFFFFFFF, true); + i++; + } } } } - - void renderList(MatrixStack matrices, int offset) { - int i = 0; - for (Text text : textList) { - int y = offset + (10 * i); - this.fontRenderer.draw(matrices, text, 4, y, 0xFFFFFFFF); - i++; - } - } -} +} \ No newline at end of file diff --git a/src/main/java/net/foxes4life/foxclient/mixin/InGameHUDMixin.java b/src/main/java/net/foxes4life/foxclient/mixin/InGameHUDMixin.java index 4628504..34dd6bf 100644 --- a/src/main/java/net/foxes4life/foxclient/mixin/InGameHUDMixin.java +++ b/src/main/java/net/foxes4life/foxclient/mixin/InGameHUDMixin.java @@ -3,11 +3,14 @@ import net.foxes4life.foxclient.Main; import net.foxes4life.foxclient.configuration.FoxClientSetting; import net.foxes4life.foxclient.gui.ArmorHud; -import net.foxes4life.foxclient.gui.FoxClientHUD; +import net.foxes4life.foxclient.gui.BlockHud; +import net.foxes4life.foxclient.gui.InfoHUD; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Final; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -15,21 +18,28 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(InGameHud.class) -public class InGameHUDMixin { +public abstract class InGameHUDMixin { @Shadow @Final private MinecraftClient client; - private static FoxClientHUD foxClientHUD = null; + @Shadow protected abstract void renderHotbarItem(DrawContext context, int x, int y, float pFloat3, PlayerEntity player, ItemStack stack, int seed); + + private static InfoHUD InfoHUD = null; private static ArmorHud armorHud = null; + private static BlockHud blockHud = null; @Inject(at = @At("HEAD"), method = "render") public void render(MatrixStack matrices, float tickDelta, CallbackInfo ci) { if (Main.config.get(FoxClientSetting.HudEnabled, Boolean.class)) { - if (foxClientHUD == null) { - foxClientHUD = new FoxClientHUD(client); + if (InfoHUD == null) { + InfoHUD = new InfoHUD(client); } - foxClientHUD.render(matrices); + InfoHUD.render(matrices); + } + if (Main.config.get(FoxClientSetting.BlockHudEnabled, Boolean.class)) { + if (blockHud == null) blockHud = new BlockHud(client); + blockHud.render(context, (x, y, item) -> renderHotbarItem(context, x, y, tickDelta, client.player, item, 1))); } if (Main.config.get(FoxClientSetting.ArmorHudEnabled, Boolean.class)) { diff --git a/src/main/java/net/foxes4life/foxclient/mixin/LoadingScreenMixin.java b/src/main/java/net/foxes4life/foxclient/mixin/LoadingScreenMixin.java index 3db98f4..f7c185b 100644 --- a/src/main/java/net/foxes4life/foxclient/mixin/LoadingScreenMixin.java +++ b/src/main/java/net/foxes4life/foxclient/mixin/LoadingScreenMixin.java @@ -9,19 +9,14 @@ import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; import net.minecraft.world.chunk.ChunkStatus; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LevelLoadingScreen.class) public abstract class LoadingScreenMixin extends Screen { - @Shadow - @Final - @Mutable + @Shadow @Final @Mutable private WorldGenerationProgressTracker progressProvider; @Shadow @Final @@ -30,6 +25,12 @@ public abstract class LoadingScreenMixin extends Screen { float progress; + @Unique + private double progress = 0.0; + + @Unique + private Progressbar progressbar; + protected LoadingScreenMixin(Text title) { super(title); } @@ -37,17 +38,10 @@ protected LoadingScreenMixin(Text title) { @Inject(method = "render", at = @At("HEAD"), cancellable = true) public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { ci.cancel(); - renderBackground(matrices); - drawTextWithShadow(matrices, textRenderer, TextUtils.string("Loading World... " + MathHelper.clamp(progressProvider.getProgressPercentage(), 0, 100) + "%"), 10, this.height - 22, 0xFFFFFF); - this.progress = MathHelper.lerp(0.88f, progress, this.progress * 0.95F + (progressProvider.getProgressPercentage() / 100f) * 0.2F); - fill(matrices, 0, this.height - 3, (int) (this.width * progress), this.height, 0xFFFFFFFF); - drawChunkThing(matrices, progressProvider); - } - - public void drawChunkThing(MatrixStack matrices, WorldGenerationProgressTracker progressProvider) { - int m = progressProvider.getSize() * 2; - int n = this.width - 5 - m; - int o = this.height - 7 - m; + if (progressbar == null) + progressbar = new Progressbar(this.width / 2 - 75, this.height / 2 + 5, 150, 10); + renderBackground(context); + context.drawCenteredTextWithShadow(textRenderer, TextUtils.string("Loading World... " + progressProvider.getProgressPercentage() + "%"), this.width / 2, this.height / 2 - 10, 0xFFFFFF); for (int r = 0; r < progressProvider.getSize(); ++r) { for (int s = 0; s < progressProvider.getSize(); ++s) { diff --git a/src/main/java/net/foxes4life/foxclient/mixin/MinecraftClientMixin.java b/src/main/java/net/foxes4life/foxclient/mixin/MinecraftClientMixin.java index 2c7e799..0edf982 100644 --- a/src/main/java/net/foxes4life/foxclient/mixin/MinecraftClientMixin.java +++ b/src/main/java/net/foxes4life/foxclient/mixin/MinecraftClientMixin.java @@ -1,6 +1,7 @@ package net.foxes4life.foxclient.mixin; import net.foxes4life.foxclient.Main; +import net.foxes4life.foxclient.MainClient; import net.foxes4life.foxclient.configuration.FoxClientSetting; import net.foxes4life.foxclient.rpc.DiscordMinecraftClient; import net.foxes4life.foxclient.rpc.PresenceUpdater; @@ -14,6 +15,7 @@ import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -84,4 +86,14 @@ public void openPauseMenu(boolean pause, CallbackInfo ci) { } } } + + @Unique + private long lastTime = 0; + + @Inject(at = @At("HEAD"), method = "render") + public void render(boolean tick, CallbackInfo ci) { + long currentTime = System.currentTimeMillis(); + MainClient.deltaTime = currentTime - lastTime; + lastTime = currentTime; + } } diff --git a/src/main/java/net/foxes4life/foxclient/screen/settings/FoxClientSettingsScreen.java b/src/main/java/net/foxes4life/foxclient/screen/settings/FoxClientSettingsScreen.java index efdfb72..d7cef9b 100644 --- a/src/main/java/net/foxes4life/foxclient/screen/settings/FoxClientSettingsScreen.java +++ b/src/main/java/net/foxes4life/foxclient/screen/settings/FoxClientSettingsScreen.java @@ -3,6 +3,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.foxes4life.foxclient.Main; +import net.foxes4life.foxclient.MainClient; import net.foxes4life.foxclient.configuration.FoxClientSetting; import net.foxes4life.foxclient.screen.settings.ui.CategoryButton; import net.foxes4life.foxclient.screen.settings.ui.ToggleButton; @@ -44,16 +45,20 @@ public class FoxClientSettingsScreen extends Screen { private int amountOfDrawableChilds = 0; // set amount of buttons created in init() here (excluding the ones in the loop) private boolean initDone = false; // to prevent amountOfDrawableChilds from increasing after init is done - public FoxClientSettingsScreen() { + private boolean showBackground; + + public FoxClientSettingsScreen(boolean showBackground) { super(TextUtils.string("FoxClient")); + this.showBackground = showBackground; categories = new LinkedHashMap<>(); - categories.put("client", List.of(FoxClientSetting.HudEnabled, FoxClientSetting.ArmorHudEnabled)); + categories.put("client", List.of(FoxClientSetting.HudEnabled, FoxClientSetting.ArmorHudEnabled, FoxClientSetting.BlockHudEnabled)); categories.put("menus", List.of(FoxClientSetting.CustomMainMenu, FoxClientSetting.CustomPauseMenu)); categories.put("misc", List.of(FoxClientSetting.DiscordEnabled, FoxClientSetting.DiscordShowIP, FoxClientSetting.DiscordShowPlayer, FoxClientSetting.SmoothZoom)); categories.put("eastereggs", List.of(FoxClientSetting.UwUfy)); categories.put("ingame-hud", List.of(FoxClientSetting.HudBackground, FoxClientSetting.HudLogo, FoxClientSetting.HudVersion, FoxClientSetting.HudCoordinates, FoxClientSetting.HudCoordinatesColor, FoxClientSetting.HudFPS, FoxClientSetting.HudPing, FoxClientSetting.HudTps, FoxClientSetting.HudServerIP, FoxClientSetting.HudBiome)); categories.put("armor-hud", List.of(FoxClientSetting.ArmorHudDisplayPercentage)); + categories.put("block-hud", List.of(FoxClientSetting.BlockHudAnimations)); } public boolean mouseScrolled(double mouseX, double mouseY, double amount) { @@ -151,15 +156,18 @@ public void close() { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { assert this.client != null; - BackgroundUtils.drawRandomBackground(matrices, this.width, this.height); + if (showBackground) + BackgroundUtils.drawRandomBackground(context, this.width, this.height); fill(matrices, 0, 0, this.width, this.height, 0x44000000); fill(matrices, 0, 0, sidebarWidth, this.height, 0x44000000); + float elapsed = MainClient.deltaTime; + int i = 0; for (Map.Entry> entry : categories.entrySet()) { if (entry.getKey().equals(currentCategory)) { catSelectBgYGoal = (i * 22) + 22; - catSelectBgY = MathHelper.lerp(delta * 1.2, catSelectBgY, catSelectBgYGoal); + catSelectBgY = MathHelper.lerp(Math.exp(-0.02 * elapsed), catSelectBgYGoal, catSelectBgY); fill(matrices, 0, (int) catSelectBgY, sidebarWidth, (int) catSelectBgY + 22, 0x44ffffff); } @@ -170,7 +178,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { if (child instanceof ToggleButton) { if (((ToggleButton) child).isHovered()) { entryHoverBgYGoal = ((ToggleButton) child).getY(); - entryHoverBgY = MathHelper.lerp(delta * 1.2, entryHoverBgY, entryHoverBgYGoal); + entryHoverBgY = MathHelper.lerp(Math.exp(-0.02 * elapsed), entryHoverBgYGoal, entryHoverBgY); fill(matrices, sidebarWidth + 2, (int) entryHoverBgY, this.client.getWindow().getScaledWidth() - 2, (int) entryHoverBgY + 22, 0x44ffffff); } } diff --git a/src/main/java/net/foxes4life/foxclient/screen/title/TitleScreen.java b/src/main/java/net/foxes4life/foxclient/screen/title/TitleScreen.java index 616603d..21f35a3 100644 --- a/src/main/java/net/foxes4life/foxclient/screen/title/TitleScreen.java +++ b/src/main/java/net/foxes4life/foxclient/screen/title/TitleScreen.java @@ -227,7 +227,7 @@ void loadMiniButtons() { } case 5 -> { tex = FOXCLIENT_OPTIONS_BUTTON; - pressAction = (button) -> this.client.setScreen(new FoxClientSettingsScreen()); + pressAction = (button) -> this.client.setScreen(new FoxClientSettingsScreen(true)); x += 30; tooltip = "FoxClient Options"; } diff --git a/src/main/java/net/foxes4life/foxclient/ui/Progressbar.java b/src/main/java/net/foxes4life/foxclient/ui/Progressbar.java new file mode 100644 index 0000000..19fb5d5 --- /dev/null +++ b/src/main/java/net/foxes4life/foxclient/ui/Progressbar.java @@ -0,0 +1,32 @@ +package net.foxes4life.foxclient.ui; + +import net.minecraft.client.gui.DrawContext; + +public class Progressbar { + public int x; + public int y; + public int width; + public int height; + + public Progressbar(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public void render(DrawContext context, double progress) { + int progressWidth = (int)Math.ceil(width * progress); + int cornerSize = (int)(height * .2f); + + context.fill(x + cornerSize, y, x + width - cornerSize, y + cornerSize, 0x33ffffff); + context.fill(x, y + cornerSize, x + width, y + height - cornerSize, 0x33ffffff); + context.fill(x + cornerSize, y + height - cornerSize, x + width - cornerSize, y + height, 0x33ffffff); + + context.fill(x, y + cornerSize, x + progressWidth, y + height - cornerSize, 0xffffffff); + if (progressWidth > cornerSize) { + context.fill(x + cornerSize, y, x + progressWidth - cornerSize, y + cornerSize, 0xffffffff); + context.fill(x + cornerSize, y + height - cornerSize, x + progressWidth - cornerSize, y + height, 0xffffffff); + } + } +} diff --git a/src/main/java/net/foxes4life/foxclient/util/rendering/ItemRender.java b/src/main/java/net/foxes4life/foxclient/util/rendering/ItemRender.java new file mode 100644 index 0000000..deb792a --- /dev/null +++ b/src/main/java/net/foxes4life/foxclient/util/rendering/ItemRender.java @@ -0,0 +1,7 @@ +package net.foxes4life.foxclient.util.rendering; + +import net.minecraft.item.ItemStack; + +public interface ItemRender { + void render(int x, int y, ItemStack item); +} \ No newline at end of file diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/biome.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/biome.png new file mode 100644 index 0000000..4ba3f57 Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/biome.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/fps.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/fps.png new file mode 100644 index 0000000..1655d53 Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/fps.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ip.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ip.png new file mode 100644 index 0000000..fc78356 Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ip.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ping.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ping.png new file mode 100644 index 0000000..0d57192 Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/ping.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/tps.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/tps.png new file mode 100644 index 0000000..61712df Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/tps.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/version.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/version.png new file mode 100644 index 0000000..346d91b Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/version.png differ diff --git a/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/xyz.png b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/xyz.png new file mode 100644 index 0000000..eabe0fc Binary files /dev/null and b/src/main/resources/assets/foxclient/textures/ui/info-hud/icons/xyz.png differ diff --git a/src/main/resources/assets/minecraft/lang/de_de.json b/src/main/resources/assets/minecraft/lang/de_de.json index a1ab02e..ddce1ce 100644 --- a/src/main/resources/assets/minecraft/lang/de_de.json +++ b/src/main/resources/assets/minecraft/lang/de_de.json @@ -22,7 +22,7 @@ "foxclient.rpc.state.multiplayer.hide_ip": "Spielt Mehrspieler", "foxclient.rpc.state.realms": "Spielt auf einem Realm", - "foxclient.config.category.ingame-hud": "In-Game HUD", + "foxclient.config.category.ingame-hud": "Info HUD", "foxclient.config.category.armor-hud": "Rüstungs HUD", "foxclient.config.category.client": "Client", "foxclient.config.category.eastereggs": "EasterEggs", @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Smooth Zoom einschalten", - "foxclient.config.hudenabled": "In-Game HUD einschalten", + "foxclient.config.hudenabled": "Info HUD einschalten", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS", diff --git a/src/main/resources/assets/minecraft/lang/en_us.json b/src/main/resources/assets/minecraft/lang/en_us.json index cd38aac..cda9369 100644 --- a/src/main/resources/assets/minecraft/lang/en_us.json +++ b/src/main/resources/assets/minecraft/lang/en_us.json @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Enable Smooth Zoom", - "foxclient.config.hudenabled" : "Enable In-Game HUD", + "foxclient.config.hudenabled" : "Enable Info HUD", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS", @@ -48,6 +48,9 @@ "foxclient.config.uwufy": "UwUfy", + "foxclient.config.blockhudenabled": "Enable Block HUD", + "foxclient.config.blockhudanimations": "Show slide and scale animations", + "foxclient.config.custommainmenu": "Main Menu", "foxclient.config.custompausemenu": "Pause Menu", diff --git a/src/main/resources/assets/minecraft/lang/es_es.json b/src/main/resources/assets/minecraft/lang/es_es.json index fe7d8c2..dcdd4d8 100644 --- a/src/main/resources/assets/minecraft/lang/es_es.json +++ b/src/main/resources/assets/minecraft/lang/es_es.json @@ -22,7 +22,7 @@ "foxclient.rpc.state.multiplayer.hide_ip": "Jugando a Multijuador", "foxclient.rpc.state.realms": "Jugando en un Realm", - "foxclient.config.category.ingame-hud": "HUD en-juego", + "foxclient.config.category.ingame-hud": "Info HUD", "foxclient.config.category.armor-hud": "HUD de armadura", "foxclient.config.category.client": "Cliente", "foxclient.config.category.eastereggs": "EasterEggs", @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Cambiar Zoom suave", - "foxclient.config.hudenabled" : "Activar HUD en-juego", + "foxclient.config.hudenabled" : "Activar Info HUD", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS", diff --git a/src/main/resources/assets/minecraft/lang/fil_ph.json b/src/main/resources/assets/minecraft/lang/fil_ph.json index 42378ab..9cf9e4f 100644 --- a/src/main/resources/assets/minecraft/lang/fil_ph.json +++ b/src/main/resources/assets/minecraft/lang/fil_ph.json @@ -22,7 +22,7 @@ "foxclient.rpc.state.multiplayer.hide_ip": "Naglalaro ng Multiplayer", "foxclient.rpc.state.realms": "Naglalaro sa Realm", - "foxclient.config.category.ingame-hud": "In-Game HUD", + "foxclient.config.category.ingame-hud": "Info HUD", "foxclient.config.category.armor-hud": "Armor HUD", "foxclient.config.category.client": "Kliente", "foxclient.config.category.eastereggs": "Mga Sekreto", @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Gamitin ang Smooth Zoom", - "foxclient.config.hudenabled" : "Buksan ang In-Game HUD", + "foxclient.config.hudenabled" : "Buksan ang Info HUD", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS", diff --git a/src/main/resources/assets/minecraft/lang/nl_nl.json b/src/main/resources/assets/minecraft/lang/nl_nl.json index 9ee2ae0..5ce208d 100644 --- a/src/main/resources/assets/minecraft/lang/nl_nl.json +++ b/src/main/resources/assets/minecraft/lang/nl_nl.json @@ -22,7 +22,7 @@ "foxclient.rpc.state.multiplayer.hide_ip": "Speelt multiplayer", "foxclient.rpc.state.realms": "Speelt op een Realm", - "foxclient.config.category.ingame-hud": "In-Game HUD", + "foxclient.config.category.ingame-hud": "Info HUD", "foxclient.config.category.armor-hud": "Pantser HUD", "foxclient.config.category.client": "Cliënt", "foxclient.config.category.eastereggs": "EasterEggs", @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Smooth Zoom in/uit schakelen", - "foxclient.config.hudenabled" : "In-Game HUD in/uit schakelen", + "foxclient.config.hudenabled" : "Info HUD in/uit schakelen", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS", diff --git a/src/main/resources/assets/minecraft/lang/tl_ph.json b/src/main/resources/assets/minecraft/lang/tl_ph.json index 42378ab..9cf9e4f 100644 --- a/src/main/resources/assets/minecraft/lang/tl_ph.json +++ b/src/main/resources/assets/minecraft/lang/tl_ph.json @@ -22,7 +22,7 @@ "foxclient.rpc.state.multiplayer.hide_ip": "Naglalaro ng Multiplayer", "foxclient.rpc.state.realms": "Naglalaro sa Realm", - "foxclient.config.category.ingame-hud": "In-Game HUD", + "foxclient.config.category.ingame-hud": "Info HUD", "foxclient.config.category.armor-hud": "Armor HUD", "foxclient.config.category.client": "Kliente", "foxclient.config.category.eastereggs": "Mga Sekreto", @@ -31,7 +31,7 @@ "foxclient.config.smoothzoom": "Gamitin ang Smooth Zoom", - "foxclient.config.hudenabled" : "Buksan ang In-Game HUD", + "foxclient.config.hudenabled" : "Buksan ang Info HUD", "foxclient.config.hudping": "Ping", "foxclient.config.hudtps": "TPS", "foxclient.config.hudfps": "FPS",