Skip to content

Commit

Permalink
New Script Entries. Quad Holes in HoleUtils. ScriptScreen optimisatio…
Browse files Browse the repository at this point in the history
…n. InputBox enterTask supplier. Wrong color used by a few settings. Scaling method in fxFontRenderer and added more documentation.
  • Loading branch information
tanishisherewithhh committed Sep 18, 2024
1 parent 59a6889 commit 921fc6d
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 107 deletions.
14 changes: 10 additions & 4 deletions src/main/java/dev/heliosclient/module/modules/render/HoleESP.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public class HoleESP extends Module_ {
.onSettingChange(this)
.build()
);
BooleanSetting quads = sgGeneral.add(new BooleanSetting.Builder()
.name("Show Quad holes")
.description("Shows quad holes (4 block holes). May drain fps.")
.value(false)
.defaultValue(false)
.onSettingChange(this)
.build()
);
DoubleSetting holeRange = sgGeneral.add(new DoubleSetting.Builder()
.name("Hole Range")
.description("Maximum distance of the hole to the player")
Expand Down Expand Up @@ -190,8 +198,6 @@ public class HoleESP extends Module_ {
.build()
);



public HoleESP() {
super("HoleESP", "Displays holes in your area", Categories.RENDER);
addSettingGroup(sgGeneral);
Expand All @@ -205,7 +211,7 @@ public HoleESP() {

@SubscribeEvent
public void onTick(TickEvent.PLAYER event) {
holes = HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value).stream().toList();
holes = HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value,quads.value).stream().toList();
}

@SubscribeEvent
Expand All @@ -216,7 +222,7 @@ public void onRender3d(Render3DEvent event) {
QuadColor.CardinalDirection direction = gradientDirection.getOption().equals("Down") ? QuadColor.CardinalDirection.SOUTH : QuadColor.CardinalDirection.NORTH;

for (HoleUtils.HoleInfo info : holes) {
if (!renderSelf.value && mc.player.getBlockPos().isWithinDistance(info.holePosition, 1d)) {
if (!renderSelf.value && info.holeBox.intersects(mc.player.getBoundingBox().contract(0.2f))) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ public Builder defaultValue(float val) {
this.defaultValue = (double) val;
return this;
}
public Builder value(float val) {
this.value = (double) val;
return this;
}

@Override
public DoubleSetting build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import dev.heliosclient.HeliosClient;
import dev.heliosclient.managers.ColorManager;
import dev.heliosclient.managers.GradientManager;
import dev.heliosclient.module.settings.lists.ListSetting;
import dev.heliosclient.ui.clickgui.gui.tables.Table;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void createTable(double width){
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) {
super.render(drawContext, x, y, mouseX, mouseY, textRenderer);

Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 2, y + 4, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 2, y + 4, ColorManager.INSTANCE.defaultTextColor);

// Draw a '🖋' button next to the text
nameWidth = Renderer2D.getFxStringWidth(name);
Expand Down Expand Up @@ -128,7 +129,7 @@ public void renderAllGradients(DrawContext context, int mouseX, int mouseY){
@Override
public void renderCompact(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) {
super.renderCompact(drawContext, x, y, mouseX, mouseY, textRenderer);
Renderer2D.drawFixedString(drawContext.getMatrices(), FontRenderers.fxfontRenderer.trimToWidth(name, moduleWidth), x + 2, y + 4, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), FontRenderers.fxfontRenderer.trimToWidth(name, moduleWidth), x + 2, y + 4, ColorManager.INSTANCE.defaultTextColor);

// Draw a '🖋' button next to the text
nameWidth = Renderer2D.getFxStringWidth(FontRenderers.fxfontRenderer.trimToWidth(name, moduleWidth));
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/heliosclient/module/settings/Option.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.heliosclient.module.settings;


//what is this anyone explain pls.
public class Option<T> {
private String name;
Expand Down
35 changes: 25 additions & 10 deletions src/main/java/dev/heliosclient/module/settings/RGBASetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.heliosclient.event.SubscribeEvent;
import dev.heliosclient.event.events.TickEvent;
import dev.heliosclient.event.listener.Listener;
import dev.heliosclient.managers.ColorManager;
import dev.heliosclient.managers.EventManager;
import dev.heliosclient.ui.clickgui.settings.RGBASettingScreen;
import dev.heliosclient.util.ColorUtils;
Expand Down Expand Up @@ -80,14 +81,28 @@ public RGBASetting(String name, String description, Color defaultColor, boolean
alphaHandleY = Math.round((1.0f - alpha) * (float) boxHeight);

hexInput = new InputBox(50, 11, ColorUtils.colorToHex(value), 7, InputBox.InputMode.ALL);
hexInput.enterTask = ()->{
if (ColorUtils.isHexColor(hexInput.getValue().trim())) {
try {
value = ColorUtils.hexToColor(hexInput.getValue().trim());
updateHandles(true);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
// Something went wrong
}
}
return true;
};
}

@Override
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) {
super.render(drawContext, x, y, mouseX, mouseY, textRenderer);
this.x = x;
this.y = y;
Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 2, y + 4, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 2, y + 4, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), x + 170, y + 2, 15, 15, 2, value.getRGB());
}

Expand All @@ -97,7 +112,7 @@ public void renderSetting(DrawContext drawContext, int x, int y, int mouseX, int


// Draw the name of setting and the value of the color we have set
Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 3, y + 2, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 3, y + 2, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), x + 170, y + 2, 15, 15, 2, value.getRGB());

int value1 = hoveredOverGradientBox(mouseX, mouseY) ? Color.DARK_GRAY.getRGB() : Color.BLACK.brighter().getRGB();
Expand Down Expand Up @@ -135,10 +150,10 @@ public void renderSetting(DrawContext drawContext, int x, int y, int mouseX, int
FontRenderers.Mid_iconRenderer.drawString(drawContext.getMatrices(), "\uF1FB", x + offsetX + Renderer2D.getFxStringWidth("Rainbow ") + 6.5f, y + offsetY + gradientBoxHeight + 6.5f, isPicking ? Color.GREEN.getRGB() : Color.RED.getRGB());

//Render the texts
Renderer2D.drawFixedString(drawContext.getMatrices(), "Alpha: " + value.getAlpha(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 9, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), "Red: " + value.getRed(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 18, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), "Green: " + value.getGreen(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 27, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), "Blue: " + value.getBlue(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 36, -1);
Renderer2D.drawFixedString(drawContext.getMatrices(), "Alpha: " + value.getAlpha(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 9, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawFixedString(drawContext.getMatrices(), "Red: " + value.getRed(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 18, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawFixedString(drawContext.getMatrices(), "Green: " + value.getGreen(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 27, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawFixedString(drawContext.getMatrices(), "Blue: " + value.getBlue(), gradientBoxX, y + offsetY + gradientBoxHeight + Renderer2D.getFxStringHeight() + 36, ColorManager.INSTANCE.defaultTextColor());

// Draw the handles
Renderer2D.drawFilledCircle(drawContext.getMatrices().peek().getPositionMatrix(), gradientBoxX + handleX, gradientBoxY + handleY, 1, -1);
Expand Down Expand Up @@ -195,7 +210,7 @@ public void drawAlphaSlider(DrawContext drawContext, int x, int y, int value3) {

Renderer2D.drawOutlineRoundedBox(drawContext.getMatrices().peek().getPositionMatrix(), x - 1, y - 1, sliderWidth + 2, boxHeight + 2, 1, 1, value3);

FontRenderers.Small_fxfontRenderer.drawString(drawContext.getMatrices(), "Alpha", x - 5, y + boxHeight + 2, -1); // Below the alpha slider
FontRenderers.Small_fxfontRenderer.drawString(drawContext.getMatrices(), "Alpha", x - 5, y + boxHeight + 2, ColorManager.INSTANCE.defaultTextColor()); // Below the alpha slider
}

public void drawBrightnessSaturationBox(DrawContext drawContext, int x, int y, float hue, int value3) {
Expand Down Expand Up @@ -243,7 +258,7 @@ public boolean hoveredOverBrightnessSaturationBox(double mouseX, double mouseY)
@Override
public void renderCompact(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) {
super.renderCompact(drawContext, x, y, mouseX, mouseY, textRenderer);
FontRenderers.Small_fxfontRenderer.drawString(drawContext.getMatrices(), name.substring(0, Math.min(12, name.length())) + "...", x + 3, y + 1, -1);
FontRenderers.Small_fxfontRenderer.drawString(drawContext.getMatrices(), name.substring(0, Math.min(12, name.length())) + "...", x + 3, y + 1, ColorManager.INSTANCE.defaultTextColor());
Renderer2D.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), x + 71, y + 1, 10, 10, 2, value.getRGB());
}

Expand Down Expand Up @@ -298,9 +313,9 @@ public void mouse(double mouseX, double mouseY, int button) {

public void keyPress(int keyCode) {
if ((keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_ENTER) && hexInput.isFocused()) {
if (ColorUtils.isHexColor(hexInput.getValue())) {
if (ColorUtils.isHexColor(hexInput.getValue().trim())) {
try {
value = ColorUtils.hexToColor(hexInput.getValue());
value = ColorUtils.hexToColor(hexInput.getValue().trim());
updateHandles(true);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class ClickGUI extends Module_ {
.name("ClickGUI roundness")
.description("Control the roundness of the click gui")
.onSettingChange(this)
.value(2d)
.defaultValue(2)
.min(1)
.max(7)
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/dev/heliosclient/scripting/LuaLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public void load(LuaFile luaFile) {

LuaValue onRunFunction = luaFile.getExecutor().getFunction("onRun");
if (onRunFunction.isfunction()) {
onRunFunction.call();
try {
onRunFunction.call();
}catch (Throwable e){
ChatUtils.sendHeliosMsg(ColorUtils.darkRed + "Error caught while calling the onRun() function: " + e.getMessage());
HeliosClient.LOGGER.error("Error caught while calling the onRun() function...", e);
}
} else {
ChatUtils.sendHeliosMsg(ColorUtils.darkRed + "onRun() function not found for " + ColorUtils.blue + luaFile.getAbsolutePath() + ColorUtils.darkRed + " while loading");
HeliosClient.LOGGER.error("onRun() function not found for file: {} while loading", luaFile.getName());
Expand Down Expand Up @@ -78,7 +83,12 @@ public void close(LuaFile file) {
try {
LuaValue onStopFunction = file.getExecutor().getFunction("onStop");
if (onStopFunction.isfunction()) {
onStopFunction.call();
try {
onStopFunction.call();
}catch (Throwable e){
ChatUtils.sendHeliosMsg(ColorUtils.darkRed + "Error caught while calling the onStop() function: " + e.getMessage());
HeliosClient.LOGGER.error("Error caught while calling the onStop() function...", e);
}
} else {
ChatUtils.sendHeliosMsg(ColorUtils.darkRed + "onStop() function not found for " + ColorUtils.blue + file.getAbsolutePath() + ColorUtils.darkRed + " while closing");
HeliosClient.LOGGER.error("onStop() function not found for file: {} while closing", file.getAbsolutePath());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/heliosclient/ui/clickgui/CategoryPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ public void keepOnlyModule(Module_ module) {
}

public void removeModules() {
moduleButtons.clear();
if(!moduleButtons.isEmpty())
moduleButtons.clear();

height = 4;
maxWidth = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/ui/clickgui/SearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY

Renderer2D.drawOutlineRoundedBox(drawContext.getMatrices().peek().getPositionMatrix(), x - 15 + 1.5f, y - 0.5f, width + 14f, height + 1f, 3, 0.5f, focused ? Color.WHITE.getRGB() : ColorUtils.argbToRgb(ColorManager.INSTANCE.clickGuiPrimary));
Renderer2D.drawRoundedRectangleWithShadow(drawContext.getMatrices(), x - 15 + 2, y, width + 13f, height, 2, 6, ColorUtils.argbToRgb(ColorManager.INSTANCE.clickGuiPrimary,200));
FontRenderers.Large_iconRenderer.drawString(drawContext.getMatrices(), "\uEA17", x - 15 + 4, y + 1, -1);
FontRenderers.Large_iconRenderer.drawString(drawContext.getMatrices(), "\uEA17", x - 15 + 4, y + 1, ColorManager.INSTANCE.defaultTextColor);

float textHeight = Renderer2D.getFxStringHeight();
float textY = y + (height - textHeight) / 2; // Center the text vertically
Expand Down
Loading

0 comments on commit 921fc6d

Please sign in to comment.