Skip to content

Commit

Permalink
Changed BlockIterator. Smoothed color of LightLevelESP. Fixed HoleUti…
Browse files Browse the repository at this point in the history
…ls for double. Player damage Prediction.
  • Loading branch information
tanishisherewithhh committed Sep 14, 2024
1 parent dc3ee15 commit d8da7e9
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,22 @@

@Cancelable
public class KeyboardInputEvent extends Event {
public float movementSideways;
public float movementForward;
public boolean pressingForward;
public boolean pressingBack;
public boolean pressingLeft;
public boolean pressingRight;
public boolean jumping;
public boolean sneaking;

public KeyboardInputEvent(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) {
this.movementSideways = movementSideways;
this.movementForward = movementForward;
public KeyboardInputEvent(boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) {
this.pressingForward = pressingForward;
this.pressingBack = pressingBack;
this.pressingLeft = pressingLeft;
this.pressingRight = pressingRight;
this.jumping = jumping;
this.sneaking = sneaking;
}

public void set(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) {
this.movementSideways = movementSideways;
this.movementForward = movementForward;
public void set( boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) {
this.pressingForward = pressingForward;
this.pressingBack = pressingBack;
this.pressingLeft = pressingLeft;
Expand All @@ -36,12 +29,12 @@ public void set(float movementSideways, float movementForward, boolean pressingF
this.sneaking = sneaking;
}

public boolean isSame(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking){
return this.movementForward == movementForward && this.movementSideways == movementSideways && this.pressingForward == pressingForward && this.pressingBack == pressingBack && this.pressingRight == pressingRight && this.jumping == jumping && this.sneaking == sneaking && this.pressingLeft == pressingLeft;
public boolean isSame(boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking){
return this.pressingForward == pressingForward && this.pressingBack == pressingBack && this.pressingRight == pressingRight && this.jumping == jumping && this.sneaking == sneaking && this.pressingLeft == pressingLeft;
}

public void setNone() {
this.set(0f,0f,false,false,false,false,false,false);
this.set(false,false,false,false,false,false);
}

}
3 changes: 2 additions & 1 deletion src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.heliosclient.hud.hudelements;

import dev.heliosclient.HeliosClient;
import dev.heliosclient.event.SubscribeEvent;
import dev.heliosclient.event.events.heliosclient.FontChangeEvent;
import dev.heliosclient.hud.HudElement;
Expand Down Expand Up @@ -75,7 +76,7 @@ public ArmorHud() {
public void onSettingChange(Setting<?> setting) {
super.onSettingChange(setting);

if(setting == textSize){
if(setting == textSize && HeliosClient.shouldUpdate()){
this.cFontRenderer = new fxFontRenderer(FontManager.fonts,textSize.getFloat());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class ModuleList extends HudElement implements Listener {
.shouldRender(() -> background.value)
.build());
private final BooleanSetting glow = sgSettings.add(new BooleanSetting.Builder()
.name("Render Glow")
.name("Render-Glow")
.description("Renders a glow behind the text depending on the color of text")
.onSettingChange(this)
.defaultValue(false)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/heliosclient/mixin/MixinKeyboardInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected static float getMovementMultiplier(boolean positive, boolean negative)

@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;sneaking:Z", shift = At.Shift.AFTER), allow = 1)
private void onTick(boolean slowDown, float slowDownFactor, CallbackInfo ci) {
KeyboardInputEvent event = new KeyboardInputEvent(movementSideways, movementForward, pressingForward, pressingBack, pressingLeft, pressingRight, jumping, sneaking);
KeyboardInputEvent event = new KeyboardInputEvent(pressingForward, pressingBack, pressingLeft, pressingRight, jumping, sneaking);
EventManager.postEvent(event);

if(event.isCanceled()){
Expand All @@ -31,6 +31,7 @@ private void onTick(boolean slowDown, float slowDownFactor, CallbackInfo ci) {
this.movementForward = getMovementMultiplier(this.pressingForward, this.pressingBack);
this.movementSideways = getMovementMultiplier(this.pressingLeft, this.pressingRight);


this.jumping = event.jumping;
this.sneaking = event.sneaking;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import dev.heliosclient.util.ChatUtils;
import dev.heliosclient.util.ColorUtils;
import dev.heliosclient.util.TickTimer;
import dev.heliosclient.util.player.DamageUtils;
import dev.heliosclient.util.player.InventoryUtils;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
Expand Down Expand Up @@ -53,15 +54,21 @@ public class AutoTotem extends Module_ {
);
BooleanSetting log = sgGeneral.add(new BooleanSetting.Builder()
.name("Notify")
.description("Notifies when we restock a totem or there is no totems left")
.description("Notifies when you restock a totem or there are no totems left")
.defaultValue(false)
.onSettingChange(this)
.build()
);
BooleanSetting predictDamage = sgGeneral.add(new BooleanSetting.Builder()
.name("Predict Damage")
.description("Will try to predict the damage you will take and auto totem")
.defaultValue(false)
.onSettingChange(this)
.build()
);

KeyBind totemSwitchKey = sgGeneral.add(new KeyBind.Builder()
.name("Totem Switch Key")
.description("When you press this key, the module will automatically switch to a totem")
.description("When you press this key, you will automatically switch to a totem")
.value(KeyBind.none())
.onSettingChange(this)
.build()
Expand Down Expand Up @@ -157,7 +164,7 @@ public void packetReceive(PacketEvent.RECEIVE e){
}

private boolean isPlayerLow(){
return mc.player.getHealth() + mc.player.getAbsorptionAmount() <= healthThreshold.value;
return mc.player.getHealth() + mc.player.getAbsorptionAmount() - (predictDamage.value? DamageUtils.calculateDamageByEnv() : 0) <= healthThreshold.value;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ public void onSettingChange(Setting<?> setting) {
super.onSettingChange(setting);


//TODO: Use ray-casting instead of this unholy finding.
targetFinder.setRange(range.value);
targetFinder.setFilter(entity -> {

//Apply to all entities (like end crystal, TNT, etc.)
//Apply to all entities (like end crystal, TNT, armor-stands etc.)
boolean A = entities.getSelectedEntries().contains(entity.getType()) &&
PlayerUtils.isPlayerLookingAtEntity(mc.player, entity, range.value) &&
entity.isAlive() &&
Expand All @@ -248,11 +249,7 @@ public void onSettingChange(Setting<?> setting) {

//Apply to only living entities
if (entity instanceof LivingEntity e) {
B = entities.getSelectedEntries().contains(entity.getType()) &&
PlayerUtils.isPlayerLookingAtEntity(mc.player, entity, range.value) &&
entity.isAlive() &&
entity.isAttackable() &&
!isTeamMate(e) &&
B = !isTeamMate(e) &&
!isFriend(e) &&
!isInvisible(e) &&
!AntiBot.isBot(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dev.heliosclient.module.Categories;
import dev.heliosclient.module.Module_;
import dev.heliosclient.util.blocks.BlockUtils;
import dev.heliosclient.util.EntityUtils;
import dev.heliosclient.util.entity.EntityUtils;
import net.minecraft.util.math.BlockPos;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import dev.heliosclient.module.settings.SettingGroup;
import dev.heliosclient.system.Friend;
import dev.heliosclient.util.ChatUtils;
import dev.heliosclient.util.EntityUtils;
import dev.heliosclient.util.entity.EntityUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand Down
51 changes: 28 additions & 23 deletions src/main/java/dev/heliosclient/module/modules/render/HoleESP.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.heliosclient.module.modules.render;

import dev.heliosclient.event.SubscribeEvent;
import dev.heliosclient.event.events.TickEvent;
import dev.heliosclient.event.events.render.Render3DEvent;
import dev.heliosclient.module.Categories;
import dev.heliosclient.module.Module_;
Expand All @@ -12,13 +13,12 @@
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

import static dev.heliosclient.util.blocks.HoleUtils.HoleType.*;

public class HoleESP extends Module_ {
static Color TRANSPARENT_BLUE = new Color(0, 30, 175, 179);
SettingGroup sgGeneral = new SettingGroup("General");
BooleanSetting throughWalls = sgGeneral.add(new BooleanSetting.Builder()
.name("ThroughWalls")
Expand All @@ -32,7 +32,7 @@ public class HoleESP extends Module_ {
.name("Hole Range")
.description("Maximum distance of the hole to the player")
.min(3)
.max(100)
.max(40)
.value(20d)
.defaultValue(20d)
.roundingPlace(0)
Expand Down Expand Up @@ -134,8 +134,8 @@ public class HoleESP extends Module_ {
.description("Start of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#1dfb00"), 123))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#1dfb00"), 123))
.value(ColorUtils.hexToColor("#1dfb00", 123))
.defaultValue(ColorUtils.hexToColor("#1dfb00", 123))
.shouldRender(() -> setColorCycle.getOption() == SAFE)
.build()
);
Expand All @@ -144,8 +144,8 @@ public class HoleESP extends Module_ {
.description("End of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#4bfb83"), 3))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#4bfb83"), 3))
.value(ColorUtils.hexToColor("#4bfb83", 3))
.defaultValue(ColorUtils.hexToColor("#4bfb83", 3))
.shouldRender(() -> setColorCycle.getOption() == SAFE)
.build()
);
Expand All @@ -154,8 +154,8 @@ public class HoleESP extends Module_ {
.description("Start of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff6d00"), 142))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff6d00"), 142))
.value(ColorUtils.hexToColor("#ff6d00", 142))
.defaultValue(ColorUtils.hexToColor("#ff6d00", 142))
.shouldRender(() -> setColorCycle.getOption() == UNSAFE)
.build()
);
Expand All @@ -164,8 +164,8 @@ public class HoleESP extends Module_ {
.description("End of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb9804"), 3))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb9804"), 3))
.value(ColorUtils.hexToColor("#fb9804", 3))
.defaultValue(ColorUtils.hexToColor("#fb9804", 3))
.shouldRender(() -> setColorCycle.getOption() == UNSAFE)
.build()
);
Expand All @@ -174,8 +174,8 @@ public class HoleESP extends Module_ {
.description("Start of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff0000"), 145))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff0000"), 145))
.value(ColorUtils.hexToColor("#ff0000", 145))
.defaultValue(ColorUtils.hexToColor("#ff0000", 145))
.shouldRender(() -> setColorCycle.getOption() == DANGER)
.build()
);
Expand All @@ -184,37 +184,44 @@ public class HoleESP extends Module_ {
.description("End of the gradient.")
.onSettingChange(this)
.rainbow(false)
.value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb794b"), 7))
.defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb794b"), 7))
.value(ColorUtils.hexToColor("#f80000", 7))
.defaultValue(ColorUtils.hexToColor("#f80000", 7))
.shouldRender(() -> setColorCycle.getOption() == DANGER)
.build()
);



public HoleESP() {
super("HoleESP", "Displays holes in your area", Categories.RENDER);
addSettingGroup(sgGeneral);
addSettingGroup(sgColor);

addQuickSettings(sgGeneral.getSettings());
addQuickSettings(sgColor.getSettings());
}

List<HoleUtils.HoleInfo> holes = new ArrayList<>();

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

@SubscribeEvent
public void onRender3d(Render3DEvent event) {
if (throughWalls.value)
Renderer3D.renderThroughWalls();

QuadColor.CardinalDirection direction = gradientDirection.getOption().equals("Down") ? QuadColor.CardinalDirection.SOUTH : QuadColor.CardinalDirection.NORTH;

for (HoleUtils.HoleInfo info : HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value)) {
for (HoleUtils.HoleInfo info : holes) {
if (!renderSelf.value && mc.player.getBlockPos().isWithinDistance(info.holePosition, 1d)) {
continue;
}

//Contract and offset so that it does not fight for Z level with block textures.
Box box = new Box(info.holePosition);
double ogMaxY = box.maxY;
box = box.contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0).withMaxY(ogMaxY + height.value);
// Use the box from HoleInfo
Box box = info.holeBox.withMaxY(info.holeBox.maxY + height.value);

if (info.holeType == SAFE) {
renderHole(QuadColor.gradient(safeColorStart.value.getRGB(), safeColorEnd.value.getRGB(), direction), QuadColor.single(safeColorStart.value.getRGB()), box);
Expand All @@ -225,14 +232,12 @@ public void onRender3d(Render3DEvent event) {
if (info.holeType == DANGER) {
renderHole(QuadColor.gradient(dangerColorStart.value.getRGB(), dangerColorEnd.value.getRGB(), direction), QuadColor.single(dangerColorStart.value.getRGB()), box);
}
if (info.holeType == SIZED) {
//Renderer3D.drawBoxFill(box, QuadColor.single(TRANSPARENT_BLUE.getRGB()), Direction.UP,Direction.NORTH,Direction.SOUTH,Direction.EAST,Direction.WEST);
}
}
if (throughWalls.value)
Renderer3D.stopRenderingThroughWalls();
}


private void renderHole(QuadColor fillColor, QuadColor lineColor, Box box) {
Direction[] excludeDirs = new Direction[2];
if (!renderTop.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
import net.minecraft.util.math.Direction;
import net.minecraft.world.LightType;

import java.awt.*;

public class LightLevelESP extends Module_ {
SettingGroup sgGeneral = new SettingGroup("General");
DoubleSetting range = sgGeneral.add(new DoubleSetting.Builder()
.name("Range")
.description("Range to check light levels")
.name("Horizontal Range")
.description("Horizontal Range to check light levels")
.min(0f)
.max(50f)
.value(10d)
Expand All @@ -30,6 +28,17 @@ public class LightLevelESP extends Module_ {
.onSettingChange(this)
.build()
);
DoubleSetting vRange = sgGeneral.add(new DoubleSetting.Builder()
.name("Vertical Range")
.description("Vertical Range to check light levels")
.min(0f)
.max(10)
.value(4d)
.defaultValue(4d)
.roundingPlace(0)
.onSettingChange(this)
.build()
);

public LightLevelESP() {
super("LightLevelESP", "Shows light levels on surface of blocks", Categories.RENDER);
Expand All @@ -38,13 +47,9 @@ public LightLevelESP() {

}

int RED_LOW = ColorUtils.changeAlpha(Color.RED,100).getRGB();
int GREEN_LOW = ColorUtils.changeAlpha(Color.GREEN,100).getRGB();
int YELLOW_LOW = ColorUtils.changeAlpha(Color.YELLOW,100).getRGB();

@SubscribeEvent
public void onRender3d(Render3DEvent event) {
BlockIterator iterator = new BlockIterator(mc.player, (int) range.value, 4);
BlockIterator iterator = new BlockIterator(mc.player, (int) range.value, vRange.getInt());
while (iterator.hasNext()) {
BlockPos pos = iterator.next();

Expand All @@ -54,14 +59,11 @@ public void onRender3d(Render3DEvent event) {

int lightLevel = mc.world.getLightLevel(LightType.BLOCK, pos);

if (lightLevel < 4) {
renderTop(pos, RED_LOW); // Red for very dark
} else if (lightLevel < 8) {
renderTop(pos, GREEN_LOW); // Orange for moderately dark
} else if (lightLevel < 12) {
renderTop(pos, YELLOW_LOW); // Yellow for moderately lit
}
//Nothing for well lit
float ratio = (float) lightLevel/mc.world.getMaxLightLevel();
int red = (int) (255 * (1 - ratio));
int green = (int) (255 * ratio);
int color = ColorUtils.rgbaToInt(red,green,0,100);
renderTop(pos,color);
}
}

Expand Down
Loading

0 comments on commit d8da7e9

Please sign in to comment.