Skip to content

Commit

Permalink
Better 3D outline rendering, and more customisation in BlockSelection…
Browse files Browse the repository at this point in the history
… with some refactors.
  • Loading branch information
tanishisherewithhh committed Dec 22, 2024
1 parent c6d94ca commit 961f98f
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 125 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/managers/ColorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void onTick(TickEvent.CLIENT e) {
if (gui.ColorMode.value == 0) {
updatePrimaryGradients(gui.staticColor.getColor(), gui.staticColor.getColor());
}else if (gui.ColorMode.value == 1) {
updatePrimaryGradients(gui.gradientType.get().getStartGradient(), gui.gradientType.get().getEndGradient());
updatePrimaryGradients(gui.gradientType.get().getStartColor(), gui.gradientType.get().getEndColor());
}

updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow());
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/dev/heliosclient/managers/GradientManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ public static String getKeyForGradient(Gradient gradient) {


public static class Gradient {
private final Supplier<Color> startGradient;
private final Supplier<Color> endGradient;
private final Supplier<Color> startColor;
private final Supplier<Color> endColor;

public static Gradient of(Supplier<Color> startGradient, Supplier<Color> endGradient){
return new Gradient(startGradient, endGradient);
public static Gradient of(Supplier<Color> startColor, Supplier<Color> endGradient){
return new Gradient(startColor, endGradient);
}

public Gradient(Supplier<Color> startGradient, Supplier<Color> endGradient) {
this.startGradient = startGradient;
this.endGradient = endGradient;
public Gradient(Supplier<Color> startColor, Supplier<Color> endColor) {
this.startColor = startColor;
this.endColor = endColor;
}

public Color getStartGradient() {
return startGradient.get();
public Color getStartColor() {
return startColor.get();
}

public Color getEndGradient() {
return endGradient.get();
public Color getEndColor() {
return endColor.get();
}
}

Expand Down
27 changes: 15 additions & 12 deletions src/main/java/dev/heliosclient/module/modules/movement/NoFall.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import dev.heliosclient.util.player.InventoryUtils;
import dev.heliosclient.util.player.RotationUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.fluid.Fluids;
Expand Down Expand Up @@ -196,14 +197,12 @@ private void clutch(PlayerMotionEvent event) {
event.modifyMovement().heliosClient$setXZ(0, 0);
}

BlockHitResult result = mc.world.raycast(new RaycastContext(mc.player.getPos(), mc.player.getPos().subtract(0, mc.interactionManager.getReachDistance() - 1, 0), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
BlockHitResult result = mc.world.raycast(new RaycastContext(mc.player.getPos(), mc.player.getPos().subtract(0, mc.interactionManager.getReachDistance(), 0), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));

if (result != null && result.getType() == HitResult.Type.BLOCK) {
BlockPos bpDown = result.getBlockPos();

if (!isPlayerAlreadySafe(result.getBlockPos())) {
for (ClutchItem item : ClutchItem.values()) {
cm.clutch(item, bpDown,event);
cm.clutch(item, result.getBlockPos(), event);
if (cm.hasClutchedProperly()) {
break;
}
Expand All @@ -216,22 +215,26 @@ private void clutch(PlayerMotionEvent event) {
}

private boolean shouldResetClutch() {
return mc.player.isOnGround() ||
mc.player.getBlockStateAtPos().getFluidState() != Fluids.EMPTY.getDefaultState() ||
mc.player.fallDistance < fallHeight.value;
return mc.player.isOnGround() ||
mc.player.getBlockStateAtPos().getFluidState() != Fluids.EMPTY.getDefaultState() ||
mc.player.fallDistance < fallHeight.value;
}

public boolean isPlayerAlreadySafe(BlockPos blockPos) {
public boolean isPlayerAlreadySafe(BlockPos collidingBlockPos) {
//We don't need to force place in water
BlockState state = mc.world.getBlockState(collidingBlockPos);
if(state.getFluidState().isOf(Fluids.WATER) || state.getFluidState().isOf(Fluids.FLOWING_WATER)) return true;

if (forcePlace.value) {
return false;
}

Block block = mc.world.getBlockState(blockPos).getBlock();
Block block = state.getBlock();

//If block is clutch item then it's probably safe. (probably because we are not accounting fallDistance for now,
// If block is clutch item then it's probably safe. (probably because we are not accounting fallDistance for now,
// meaning haybales and slimeblocks may still kill you).
for (ClutchItem item : ClutchItem.values()) {
if (item.getBlock() == block || block.getDefaultState().isLiquid()) {
if (item.getBlock() == block) {
return true;
}
}
Expand All @@ -242,9 +245,9 @@ public boolean isPlayerAlreadySafe(BlockPos blockPos) {

public enum ClutchItem {
WATER_BUCKET(Items.WATER_BUCKET, Items.BUCKET, Blocks.WATER),
POWDER_SNOW_BUCKET(Items.POWDER_SNOW_BUCKET, Items.BUCKET, Blocks.POWDER_SNOW),
HAY_BLOCK(Items.HAY_BLOCK, null, Blocks.HAY_BLOCK),
SLIME_BLOCK(Items.SLIME_BLOCK, null, Blocks.SLIME_BLOCK),
POWDER_SNOW_BUCKET(Items.POWDER_SNOW_BUCKET, Items.BUCKET, Blocks.POWDER_SNOW),
COB_WEB(Items.COBWEB, null, Blocks.COBWEB);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import dev.heliosclient.event.events.render.Render3DEvent;
import dev.heliosclient.module.Categories;
import dev.heliosclient.module.Module_;
import dev.heliosclient.module.settings.BooleanSetting;
import dev.heliosclient.module.settings.DoubleSetting;
import dev.heliosclient.module.settings.RGBASetting;
import dev.heliosclient.module.settings.SettingGroup;
import dev.heliosclient.module.settings.*;
import dev.heliosclient.util.color.ColorUtils;
import dev.heliosclient.util.render.Renderer3D;
import dev.heliosclient.util.render.color.QuadColor;
Expand All @@ -20,6 +17,7 @@
import org.apache.commons.lang3.ArrayUtils;

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

public class BlockSelection extends Module_ {
SettingGroup sgGeneral = new SettingGroup("General");
Expand All @@ -32,6 +30,14 @@ public class BlockSelection extends Module_ {
.onSettingChange(this)
.build()
);
BooleanSetting fill = sgGeneral.add(new BooleanSetting.Builder()
.name("Fill")
.description("Draw side fill of holes")
.value(true)
.defaultValue(true)
.onSettingChange(this)
.build()
);
BooleanSetting outline = sgGeneral.add(new BooleanSetting.Builder()
.name("Outline")
.description("Draw outline of holes")
Expand Down Expand Up @@ -61,29 +67,56 @@ public class BlockSelection extends Module_ {
.build()
);

BooleanSetting fill = sgGeneral.add(new BooleanSetting.Builder()
.name("Fill")
.description("Draw side fill of holes")
.value(true)
.defaultValue(true)
BooleanSetting gradient = sgGeneral.add(new BooleanSetting.Builder()
.name("Gradient")
.description("Uses gradients instead of static single fill colors")
.value(false)
.defaultValue(false)
.onSettingChange(this)
.build()
);
CycleSetting gradientDirection = sgGeneral.add(new CycleSetting.Builder()
.name("Gradient Direction")
.description("Direction of gradient")
.value(List.of(QuadColor.CardinalDirection.values()))
.defaultListOption(QuadColor.CardinalDirection.DIAGONAL_LEFT)
.onSettingChange(this)
.shouldRender(()-> gradient.value)
.build()
);
GradientSetting fillGradient = sgGeneral.add(new GradientSetting.Builder()
.name("Fill Gradient")
.description("Gradient of the fill")
.defaultValue("Rainbow")
.onSettingChange(this)
.shouldRender(()-> gradient.value)
.build()
);
GradientSetting lineGradient = sgGeneral.add(new GradientSetting.Builder()
.name("Line Gradient")
.description("Gradient of the outline")
.defaultValue("Rainbow")
.onSettingChange(this)
.shouldRender(()-> gradient.value)
.build()
);
RGBASetting fillColor = sgGeneral.add(new RGBASetting.Builder()
.name("Fill color")
.description("Color of the Fill")
.defaultValue(ColorUtils.changeAlpha(Color.WHITE, 125))
.onSettingChange(this)
.shouldRender(()-> !gradient.value)
.rainbow(false)
.build()
);

RGBASetting lineColor = sgGeneral.add(new RGBASetting.Builder()
.name("Line color")
.description("Color of the line")
.description("Color of the outline")
.value(Color.WHITE)
.defaultValue(Color.WHITE)
.onSettingChange(this)
.shouldRender(()-> !gradient.value)
.rainbow(false)
.build()
);
Expand Down Expand Up @@ -128,12 +161,16 @@ public void renderBlockHitResult(BlockHitResult result, boolean doEmptyRender) {
}

public void renderSelection(Box box,Direction... exclude) {
QuadColor.CardinalDirection gradientDirection = (QuadColor.CardinalDirection) this.gradientDirection.getOption();
QuadColor fillColor = gradient.value ? QuadColor.gradient(fillGradient.getStartColor().getRGB(), fillGradient.getEndColor().getRGB(),gradientDirection) : QuadColor.single(this.fillColor.value.getRGB());
QuadColor lineColor = gradient.value ? QuadColor.gradient(lineGradient.getStartColor().getRGB(), lineGradient.getEndColor().getRGB(), gradientDirection) : QuadColor.single(this.lineColor.value.getRGB());

if (outline.value && fill.value) {
Renderer3D.drawBoxBoth(box, QuadColor.single(fillColor.value.getRGB()), QuadColor.single(lineColor.value.getRGB()), (float) outlineWidth.value,exclude);
Renderer3D.drawBoxBoth(box, fillColor, lineColor, (float) outlineWidth.value,exclude);
} else if (outline.value) {
Renderer3D.drawBoxOutline(box, QuadColor.single(lineColor.value.getRGB()), (float) outlineWidth.value,exclude);
Renderer3D.drawBoxOutline(box, lineColor, (float) outlineWidth.value,exclude);
} else if (fill.value) {
Renderer3D.drawBoxFill(box, QuadColor.single(fillColor.value.getRGB()),exclude);
Renderer3D.drawBoxFill(box, fillColor,exclude);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public void onRender3d(Render3DEvent event) {
BlockState state = mc.world.getBlockState(currentBreakingPos);
VoxelShape shape = state.getOutlineShape(mc.world, currentBreakingPos);
if (shape == null || shape.isEmpty()) return;
int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();

renderIndicator(shape.getBoundingBox().expand(0.001f).offset(currentBreakingPos), selfBreakingProgress/10.0f, (IndicateType) type.getOption(),start,end);
}
Expand All @@ -113,8 +113,8 @@ public void onRender3d(Render3DEvent event) {
VoxelShape shape = state.getOutlineShape(mc.world, pos);

if (shape == null || shape.isEmpty()) return;
int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();

renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) (breakProgress + 1) / 10, (IndicateType) type.getOption(),start,end);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void renderSquare(DrawContext dr, int x, int y, int width, int height) {
}

public void renderInverseTriangleGap(DrawContext dr, int x, int y) {
Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getStartGradient();
Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getEndGradient();
Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getStartColor();
Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getEndColor();

Matrix4f mc = dr.getMatrices().peek().getPositionMatrix();
//left
Expand Down Expand Up @@ -177,8 +177,8 @@ private int getSize() {
}

public void mask(DrawContext dr, Runnable task, int x, int y, int width, int height) {
Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getStartGradient();
Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getEndGradient();
Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getStartColor();
Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getEndColor();

Renderer2D.drawToGradientMask(dr.getMatrices().peek().getPositionMatrix(),
startG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public class HoleESP extends Module_ {
.build()
);
SettingGroup sgColor = new SettingGroup("Color");

CycleSetting gradientDirection = sgColor.add(new CycleSetting.Builder()
.name("Gradient Direction")
.description("Direction of gradient, up/down")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ public void render3d(Render3DEvent event) {
VoxelShape shape = state.getOutlineShape(mc.world, pos);
if (shape == null || shape.isEmpty()) return;

int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();
int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB();

ModuleManager.get(BreakIndicator.class).renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) info.progress, (BreakIndicator.IndicateType) type.getOption(),start,end);
});
Expand Down
Loading

0 comments on commit 961f98f

Please sign in to comment.