Skip to content

Commit

Permalink
Added switchable draw modes to EntityESP.
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonk9043 committed Aug 17, 2024
1 parent d96c396 commit fc50337
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
7 changes: 2 additions & 5 deletions src/main/java/net/aoba/gui/components/EnumComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import net.aoba.gui.IGuiElement;
import net.aoba.gui.Margin;
import net.aoba.gui.Rectangle;
import net.aoba.gui.colors.Color;
import net.aoba.settings.types.EnumSetting;
import net.aoba.utils.input.CursorStyle;
import net.aoba.utils.render.Render2D;
import net.aoba.utils.types.MouseAction;
import net.aoba.utils.types.MouseButton;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Colors;


public class EnumComponent<T extends Enum<T>> extends Component {
private EnumSetting<T> enumSetting;
Expand All @@ -23,7 +20,7 @@ public class EnumComponent<T extends Enum<T>> extends Component {
private boolean hoveringRightButton;

public EnumComponent(IGuiElement parent, EnumSetting<T> enumSetting) {
super(parent, new Rectangle(null, null, null, 60f));
super(parent, new Rectangle(null, null, null, 55f));
this.enumSetting = enumSetting;

this.setMargin(new Margin(8f, 2f, 8f, 2f));
Expand Down Expand Up @@ -51,7 +48,7 @@ public void draw(DrawContext drawContext, float partialTicks) {
// Text
String enumValue = this.enumSetting.getValue().toString();
float stringWidth = Render2D.getStringWidth(enumValue);
Render2D.drawString(drawContext, enumValue, actualX + (actualWidth / 2.0f) - stringWidth, actualY + 30, 0xFFFFFF);
Render2D.drawString(drawContext, enumValue, actualX + (actualWidth / 2.0f) - stringWidth, actualY + 34, 0xFFFFFF);
}

@Override
Expand Down
46 changes: 26 additions & 20 deletions src/main/java/net/aoba/module/modules/render/EntityESP.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@
import net.aoba.module.Module;
import net.aoba.settings.types.BooleanSetting;
import net.aoba.settings.types.ColorSetting;
import net.aoba.settings.types.EnumSetting;
import net.aoba.settings.types.FloatSetting;
import net.aoba.settings.types.KeybindSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.entity.mob.Monster;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -49,16 +48,20 @@

import org.lwjgl.glfw.GLFW;



public class EntityESP extends Module implements Render3DListener {
public enum DrawMode {
BoundingBox, Model
}

private EnumSetting<DrawMode> drawMode = new EnumSetting<DrawMode>("entityesp_draw_mode", "Draw Mode", "Draw Mode", DrawMode.Model);
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", "Show Passive Entities", true);
private BooleanSetting showEnemies = new BooleanSetting("entityesp_show_enemies", "Show Enemies", "Show Enemies", true);
private BooleanSetting showMiscEntities = new BooleanSetting("entityesp_show_misc", "Show Misc Entities", "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 lineThickness = new FloatSetting("entityesp_linethickness", "Line Thickness", "Adjust the thickness of the ESP box lines", 2f, 0f, 5f, 0.1f);

public EntityESP() {
Expand All @@ -68,11 +71,10 @@ public EntityESP() {
this.setCategory(Category.of("Render"));
this.setDescription("Allows the player to see entities with an ESP.");

this.addSetting(drawMode);
this.addSetting(color_passive);
this.addSetting(color_enemies);
this.addSetting(color_misc);
this.addSetting(rainbow);
this.addSetting(effectSpeed);
this.addSetting(lineThickness);
this.addSetting(showPassiveEntities);
this.addSetting(showEnemies);
Expand All @@ -90,9 +92,7 @@ public void onEnable() {
}

@Override
public void onToggle() {

}
public void onToggle() { }

@Override
public void OnRender(Render3DEvent event) {
Expand All @@ -106,17 +106,23 @@ public void OnRender(Render3DEvent event) {
Vec3d cameraPosition = camera.getPos();
if(MC.getEntityRenderDispatcher().shouldRender(entity, frustum, cameraPosition.getX(), cameraPosition.getY(), cameraPosition.getZ())) {
if (entity instanceof LivingEntity && !(entity instanceof PlayerEntity)) {
//double interpolatedX = MathHelper.lerp(partialTicks, entity.prevX, entity.getX());
//double interpolatedY = MathHelper.lerp(partialTicks, entity.prevY, entity.getY());
//double interpolatedZ = MathHelper.lerp(partialTicks, entity.prevZ, entity.getZ());

//Box boundingBox = entity.getBoundingBox().offset(interpolatedX - entity.getX(), interpolatedY - entity.getY(), interpolatedZ - entity.getZ());

Color color = getColorForEntity(entity);
if (color != null) {
Render3D.drawEntityModel(matrixStack, partialTicks, entity, color, lineThickness.getValue());
//Render3D.draw3DBox(matrixStack, boundingBox, color, lineThickness.getValue());
}

Color color = getColorForEntity(entity);
if (color != null) {
switch(drawMode.getValue()) {
case DrawMode.BoundingBox:
double interpolatedX = MathHelper.lerp(partialTicks, entity.prevX, entity.getX());
double interpolatedY = MathHelper.lerp(partialTicks, entity.prevY, entity.getY());
double interpolatedZ = MathHelper.lerp(partialTicks, entity.prevZ, entity.getZ());

Box boundingBox = entity.getBoundingBox().offset(interpolatedX - entity.getX(), interpolatedY - entity.getY(), interpolatedZ - entity.getZ());
Render3D.draw3DBox(matrixStack, boundingBox, color, lineThickness.getValue());
break;
case DrawMode.Model:
Render3D.drawEntityModel(matrixStack, partialTicks, entity, color, lineThickness.getValue());
break;
}
}
}
}
}
Expand Down

0 comments on commit fc50337

Please sign in to comment.