Skip to content

Commit

Permalink
more settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cvs0 committed Jul 7, 2024
1 parent cde8fdb commit d989c38
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 30 deletions.
6 changes: 4 additions & 2 deletions src/main/java/net/aoba/event/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

import net.aoba.event.events.AbstractEvent;
import net.aoba.event.listeners.AbstractListener;

public class EventManager {

private final HashMap<Class<AbstractListener>, ArrayList<AbstractListener>> listeners;
private final ConcurrentHashMap<Class<AbstractListener>, ArrayList<AbstractListener>> listeners;

public EventManager() {
listeners = new HashMap<Class<AbstractListener>, ArrayList<AbstractListener>>();
listeners = new ConcurrentHashMap<Class<AbstractListener>, ArrayList<AbstractListener>>();
}

@SuppressWarnings("unchecked")
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/aoba/gui/colors/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public Color(float hue, float saturation, float luminance) {
*
* @param hue The hue of the HSV color space.
* @param saturation The saturation of the HSV color space.
* @param value
*/
public void setHSV(float hue, float saturation, float luminance) {
this.hue = hue;
Expand Down Expand Up @@ -334,5 +333,4 @@ public static Color hsv2rgb(float hue, float saturation, float luminance) {
}
return null;
}

}
116 changes: 116 additions & 0 deletions src/main/java/net/aoba/misc/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,99 @@ public static void draw3DBox(Matrix4f matrix4f, Box box, Color color) {
GL11.glDisable(GL11.GL_BLEND);
}

public static void draw3DBox(Matrix4f matrix4f, Box box, Color color, float opacity, float lineThickness) {
RenderSystem.setShaderColor(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), opacity);

GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glLineWidth(lineThickness);

Tessellator tessellator = RenderSystem.renderThreadTesselator();
RenderSystem.setShader(GameRenderer::getPositionProgram);

BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);

BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

RenderSystem.setShaderColor(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), color.getAlphaFloat());
RenderSystem.setShader(GameRenderer::getPositionProgram);

bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);

bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.maxX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);

bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.minZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.minY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.maxZ);
bufferBuilder.vertex(matrix4f, (float) box.minX, (float) box.maxY, (float) box.minZ);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.setShaderColor(1, 1, 1, 1);

GL11.glLineWidth(1.0f);
RenderSystem.setShaderColor(1, 1, 1, 1);

GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);
}

public static void drawLine3D(Matrix4f matrix4f, Vec3d pos, Vec3d pos2, Color color) {
RenderSystem.setShaderColor(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), color.getAlphaFloat());

Expand All @@ -476,6 +569,29 @@ public static void drawLine3D(Matrix4f matrix4f, Vec3d pos, Vec3d pos2, Color co
GL11.glDisable(GL11.GL_BLEND);
}

public static void drawLine3D(Matrix4f matrix4f, Vec3d pos, Vec3d pos2, Color color, float thickness) {
RenderSystem.setShaderColor(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), color.getAlphaFloat());

GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glLineWidth(thickness);

Tessellator tessellator = RenderSystem.renderThreadTesselator();
RenderSystem.setShader(GameRenderer::getPositionProgram);

BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
bufferBuilder.vertex(matrix4f, (float) pos.x, (float) pos.y, (float) pos.z);
bufferBuilder.vertex(matrix4f, (float) pos2.x, (float) pos2.y, (float) pos2.z);

BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.setShaderColor(1, 1, 1, 1);

GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glLineWidth(1.0f);
}

public static void drawString(DrawContext drawContext, String text, float x, float y, Color color) {
AobaClient aoba = Aoba.getInstance();
MatrixStack matrixStack = drawContext.getMatrices();
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/net/aoba/module/modules/render/Breadcrumbs.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package net.aoba.module.modules.render;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.aoba.Aoba;
import net.aoba.event.events.RenderEvent;
Expand All @@ -46,11 +47,15 @@ public class Breadcrumbs extends Module implements RenderListener, TickListener

public BooleanSetting rainbow = new BooleanSetting("breadcrumbs_rainbow", "Rainbow", "Rainbow", false);
public FloatSetting effectSpeed = new FloatSetting("breadcrumbs_effectspeed", "Effect Spd.", "Effect Spd", 4f, 1f, 20f, 0.1f);

private float timer = 10;
public FloatSetting lineThickness = new FloatSetting("breadcrumbs_linethickness", "Line Thickness", "Line Thickness", 1f, 0.1f, 10f, 0.1f);

private final float distanceThreshold = 1.0f; // Minimum distance to record a new position
private float currentTick = 0;
private List<Vec3d> positions = new ArrayList<Vec3d>();

private float timer = 10;
private final LinkedList<Vec3d> positions = new LinkedList<>();
private final int maxPositions = 1000;


public Breadcrumbs() {
super(new KeybindSetting("key.breadcrumbs", "Breadcrumbs Key", InputUtil.fromKeyCode(GLFW.GLFW_KEY_UNKNOWN, 0)));

Expand All @@ -62,12 +67,14 @@ public Breadcrumbs() {
this.addSetting(color);
this.addSetting(rainbow);
this.addSetting(effectSpeed);
this.addSetting(lineThickness);
}

@Override
public void onDisable() {
Aoba.getInstance().eventManager.RemoveListener(RenderListener.class, this);
Aoba.getInstance().eventManager.RemoveListener(TickListener.class, this);
positions.clear();
}

@Override
Expand All @@ -80,21 +87,31 @@ public void onEnable() {
public void onToggle() {

}

@Override
public void OnRender(RenderEvent event) {
for(int i = 0; i < this.positions.size() - 1; i++) {
RenderUtils.drawLine3D(event.GetMatrix().peek().getPositionMatrix(), this.positions.get(i), this.positions.get(i + 1), this.currentColor);
Vec3d prevPosition = null;
for (Vec3d position : positions) {
if (prevPosition != null) {
RenderUtils.drawLine3D(event.GetMatrix().peek().getPositionMatrix(), prevPosition, position, currentColor, lineThickness.getValue().floatValue());
}
prevPosition = position;
}
}

@Override
public void OnUpdate(TickEvent event) {
currentTick++;
if(timer == currentTick) {
if (timer == currentTick) {
currentTick = 0;
if(!Aoba.getInstance().moduleManager.freecam.getState()) {
positions.add(MC.player.getPos());
if (!Aoba.getInstance().moduleManager.freecam.getState()) {
Vec3d currentPosition = MC.player.getPos();
if (positions.isEmpty() || positions.getLast().squaredDistanceTo(currentPosition) >= distanceThreshold * distanceThreshold) {
if (positions.size() >= maxPositions) {
positions.removeFirst();
}
positions.add(currentPosition);
}
}
}
}
Expand Down
43 changes: 28 additions & 15 deletions src/main/java/net/aoba/module/modules/render/EntityESP.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,31 @@ public class EntityESP extends Module implements RenderListener {
private ColorSetting color_passive = new ColorSetting("entityesp_color_passive", "Passive Color", "Passive Color", new Color(0, 1f, 1f));
private ColorSetting color_enemies = new ColorSetting("entityesp_color_enemy", "Enemy Color", "Enemy Color", new Color(0, 1f, 1f));
private ColorSetting color_misc = new ColorSetting("entityesp_color_misc", "Misc. Color", "Misc. Color", new Color(0, 1f, 1f));

private BooleanSetting showPassiveEntities = new BooleanSetting("entityesp_show_passive", "Show Passive Entities", true);
private BooleanSetting showEnemies = new BooleanSetting("entityesp_show_enemies", "Show Enemies", true);
private BooleanSetting showMiscEntities = new BooleanSetting("entityesp_show_misc", "Show Misc Entities", true);
public BooleanSetting rainbow = new BooleanSetting("entityesp_rainbow", "Rainbow","Rainbow", false);
public FloatSetting effectSpeed = new FloatSetting("entityesp_effectspeed", "Effect Speed", "Effect Speed", 4f, 1f, 20f, 0.1f);

private FloatSetting opacity = new FloatSetting("entityesp_opacity", "Opacity", "Adjust the opacity of the ESP boxes", 0.5f, 0.1f, 1.0f, 0.05f);
private FloatSetting lineThickness = new FloatSetting("entityesp_linethickness", "Line Thickness", "Adjust the thickness of the ESP box lines", 2f, 1f, 5f, 0.1f);

public EntityESP() {
super(new KeybindSetting("key.entityesp", "EntityESP Key", InputUtil.fromKeyCode(GLFW.GLFW_KEY_UNKNOWN, 0)));

this.setName("EntityESP");
this.setCategory(Category.Render);
this.setDescription("Allows the player to see entities with an ESP.");

this.addSetting(color_passive);
this.addSetting(color_enemies);
this.addSetting(color_misc);

this.addSetting(rainbow);
this.addSetting(effectSpeed);
this.addSetting(opacity);
this.addSetting(lineThickness);
this.addSetting(showPassiveEntities);
this.addSetting(showEnemies);
this.addSetting(showMiscEntities);
}

@Override
Expand All @@ -84,21 +92,26 @@ public void onToggle() {
@Override
public void OnRender(RenderEvent event) {
Matrix4f matrix4f = event.GetMatrix().peek().getPositionMatrix();

for (Entity entity : MC.world.getEntities()) {
if (entity instanceof LivingEntity && !(entity instanceof PlayerEntity)) {

Box boundingBox = entity.getBoundingBox();
//Vec3d offset = RenderUtils.getEntityPositionOffsetInterpolated(entity, partialTicks);
//boundingBox = boundingBox.offset(offset);
if (entity instanceof AnimalEntity) {
RenderUtils.draw3DBox(matrix4f, boundingBox, color_passive.getValue());
} else if (entity instanceof Monster) {
RenderUtils.draw3DBox(matrix4f, boundingBox, color_enemies.getValue());
} else {
RenderUtils.draw3DBox(matrix4f, boundingBox, color_misc.getValue());
Box boundingBox = entity.getBoundingBox();
Color color = getColorForEntity(entity); // Determine color based on entity type
if (color != null) {
RenderUtils.draw3DBox(matrix4f, boundingBox, color, opacity.getValue(), lineThickness.getValue());
}
}
}
}

private Color getColorForEntity(Entity entity) {
if (entity instanceof AnimalEntity && showPassiveEntities.getValue()) {
return color_passive.getValue();
} else if (entity instanceof Monster && showEnemies.getValue()) {
return color_enemies.getValue();
} else if (!(entity instanceof AnimalEntity || entity instanceof Monster) && showMiscEntities.getValue()) {
return color_misc.getValue();
}
return null;
}
}

0 comments on commit d989c38

Please sign in to comment.