From e74f1f8378b45d1056d4c4a01549b2304853275c Mon Sep 17 00:00:00 2001 From: Symo Date: Mon, 15 Apr 2024 22:17:23 +0200 Subject: [PATCH] update --- .../dev/symo/finz/config/ConfigManager.java | 12 +-- .../java/dev/symo/finz/config/FinZConfig.java | 4 +- .../client/SelectedBlockOutLineMixin.java | 4 +- .../client/fastplace/FastPlaceInvoker.java | 4 +- .../java/dev/symo/finz/modules/AModule.java | 4 +- .../dev/symo/finz/modules/ModuleManager.java | 5 -- .../symo/finz/modules/{impl => }/Modules.java | 21 +++++- .../modules/impl/{esp => }/AntiKnockback.java | 8 +- .../symo/finz/modules/impl/ChromaOutline.java | 10 +++ .../finz/modules/impl/MaterialScanner.java | 27 +++---- .../symo/finz/modules/impl/PathTracer.java | 25 +++---- .../modules/impl/WhatTheFAmILookingAt.java | 10 --- .../java/dev/symo/finz/modules/impl/Zoom.java | 21 ++---- .../symo/finz/modules/impl/esp/ItemESP.java | 17 ++--- .../symo/finz/modules/impl/esp/MobEsp.java | 16 ++-- .../symo/finz/modules/impl/esp/PlayerESP.java | 9 --- .../finz/modules/settings/DoubleSetting.java | 13 +--- .../finz/modules/settings/IntSetting.java | 47 ++++++++++++ .../finz/modules/settings/StringSetting.java | 2 +- .../java/dev/symo/finz/ui/ConfigScreen.java | 14 +--- .../dev/symo/finz/ui/ParentUiComponent.java | 51 ++++++++++--- .../java/dev/symo/finz/ui/UiComponent.java | 5 +- .../symo/finz/ui/components/BoxComponent.java | 1 + .../finz/ui/components/ModuleComponent.java | 75 ++++++++++--------- .../finz/ui/components/OptionComponent.java | 5 +- .../finz/ui/components/WidgetContainer.java | 49 ------------ .../java/dev/symo/finz/util/InputType.java | 2 +- 27 files changed, 227 insertions(+), 234 deletions(-) rename src/client/java/dev/symo/finz/modules/{impl => }/Modules.java (71%) rename src/client/java/dev/symo/finz/modules/impl/{esp => }/AntiKnockback.java (86%) create mode 100644 src/client/java/dev/symo/finz/modules/impl/ChromaOutline.java create mode 100644 src/client/java/dev/symo/finz/modules/settings/IntSetting.java delete mode 100644 src/client/java/dev/symo/finz/ui/components/WidgetContainer.java diff --git a/src/client/java/dev/symo/finz/config/ConfigManager.java b/src/client/java/dev/symo/finz/config/ConfigManager.java index ff29759..d24da3c 100644 --- a/src/client/java/dev/symo/finz/config/ConfigManager.java +++ b/src/client/java/dev/symo/finz/config/ConfigManager.java @@ -86,7 +86,7 @@ public static void readConfig(String path) { public static void buildSettings() { // categories - +/* ConfigEntryBuilder entryBuilder = configBuilder.entryBuilder(); // esp @@ -155,7 +155,7 @@ public static void buildSettings() { .setSaveConsumer(newValue -> FinZClient.config.materialScannerMaterial = newValue) .build()); - /*// Fullbright + // Fullbright ConfigCategory fullbright = configBuilder.getOrCreateCategory(Text.translatable("category.finz.fullbright")); fullbright.addEntry(entryBuilder.startBooleanToggle(Text.translatable("option.finz.fullbrightenabled"), FinZClient.config.fullBrightEnabled) .setDefaultValue(false) @@ -165,7 +165,7 @@ public static void buildSettings() { .setDefaultValue(1.0) .setTooltip(Text.of("The gamma level to set when fullbright is enabled.")) .setSaveConsumer(newValue -> FinZClient.config.fullBrightGamma = newValue) - .build());*/ + .build());*//* // ZOOM @@ -199,7 +199,7 @@ public static void buildSettings() { .build()); // auto get block - /*ConfigCategory autoGetBlock = configBuilder.getOrCreateCategory(Text.translatable("category.finz.autogetblock")); + ConfigCategory autoGetBlock = configBuilder.getOrCreateCategory(Text.translatable("category.finz.autogetblock")); autoGetBlock.addEntry(entryBuilder.startBooleanToggle(Text.translatable("option.finz.autogetblock"), FinZClient.config.autoGetBlockEnabled) .setDefaultValue(true) .setTooltip(Text.of("Automatically restocks your hotbar with the block you placed")) @@ -211,13 +211,13 @@ public static void buildSettings() { .setDefaultValue(true) .setTooltip(Text.of("Automatically restocks your hotbar with the tool that broke")) .setSaveConsumer(newValue -> FinZClient.config.autoGetToolEnabled = newValue) - .build());*/ + .build()); // chroma block outline ConfigCategory chromaOutline = configBuilder.getOrCreateCategory(Text.translatable("category.finz.chromaoutline")); chromaOutline.addEntry(entryBuilder.startBooleanToggle(Text.translatable("option.finz.blockoutline"), FinZClient.config.chromaBlockOutlineEnabled) .setDefaultValue(true) .setTooltip(Text.of("Enables chroma block outline")) .setSaveConsumer(newValue -> FinZClient.config.chromaBlockOutlineEnabled = newValue) - .build()); + .build());*/ } } diff --git a/src/client/java/dev/symo/finz/config/FinZConfig.java b/src/client/java/dev/symo/finz/config/FinZConfig.java index 56fa047..ad8fa5d 100644 --- a/src/client/java/dev/symo/finz/config/FinZConfig.java +++ b/src/client/java/dev/symo/finz/config/FinZConfig.java @@ -2,7 +2,7 @@ public class FinZConfig { - public boolean materialScannerEnabled = false; + /*public boolean materialScannerEnabled = false; public int materialScannerRange = 25; public String materialScannerMaterial = "minecraft:ancient_debris"; @@ -28,7 +28,7 @@ public class FinZConfig { public float mobEspRange = 50; public boolean itemEsp; - public float itemEspRange = 50; + public float itemEspRange = 50;*/ //public boolean fullBrightEnabled = false; diff --git a/src/client/java/dev/symo/finz/mixin/client/SelectedBlockOutLineMixin.java b/src/client/java/dev/symo/finz/mixin/client/SelectedBlockOutLineMixin.java index 084acba..ea20f34 100644 --- a/src/client/java/dev/symo/finz/mixin/client/SelectedBlockOutLineMixin.java +++ b/src/client/java/dev/symo/finz/mixin/client/SelectedBlockOutLineMixin.java @@ -1,6 +1,8 @@ package dev.symo.finz.mixin.client; import dev.symo.finz.FinZClient; +import dev.symo.finz.modules.Modules; +import dev.symo.finz.modules.impl.ChromaOutline; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; import net.minecraft.block.ShapeContext; @@ -38,7 +40,7 @@ private void drawBlockOutline(MatrixStack matrices, VertexConsumer vertexConsume float green = 0; float blue = 0; - if (FinZClient.config.chromaBlockOutlineEnabled) { + if (Modules.chromaOutline.isEnabled()){ var hue = (float) (System.currentTimeMillis() % 4000) / 4000; var color = Color.HSBtoRGB(hue, 1, 1); red = (color >> 16 & 255) / 255.0F; diff --git a/src/client/java/dev/symo/finz/mixin/client/fastplace/FastPlaceInvoker.java b/src/client/java/dev/symo/finz/mixin/client/fastplace/FastPlaceInvoker.java index 4929c7c..ca9dfed 100644 --- a/src/client/java/dev/symo/finz/mixin/client/fastplace/FastPlaceInvoker.java +++ b/src/client/java/dev/symo/finz/mixin/client/fastplace/FastPlaceInvoker.java @@ -19,8 +19,8 @@ public class FastPlaceInvoker { at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;emitGameEvent(Lnet/minecraft/world/event/GameEvent;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/event/GameEvent$Emitter;)V", shift = At.Shift.AFTER)) public void onBlockPlace(ItemPlacementContext context, CallbackInfoReturnable cir) { - if (FinZClient.config.fastPlaceEnabled) - ((FastPlaceClientMixin) FinZClient.mc).setItemUseCooldown(FinZClient.config.fastPlaceValue); + //if (FinZClient.config.fastPlaceEnabled) + // ((FastPlaceClientMixin) FinZClient.mc).setItemUseCooldown(FinZClient.config.fastPlaceValue); } } diff --git a/src/client/java/dev/symo/finz/modules/AModule.java b/src/client/java/dev/symo/finz/modules/AModule.java index d056111..30d3d27 100644 --- a/src/client/java/dev/symo/finz/modules/AModule.java +++ b/src/client/java/dev/symo/finz/modules/AModule.java @@ -43,11 +43,11 @@ public Collection getSettings() { return settings.values(); } - public boolean isEnabled() { + public final boolean isEnabled() { return ((BoolSetting)settings.get("enabled")).getValue(); } - public void setEnabled(boolean enabled) { + public final void setEnabled(boolean enabled) { ((BoolSetting)settings.get("enabled")).setValue(enabled); if (enabled) onEnable(); diff --git a/src/client/java/dev/symo/finz/modules/ModuleManager.java b/src/client/java/dev/symo/finz/modules/ModuleManager.java index b2df0e6..00390df 100644 --- a/src/client/java/dev/symo/finz/modules/ModuleManager.java +++ b/src/client/java/dev/symo/finz/modules/ModuleManager.java @@ -2,11 +2,6 @@ import dev.symo.finz.FinZClient; import dev.symo.finz.events.*; -import dev.symo.finz.events.listeners.ConfigChangeListener; -import dev.symo.finz.modules.impl.*; -import dev.symo.finz.modules.impl.esp.ItemESP; -import dev.symo.finz.modules.impl.esp.MobEsp; -import dev.symo.finz.modules.impl.esp.PlayerESP; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; diff --git a/src/client/java/dev/symo/finz/modules/impl/Modules.java b/src/client/java/dev/symo/finz/modules/Modules.java similarity index 71% rename from src/client/java/dev/symo/finz/modules/impl/Modules.java rename to src/client/java/dev/symo/finz/modules/Modules.java index b13c862..e9dea1b 100644 --- a/src/client/java/dev/symo/finz/modules/impl/Modules.java +++ b/src/client/java/dev/symo/finz/modules/Modules.java @@ -1,6 +1,6 @@ -package dev.symo.finz.modules.impl; +package dev.symo.finz.modules; -import dev.symo.finz.modules.AModule; +import dev.symo.finz.modules.impl.*; import dev.symo.finz.modules.impl.esp.ItemESP; import dev.symo.finz.modules.impl.esp.MobEsp; import dev.symo.finz.modules.impl.esp.PlayerESP; @@ -11,19 +11,34 @@ public class Modules { public static final ArrayList all = new ArrayList<>(); + // misc + public static AntiKnockback knockback = new AntiKnockback(); + public static Zoom zoom = new Zoom(); + + // render public static WhatTheFAmILookingAt wtfaila = new WhatTheFAmILookingAt(); - public static PathTracer pathTracer = new PathTracer(); public static MaterialScanner materialScanner = new MaterialScanner(); + public static PathTracer pathTracer = new PathTracer(); + public static ChromaOutline chromaOutline = new ChromaOutline(); + + // esp public static PlayerESP playerESP = new PlayerESP(); public static MobEsp mobEsp = new MobEsp(); public static ItemESP itemESP = new ItemESP(); static { + // misc + all.add(knockback); all.add(zoom); + + // render all.add(wtfaila); all.add(pathTracer); all.add(materialScanner); + all.add(chromaOutline); + + // esp all.add(playerESP); all.add(mobEsp); all.add(itemESP); diff --git a/src/client/java/dev/symo/finz/modules/impl/esp/AntiKnockback.java b/src/client/java/dev/symo/finz/modules/impl/AntiKnockback.java similarity index 86% rename from src/client/java/dev/symo/finz/modules/impl/esp/AntiKnockback.java rename to src/client/java/dev/symo/finz/modules/impl/AntiKnockback.java index 52b02ed..308d953 100644 --- a/src/client/java/dev/symo/finz/modules/impl/esp/AntiKnockback.java +++ b/src/client/java/dev/symo/finz/modules/impl/AntiKnockback.java @@ -1,20 +1,20 @@ -package dev.symo.finz.modules.impl.esp; +package dev.symo.finz.modules.impl; import dev.symo.finz.events.listeners.KnockbackListener; import dev.symo.finz.modules.AModule; import dev.symo.finz.modules.settings.DoubleSetting; import dev.symo.finz.util.Category; import dev.symo.finz.util.InputType; -import dev.symo.finz.util.ValueDisplay; public class AntiKnockback extends AModule implements KnockbackListener { - private final DoubleSetting _horizontal = new DoubleSetting("Horizontal", "100% = no knockback -- >100% = reverse knockback", 1, 0.0, 1.0, ValueDisplay.DECIMAL, InputType.PERCENT_SLIDER); - private final DoubleSetting _vertical = new DoubleSetting("Vertical", "100% = no knockback -- >100% = reverse knockback",1, 0.0, 1.0, ValueDisplay.DECIMAL, InputType.PERCENT_SLIDER); + private final DoubleSetting _horizontal = new DoubleSetting("Horizontal", "100% = no knockback -- >100% = reverse knockback", 1, 0.0, 1.0, InputType.PERCENT_SLIDER); + private final DoubleSetting _vertical = new DoubleSetting("Vertical", "100% = no knockback -- >100% = reverse knockback",1, 0.0, 1.0, InputType.PERCENT_SLIDER); public AntiKnockback() { super("AntiKnockback", Category.MOVEMENT); addSetting(_horizontal); + addSetting(_vertical); } @Override diff --git a/src/client/java/dev/symo/finz/modules/impl/ChromaOutline.java b/src/client/java/dev/symo/finz/modules/impl/ChromaOutline.java new file mode 100644 index 0000000..815a851 --- /dev/null +++ b/src/client/java/dev/symo/finz/modules/impl/ChromaOutline.java @@ -0,0 +1,10 @@ +package dev.symo.finz.modules.impl; + +import dev.symo.finz.modules.AModule; +import dev.symo.finz.util.Category; + +public class ChromaOutline extends AModule { + public ChromaOutline() { + super("ChromaOutline", Category.RENDER); + } +} diff --git a/src/client/java/dev/symo/finz/modules/impl/MaterialScanner.java b/src/client/java/dev/symo/finz/modules/impl/MaterialScanner.java index fa86595..cf967ba 100644 --- a/src/client/java/dev/symo/finz/modules/impl/MaterialScanner.java +++ b/src/client/java/dev/symo/finz/modules/impl/MaterialScanner.java @@ -1,8 +1,9 @@ package dev.symo.finz.modules.impl; -import dev.symo.finz.FinZClient; import dev.symo.finz.events.listeners.ConfigChangeListener; import dev.symo.finz.modules.AModule; +import dev.symo.finz.modules.settings.IntSetting; +import dev.symo.finz.modules.settings.StringSetting; import dev.symo.finz.util.Category; import dev.symo.finz.util.WorldSpaceRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -13,6 +14,11 @@ import java.util.ArrayList; public class MaterialScanner extends AModule implements ConfigChangeListener { + private final IntSetting _range = new IntSetting("Range", "Range to scan for blocks", + 50, 1, 100); + + private final StringSetting _material = new StringSetting("Material", "Material to scan for", + "minecraft:ancient_debris"); ArrayList blocks = new ArrayList<>(); @@ -20,17 +26,8 @@ public class MaterialScanner extends AModule implements ConfigChangeListener { public MaterialScanner() { super("Material Scanner", Category.RENDER); - } - - - @Override - public boolean isEnabled() { - return config.materialScannerEnabled; - } - - @Override - public void setEnabled(boolean enabled) { - config.materialScannerEnabled = enabled; + addSetting(_range); + addSetting(_material); } public void onConfigChange() { @@ -59,7 +56,7 @@ public void onTick() { var playerY = playerPos.getY(); var playerZ = playerPos.getZ(); - var range = config.materialScannerRange; + var range = _range.getValue(); for (int x = playerX - range; x < playerX + range; x++) { for (int y = playerY - range; y < playerY + range; y++) { @@ -67,9 +64,9 @@ public void onTick() { var pos = new BlockPos(x, y, z); var state = mc.world.getBlockState(pos); var block = state.getBlock(); - var match = config.materialScannerMaterial; // minecraft:ancient_debris + // _material.getValue() -> minecraft:ancient_debris var id = String.valueOf(Registries.BLOCK.getId(block)); - if (match.contains(id) && !blocks.contains(pos)) + if (_material.getValue().contains(id) && !blocks.contains(pos)) blocks.add(pos); } } diff --git a/src/client/java/dev/symo/finz/modules/impl/PathTracer.java b/src/client/java/dev/symo/finz/modules/impl/PathTracer.java index d7b73ef..667091b 100644 --- a/src/client/java/dev/symo/finz/modules/impl/PathTracer.java +++ b/src/client/java/dev/symo/finz/modules/impl/PathTracer.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.symo.finz.FinZClient; import dev.symo.finz.modules.AModule; +import dev.symo.finz.modules.settings.IntSetting; import dev.symo.finz.util.Category; import dev.symo.finz.util.PlayerUtil; import dev.symo.finz.util.RegionPos; @@ -18,21 +19,15 @@ public class PathTracer extends AModule { + private final IntSetting _pathTracerLength = new IntSetting("Path Tracer Length", "Length of the path tracer", + 50, 1, 100); + + public List path = new ArrayList<>(); public PathTracer() { super("PathTracer", Category.RENDER); - - } - - @Override - public boolean isEnabled() { - return FinZClient.config.pathTracerEnabled; - } - - @Override - public void setEnabled(boolean enabled) { - config.pathTracerEnabled = enabled; + addSetting(_pathTracerLength); } public void onTick() { @@ -49,9 +44,11 @@ public void onTick() { } } - if (config.pathTracerLength < path.size()) - if (path.size() - config.pathTracerLength > 0) - path.subList(0, path.size() - config.pathTracerLength).clear(); + var length = _pathTracerLength.getValue(); + + if (length < path.size()) + if (path.size() - length > 0) + path.subList(0, path.size() - length).clear(); } diff --git a/src/client/java/dev/symo/finz/modules/impl/WhatTheFAmILookingAt.java b/src/client/java/dev/symo/finz/modules/impl/WhatTheFAmILookingAt.java index 9a7d74b..2d62e60 100644 --- a/src/client/java/dev/symo/finz/modules/impl/WhatTheFAmILookingAt.java +++ b/src/client/java/dev/symo/finz/modules/impl/WhatTheFAmILookingAt.java @@ -37,16 +37,6 @@ public WhatTheFAmILookingAt() { super("WhatTheFAmILookingAt", Category.RENDER); } - @Override - public boolean isEnabled() { - return config.whatTheFAmILookingAtEnabled; - } - - @Override - public void setEnabled(boolean enabled) { - config.whatTheFAmILookingAtEnabled = enabled; - } - @Override public void onHudRender(DrawContext drawContext, float tickDelta){ diff --git a/src/client/java/dev/symo/finz/modules/impl/Zoom.java b/src/client/java/dev/symo/finz/modules/impl/Zoom.java index 0432a3c..c74baba 100644 --- a/src/client/java/dev/symo/finz/modules/impl/Zoom.java +++ b/src/client/java/dev/symo/finz/modules/impl/Zoom.java @@ -2,15 +2,18 @@ import dev.symo.finz.FinZClient; import dev.symo.finz.modules.AModule; +import dev.symo.finz.modules.settings.DoubleSetting; import dev.symo.finz.util.Category; +import dev.symo.finz.util.InputType; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.option.SimpleOption; import net.minecraft.client.util.InputUtil; -import net.minecraft.world.GameRules; import org.lwjgl.glfw.GLFW; public class Zoom extends AModule { + private final DoubleSetting _zoomLevel = new DoubleSetting("Zoom Level", "Zoom level", 1, 1, 50, InputType.DECIMAL_SLIDER); + private Double defaultMouseSensitivity; public Zoom() { @@ -19,7 +22,6 @@ public Zoom() { } public double zoom(double fov) { - SimpleOption mouseSensitivitySetting = mc.options.getMouseSensitivity(); if (!_keybind.isPressed()) { @@ -36,19 +38,8 @@ public double zoom(double fov) { // Adjust mouse sensitivity in relation to zoom level. // 1.0 / currentLevel is a value between 0.02 (50x zoom) // and 1 (no zoom). - mouseSensitivitySetting.setValue(defaultMouseSensitivity * (1.0 / FinZClient.config.zoomLevel)); - - return fov / FinZClient.config.zoomLevel; - } - - - @Override - public boolean isEnabled() { - return _keybind.isPressed(); - } + mouseSensitivitySetting.setValue(defaultMouseSensitivity * (1.0 / _zoomLevel.getValue())); - @Override - public void setEnabled(boolean enabled) { - _keybind.setPressed(enabled); + return fov / _zoomLevel.getValue(); } } diff --git a/src/client/java/dev/symo/finz/modules/impl/esp/ItemESP.java b/src/client/java/dev/symo/finz/modules/impl/esp/ItemESP.java index cc9568f..3896bfd 100644 --- a/src/client/java/dev/symo/finz/modules/impl/esp/ItemESP.java +++ b/src/client/java/dev/symo/finz/modules/impl/esp/ItemESP.java @@ -1,6 +1,7 @@ package dev.symo.finz.modules.impl.esp; import dev.symo.finz.modules.AModule; +import dev.symo.finz.modules.settings.IntSetting; import dev.symo.finz.util.Category; import dev.symo.finz.util.WorldSpaceRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -13,19 +14,13 @@ public class ItemESP extends AModule { private final ArrayList items = new ArrayList<>(); + private final IntSetting itemEspRange = new IntSetting("Range", "Range to scan for items", + 50, 1, 100); + public ItemESP() { super("ItemESP", Category.RENDER); - } - - @Override - public boolean isEnabled() { - return config.itemEsp; - } - - @Override - public void setEnabled(boolean enabled) { - config.itemEsp = enabled; + addSetting(itemEspRange); } @@ -36,7 +31,7 @@ public void onTick() { if (mc.world == null) return; items.clear(); - items.addAll(mc.world.getEntitiesByClass(ItemEntity.class, mc.player.getBoundingBox().expand(config.itemEspRange), Objects::nonNull)); + items.addAll(mc.world.getEntitiesByClass(ItemEntity.class, mc.player.getBoundingBox().expand(itemEspRange.getValue()), Objects::nonNull)); } @Override diff --git a/src/client/java/dev/symo/finz/modules/impl/esp/MobEsp.java b/src/client/java/dev/symo/finz/modules/impl/esp/MobEsp.java index baae8c1..c17b491 100644 --- a/src/client/java/dev/symo/finz/modules/impl/esp/MobEsp.java +++ b/src/client/java/dev/symo/finz/modules/impl/esp/MobEsp.java @@ -2,6 +2,7 @@ import dev.symo.finz.modules.AModule; import dev.symo.finz.modules.ModuleManager; +import dev.symo.finz.modules.settings.IntSetting; import dev.symo.finz.util.Category; import dev.symo.finz.util.WorldSpaceRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -15,6 +16,10 @@ import java.util.Objects; public class MobEsp extends AModule { + + private final IntSetting itemEspRange = new IntSetting("Range", "Range to scan for items", + 50, 1, 100); + private final ArrayList mobs = new ArrayList<>(); public ArrayList ignore = new ArrayList<>(); @@ -23,15 +28,6 @@ public class MobEsp extends AModule { public MobEsp() { super("MobESP", Category.RENDER);} - @Override - public boolean isEnabled() { - return config.mobEsp; - } - - @Override - public void setEnabled(boolean enabled) { - config.mobEsp = enabled; - } @Override public void onTick() { @@ -40,7 +36,7 @@ public void onTick() { if (mc.world == null) return; mobs.clear(); - for (LivingEntity mob : mc.world.getEntitiesByClass(MobEntity.class, mc.player.getBoundingBox().expand(config.mobEspRange), Objects::nonNull)) { + for (LivingEntity mob : mc.world.getEntitiesByClass(MobEntity.class, mc.player.getBoundingBox().expand(itemEspRange.getValue()), Objects::nonNull)) { if (mob == mc.player) continue; if (!mob.isAlive()) continue; if (ignore.contains(mob)) continue; diff --git a/src/client/java/dev/symo/finz/modules/impl/esp/PlayerESP.java b/src/client/java/dev/symo/finz/modules/impl/esp/PlayerESP.java index 4cac9c2..6f8f4f6 100644 --- a/src/client/java/dev/symo/finz/modules/impl/esp/PlayerESP.java +++ b/src/client/java/dev/symo/finz/modules/impl/esp/PlayerESP.java @@ -23,15 +23,6 @@ public PlayerESP() { super("PlayerESP", Category.RENDER); } - @Override - public boolean isEnabled() { - return config.playerEsp; - } - - @Override - public void setEnabled(boolean enabled) { - config.playerEsp = enabled; - } @Override public void onTick() { diff --git a/src/client/java/dev/symo/finz/modules/settings/DoubleSetting.java b/src/client/java/dev/symo/finz/modules/settings/DoubleSetting.java index d4d2156..bd3c5ec 100644 --- a/src/client/java/dev/symo/finz/modules/settings/DoubleSetting.java +++ b/src/client/java/dev/symo/finz/modules/settings/DoubleSetting.java @@ -2,28 +2,24 @@ import com.google.gson.JsonElement; import dev.symo.finz.util.InputType; -import dev.symo.finz.util.ValueDisplay; public class DoubleSetting extends ModuleSetting{ private double _value; private final double _min; private final double _max; - private final ValueDisplay _display; - public DoubleSetting(String name, String description, double value, double min, double max, ValueDisplay display) { + public DoubleSetting(String name, String description, double value, double min, double max) { super(name, description, InputType.DECIMAL); _value = value; _min = min; _max = max; - _display = display; } - public DoubleSetting(String name, String description, double value, double min, double max, ValueDisplay display, InputType type) { + public DoubleSetting(String name, String description, double value, double min, double max, InputType type) { super(name, description, type); _value = value; _min = min; _max = max; - _display = display; } @Override @@ -43,11 +39,6 @@ public void setValue(double value) { _value = Math.max(_min, Math.min(_max, value)); } - @Override - public String toString() { - return _display.getValueString(_value); - } - public double getMin() { return _min; } diff --git a/src/client/java/dev/symo/finz/modules/settings/IntSetting.java b/src/client/java/dev/symo/finz/modules/settings/IntSetting.java new file mode 100644 index 0000000..8c61dfc --- /dev/null +++ b/src/client/java/dev/symo/finz/modules/settings/IntSetting.java @@ -0,0 +1,47 @@ +package dev.symo.finz.modules.settings; + +import com.google.gson.JsonElement; +import dev.symo.finz.util.InputType; + +public class IntSetting extends ModuleSetting{ + + private int _value; + private final int _min; + private final int _max; + + + public IntSetting(String name, String description, int value, int min, int max, InputType type) { + super(name, description, type); + _value = value; + _min = min; + _max = max; + } + public IntSetting(String name, String description, int value, int min, int max) { + this(name, description, value, min, max, InputType.NUMBER); + } + + @Override + public void fromJson(JsonElement json) { + } + + @Override + public JsonElement toJson() { + return null; + } + + public int getValue() { + return _value; + } + + public void setValue(int value) { + _value = Math.max(_min, Math.min(_max, value)); + } + + public int getMin() { + return _min; + } + + public int getMax() { + return _max; + } +} diff --git a/src/client/java/dev/symo/finz/modules/settings/StringSetting.java b/src/client/java/dev/symo/finz/modules/settings/StringSetting.java index dcf6bb2..bc32812 100644 --- a/src/client/java/dev/symo/finz/modules/settings/StringSetting.java +++ b/src/client/java/dev/symo/finz/modules/settings/StringSetting.java @@ -6,7 +6,7 @@ public class StringSetting extends ModuleSetting{ private String _value; - protected StringSetting(String name, String description, String value) { + public StringSetting(String name, String description, String value) { super(name, description, InputType.TEXT); _value = value; } diff --git a/src/client/java/dev/symo/finz/ui/ConfigScreen.java b/src/client/java/dev/symo/finz/ui/ConfigScreen.java index 55d1cbd..8ccaa66 100644 --- a/src/client/java/dev/symo/finz/ui/ConfigScreen.java +++ b/src/client/java/dev/symo/finz/ui/ConfigScreen.java @@ -2,10 +2,8 @@ import dev.symo.finz.FinZClient; import dev.symo.finz.modules.AModule; -import dev.symo.finz.modules.impl.Modules; -import dev.symo.finz.ui.components.BoxComponent; +import dev.symo.finz.modules.Modules; import dev.symo.finz.ui.components.ModuleComponent; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; @@ -30,8 +28,7 @@ protected void init() { false, false, null, 0); AModule[] modules = Modules.all.toArray(new AModule[0]); for (int i = 0; i < modules.length; i++) { - var comp = new ModuleComponent(modules[i]._name, i * 250, 0, 200, 200, true, false, parent, modules[i].getSettings()); - addDrawableChild(comp); + addDrawableChild(new ModuleComponent(modules[i]._name, i * 250, 0, 200, 200, true, false, parent, modules[i].getSettings())); } } @@ -40,11 +37,6 @@ public boolean shouldPause() { return false; } - @Override - public void resize(MinecraftClient client, int width, int height) { - super.resize(client, width, height); - } - @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { var flag = false; @@ -65,7 +57,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 0) this.setDragging(true); return true; } - if (flag){ + if (flag) { return true; } } diff --git a/src/client/java/dev/symo/finz/ui/ParentUiComponent.java b/src/client/java/dev/symo/finz/ui/ParentUiComponent.java index f7403b6..add4872 100644 --- a/src/client/java/dev/symo/finz/ui/ParentUiComponent.java +++ b/src/client/java/dev/symo/finz/ui/ParentUiComponent.java @@ -31,6 +31,33 @@ public ParentUiComponent(String title, int x, int y, int width, int height, bool this.padding = padding; } + + public void setXChildren(int x) { + for (UiComponent child : children) + child.x = x; + } + + public void setYChildren(int y) { + for (UiComponent child : children) + child.y = y; + } + + @Override + public void setXSanitized(int x) { + var prevX = getX(); + super.setXSanitized(x); + var deltaX = getX() - prevX; + setXChildren(getX() + deltaX); + } + + @Override + public void setYSanitized(int y) { + var prevY = getY(); + super.setYSanitized(y); + var deltaY = getY() - prevY; + setYChildren(getY() + deltaY); + } + public boolean isDraggable() { return draggable; } @@ -50,14 +77,14 @@ public final void setDragging(boolean dragging) { @Override public int getHeight() { int height = 0; - for (UiComponent child : children) height = Math.max(height, child.getMinHeight()); + for (UiComponent child : children) height = Math.max(height, child.getHeight()); return height + padding; } @Override public int getWidth() { int width = 0; - for (UiComponent child : children) width = Math.max(width, child.getMinWidth()); + for (UiComponent child : children) width = Math.max(width, child.getWidth()); return width + padding; } @@ -82,18 +109,18 @@ public final void removeChildren(UiComponent... children) { for (UiComponent child : children) this.children.remove(child); } - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (!isMouseOver(mouseX, mouseY)) return false; + //@Override + //public boolean mouseClicked(double mouseX, double mouseY, int button) { + // if (!isMouseOver(mouseX, mouseY)) return false; - for (UiComponent child : children) { - if (child.mouseClicked(mouseX, mouseY, button)) { - return true; - } - } + // for (UiComponent child : children) { + // if (child.mouseClicked(mouseX, mouseY, button)) { + // return true; + // } + // } - return true; - } + // return true; + //} public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { if (!isMouseOver(mouseX, mouseY)) return false; diff --git a/src/client/java/dev/symo/finz/ui/UiComponent.java b/src/client/java/dev/symo/finz/ui/UiComponent.java index ae0e95d..062ca23 100644 --- a/src/client/java/dev/symo/finz/ui/UiComponent.java +++ b/src/client/java/dev/symo/finz/ui/UiComponent.java @@ -46,11 +46,11 @@ public final void setTitle(String title) { } public final int rightX() { - return x + minWidth / 2; + return x + getWidth() / 2; } public final int bottomY() { - return y + minHeight / 2; + return y + getWidth() / 2; } protected final int getParentWidth() { @@ -121,7 +121,6 @@ public void setYSanitized(int y) { this.y = this.getY(); } - @Override public boolean isMouseOver(double mouseX, double mouseY) { return mouseX >= this.getXLeft() && mouseX <= this.getXRight() && mouseY >= this.getYTop() && mouseY <= this.getYBottom(); diff --git a/src/client/java/dev/symo/finz/ui/components/BoxComponent.java b/src/client/java/dev/symo/finz/ui/components/BoxComponent.java index ac57b2a..fc39abd 100644 --- a/src/client/java/dev/symo/finz/ui/components/BoxComponent.java +++ b/src/client/java/dev/symo/finz/ui/components/BoxComponent.java @@ -13,6 +13,7 @@ public BoxComponent(String title, int x, int y, int width, int height, boolean d public void render(DrawContext context, int mouseX, int mouseY, float delta) { context.drawCenteredTextWithShadow(textRenderer, this.getTitle(), this.getX(), this.getYTop() + 4, 0xFFFFFFFF); context.fill(this.getXLeft(), this.getYTop(),this. getXRight(), this.getYBottom(), 0x80000000); + context.drawBorder(getXLeft(), getYTop(), getWidth(), getHeight(), 0xFFFFFFFF); } } diff --git a/src/client/java/dev/symo/finz/ui/components/ModuleComponent.java b/src/client/java/dev/symo/finz/ui/components/ModuleComponent.java index 285ca47..4b96e4b 100644 --- a/src/client/java/dev/symo/finz/ui/components/ModuleComponent.java +++ b/src/client/java/dev/symo/finz/ui/components/ModuleComponent.java @@ -1,9 +1,6 @@ package dev.symo.finz.ui.components; -import dev.symo.finz.modules.settings.BoolSetting; -import dev.symo.finz.modules.settings.DoubleSetting; -import dev.symo.finz.modules.settings.ModuleSetting; -import dev.symo.finz.modules.settings.StringSetting; +import dev.symo.finz.modules.settings.*; import dev.symo.finz.ui.ParentUiComponent; import dev.symo.finz.ui.UiComponent; import dev.symo.finz.ui.widgets.SliderWidget; @@ -14,42 +11,31 @@ import net.minecraft.text.Text; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; public class ModuleComponent extends BoxComponent { - private int width; - private int height; public ModuleComponent(String title, int x, int y, int width, int height, boolean draggable, boolean scrollable, ParentUiComponent parent, Collection settings) { super(title, x, y, width, height, draggable, scrollable, parent); + var oX = getXLeft(); + var oY = getYTop(); + for (ModuleSetting setting : settings) { //this.width = Math.max(width, component.getWidth() + 10 + textRenderer.getWidth(setting.getName())); //this.height += component.getHeight() + 20; var widget = getComponentForSetting(setting); - var component = new OptionComponent(setting.getName(), x, y, width, height, false, parent, widget); + var component = new OptionComponent(setting.getName(), oX, oY, width, height, false, parent, widget); children.add(component); - y += component.getHeight(); + oY += component.getHeight() + 20; } } @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { - for (UiComponent child : children) { + super.render(context, mouseX, mouseY, delta); + for (UiComponent child : children) child.render(context, mouseX, mouseY, delta); - } - } - - @Override - public int getHeight() { - return height; - } - - @Override - public int getWidth() { - return width; } private ClickableWidget getComponentForSetting(ModuleSetting setting) { @@ -60,41 +46,58 @@ private ClickableWidget getComponentForSetting(ModuleSetting setting) { if (!(setting instanceof StringSetting stringSetting)) throw new IllegalArgumentException("Setting is not a StringSetting"); var textField = new TextFieldWidget(textRenderer, 0, 0, 100, 20, text); + textField.setText(stringSetting.getValue()); textField.setChangedListener(stringSetting::setValue); widget = textField; } - //case NUMBER -> { - //} - case BOOLEAN -> { - if (!(setting instanceof BoolSetting boolSetting)) - throw new IllegalArgumentException("Setting is not a BoolSetting"); - widget = CheckboxWidget.builder(text, textRenderer) - .pos(x, y) - .callback((w, b) -> boolSetting.setValue(b)) - .build(); + case NUMBER -> { + if (!(setting instanceof IntSetting intSetting)) + throw new IllegalArgumentException("Setting is not a DoubleSetting"); + var textField = new TextFieldWidget(textRenderer, 0, 0, 100, 20, text); + textField.setText("%d".formatted(intSetting.getValue())); + textField.setChangedListener(s -> { + try { + intSetting.setValue(Integer.parseInt(s)); + } catch (NumberFormatException ignored) { + // clear the text field + textField.setText("%d".formatted(intSetting.getValue())); + } + }); + widget = textField; } - //case SELECT -> { - //} case DECIMAL -> { if (!(setting instanceof DoubleSetting doubleSetting)) throw new IllegalArgumentException("Setting is not a DoubleSetting"); var textField = new TextFieldWidget(textRenderer, 0, 0, 100, 20, text); + textField.setText("%s".formatted(doubleSetting.getValue())); textField.setChangedListener(s -> { try { doubleSetting.setValue(Double.parseDouble(s)); } catch (NumberFormatException ignored) { // clear the text field - textField.setText("0"); + textField.setText("%s".formatted(doubleSetting.getValue())); } }); widget = textField; } + case BOOLEAN -> { + if (!(setting instanceof BoolSetting boolSetting)) { + throw new IllegalArgumentException("Setting is not a BoolSetting"); + } + widget = CheckboxWidget.builder(Text.empty(), textRenderer) + .pos(x, y) + .callback((w, b) -> boolSetting.setValue(b)) + .checked(boolSetting.getValue()) + .build(); + } + //case SELECT -> { + //} //case COLOR -> { //} case DECIMAL_SLIDER -> { if (!(setting instanceof DoubleSetting doubleSetting)) throw new IllegalArgumentException("Setting is not a DoubleSetting"); - var slider = new SliderWidget(0, 0, 100, 20, text, + var slider = new SliderWidget(0, 0, 100, 20, Text.empty(), doubleSetting.getValue(), doubleSetting.getMin(), doubleSetting.getMax()); slider.setChangedListener(doubleSetting::setValue); widget = slider; @@ -102,7 +105,7 @@ private ClickableWidget getComponentForSetting(ModuleSetting setting) { case PERCENT_SLIDER -> { if (!(setting instanceof DoubleSetting doubleSetting)) throw new IllegalArgumentException("Setting is not a DoubleSetting"); - var slider = new SliderWidget(0, 0, 100, 20, text, + var slider = new SliderWidget(0, 0, 100, 20, Text.empty(), doubleSetting.getValue(), doubleSetting.getMin(), doubleSetting.getMax()); slider.setChangedListener(doubleSetting::setValue); widget = slider; diff --git a/src/client/java/dev/symo/finz/ui/components/OptionComponent.java b/src/client/java/dev/symo/finz/ui/components/OptionComponent.java index 9775deb..3c6db18 100644 --- a/src/client/java/dev/symo/finz/ui/components/OptionComponent.java +++ b/src/client/java/dev/symo/finz/ui/components/OptionComponent.java @@ -16,7 +16,10 @@ public OptionComponent(String optionName, int x, int y, int width, int height, @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { + //context.drawBorder(getXLeft(), getYTop(), getWidth(), getHeight(), 0xFFFFFFFF); context.drawTextWithShadow(textRenderer, title, getXLeft(), getYTop(), 0xFFFFFFFF); + widget.setX(getXLeft() + textRenderer.getWidth(title)); + widget.setY(getYTop()); widget.render(context, mouseX, mouseY, delta); } @@ -27,7 +30,7 @@ public SelectionType getType() { @Override public int getHeight() { - return (int) (textRenderer.fontHeight * 1.5 + widget.getHeight()); + return (int) (Math.max(textRenderer.fontHeight * 1.5, widget.getHeight())); } @Override diff --git a/src/client/java/dev/symo/finz/ui/components/WidgetContainer.java b/src/client/java/dev/symo/finz/ui/components/WidgetContainer.java deleted file mode 100644 index 302b666..0000000 --- a/src/client/java/dev/symo/finz/ui/components/WidgetContainer.java +++ /dev/null @@ -1,49 +0,0 @@ -package dev.symo.finz.ui.components; - -import dev.symo.finz.ui.ParentUiComponent; -import dev.symo.finz.ui.UiComponent; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.widget.ClickableWidget; -import org.jetbrains.annotations.Nullable; - -public class WidgetContainer extends UiComponent { - - private final ClickableWidget widget; - - public WidgetContainer(String title, int x, int y, int width, int height, boolean scrollable, @Nullable ParentUiComponent parent, ClickableWidget widget) { - super(title, x, y, width, height, scrollable, parent); - this.widget = widget; - } - - @Override - public int getHeight() { - return widget.getHeight(); - } - - @Override - public int getWidth() { - return widget.getWidth(); - } - - @Override - public void setYSanitized(int y) { - super.setYSanitized(y); - widget.setX(x); - } - - @Override - public void setXSanitized(int x) { - super.setXSanitized(x); - widget.setY(y); - } - - @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { - widget.render(context, mouseX, mouseY, delta); - } - - @Override - public SelectionType getType() { - return SelectionType.FOCUSED; - } -} diff --git a/src/client/java/dev/symo/finz/util/InputType.java b/src/client/java/dev/symo/finz/util/InputType.java index 7022317..4b69e41 100644 --- a/src/client/java/dev/symo/finz/util/InputType.java +++ b/src/client/java/dev/symo/finz/util/InputType.java @@ -2,7 +2,7 @@ public enum InputType { TEXT("text"), - //NUMBER("number"), + NUMBER("number"), BOOLEAN("boolean"), //SELECT("select"), DECIMAL("decimal"),